summaryrefslogtreecommitdiffstats
path: root/src/core
diff options
context:
space:
mode:
Diffstat (limited to 'src/core')
-rw-r--r--src/core/CMakeLists.txt3
-rw-r--r--src/core/debugger/gdbstub_arch.cpp4
-rw-r--r--src/core/hle/service/caps/caps_a.cpp156
-rw-r--r--src/core/hle/service/caps/caps_a.h34
-rw-r--r--src/core/hle/service/caps/caps_c.cpp16
-rw-r--r--src/core/hle/service/caps/caps_c.h5
-rw-r--r--src/core/hle/service/caps/caps_manager.cpp61
-rw-r--r--src/core/hle/service/caps/caps_manager.h16
-rw-r--r--src/core/hle/service/caps/caps_ss.cpp82
-rw-r--r--src/core/hle/service/caps/caps_ss.h18
-rw-r--r--src/core/hle/service/caps/caps_su.cpp87
-rw-r--r--src/core/hle/service/caps/caps_su.h18
-rw-r--r--src/core/hle/service/caps/caps_types.h32
-rw-r--r--src/core/hle/service/caps/caps_u.cpp110
-rw-r--r--src/core/hle/service/caps/caps_u.h16
-rw-r--r--src/core/hle/service/cmif_serialization.h6
-rw-r--r--src/core/hle/service/cmif_types.h27
-rw-r--r--src/core/hle/service/filesystem/fsp/fsp_srv.cpp9
-rw-r--r--src/core/hle/service/glue/glue.cpp7
-rw-r--r--src/core/hle/service/glue/notif.cpp291
-rw-r--r--src/core/hle/service/glue/notif.h152
-rw-r--r--src/core/hle/service/glue/time/static.cpp6
-rw-r--r--src/core/hle/service/glue/time/static.h6
-rw-r--r--src/core/hle/service/glue/time/time_zone.cpp9
-rw-r--r--src/core/hle/service/glue/time/time_zone.h10
-rw-r--r--src/core/hle/service/glue/time/time_zone_binary.cpp7
-rw-r--r--src/core/hle/service/glue/time/time_zone_binary.h6
-rw-r--r--src/core/hle/service/hid/hid.cpp5
-rw-r--r--src/core/hle/service/hid/hid_debug_server.cpp149
-rw-r--r--src/core/hle/service/hid/hid_debug_server.h21
-rw-r--r--src/core/hle/service/hid/hid_server.cpp24
-rw-r--r--src/core/hle/service/hid/hid_system_server.cpp64
-rw-r--r--src/core/hle/service/hid/hid_system_server.h3
-rw-r--r--src/core/hle/service/hid/irs.cpp588
-rw-r--r--src/core/hle/service/hid/irs.h84
-rw-r--r--src/core/hle/service/jit/jit.cpp8
-rw-r--r--src/core/hle/service/mii/mii.cpp2
-rw-r--r--src/core/hle/service/nvdrv/devices/nvdisp_disp0.cpp35
-rw-r--r--src/core/hle/service/nvdrv/devices/nvdisp_disp0.h10
-rw-r--r--src/core/hle/service/nvnflinger/hardware_composer.cpp215
-rw-r--r--src/core/hle/service/nvnflinger/hardware_composer.h59
-rw-r--r--src/core/hle/service/nvnflinger/hwc_layer.h27
-rw-r--r--src/core/hle/service/nvnflinger/nvnflinger.cpp41
-rw-r--r--src/core/hle/service/nvnflinger/nvnflinger.h2
-rw-r--r--src/core/hle/service/psc/time/clocks/context_writers.cpp6
-rw-r--r--src/core/hle/service/psc/time/clocks/context_writers.h8
-rw-r--r--src/core/hle/service/psc/time/clocks/standard_local_system_clock_core.cpp2
-rw-r--r--src/core/hle/service/psc/time/clocks/standard_local_system_clock_core.h2
-rw-r--r--src/core/hle/service/psc/time/clocks/standard_network_system_clock_core.cpp2
-rw-r--r--src/core/hle/service/psc/time/clocks/standard_network_system_clock_core.h2
-rw-r--r--src/core/hle/service/psc/time/clocks/standard_user_system_clock_core.cpp2
-rw-r--r--src/core/hle/service/psc/time/clocks/standard_user_system_clock_core.h2
-rw-r--r--src/core/hle/service/psc/time/clocks/system_clock_core.cpp4
-rw-r--r--src/core/hle/service/psc/time/clocks/system_clock_core.h4
-rw-r--r--src/core/hle/service/psc/time/service_manager.cpp18
-rw-r--r--src/core/hle/service/psc/time/service_manager.h15
-rw-r--r--src/core/hle/service/psc/time/shared_memory.cpp6
-rw-r--r--src/core/hle/service/psc/time/shared_memory.h6
-rw-r--r--src/core/hle/service/psc/time/static.cpp16
-rw-r--r--src/core/hle/service/psc/time/static.h11
-rw-r--r--src/core/hle/service/psc/time/system_clock.cpp2
-rw-r--r--src/core/hle/service/psc/time/system_clock.h2
-rw-r--r--src/core/hle/service/psc/time/time_zone.cpp6
-rw-r--r--src/core/hle/service/psc/time/time_zone.h6
-rw-r--r--src/core/hle/service/psc/time/time_zone_service.cpp6
-rw-r--r--src/core/hle/service/psc/time/time_zone_service.h6
-rw-r--r--src/core/hle/service/ro/ro.cpp4
-rw-r--r--src/core/hle/service/set/setting_formats/system_settings.h4
-rw-r--r--src/core/hle/service/set/system_settings_server.cpp37
-rw-r--r--src/core/hle/service/set/system_settings_server.h4
-rw-r--r--src/core/hle/service/vi/display/vi_display.cpp4
-rw-r--r--src/core/hle/service/vi/display/vi_display.h15
-rw-r--r--src/core/hle/service/vi/vi.cpp5
-rw-r--r--src/core/memory/cheat_engine.cpp46
-rw-r--r--src/core/memory/cheat_engine.h8
-rw-r--r--src/core/memory/dmnt_cheat_types.h2
-rw-r--r--src/core/memory/dmnt_cheat_vm.cpp74
-rw-r--r--src/core/memory/dmnt_cheat_vm.h22
78 files changed, 1731 insertions, 1159 deletions
diff --git a/src/core/CMakeLists.txt b/src/core/CMakeLists.txt
index 570acb193..eb8f643a2 100644
--- a/src/core/CMakeLists.txt
+++ b/src/core/CMakeLists.txt
@@ -775,6 +775,9 @@ add_library(core STATIC
hle/service/nvnflinger/graphic_buffer_producer.h
hle/service/nvnflinger/hos_binder_driver_server.cpp
hle/service/nvnflinger/hos_binder_driver_server.h
+ hle/service/nvnflinger/hardware_composer.cpp
+ hle/service/nvnflinger/hardware_composer.h
+ hle/service/nvnflinger/hwc_layer.h
hle/service/nvnflinger/nvnflinger.cpp
hle/service/nvnflinger/nvnflinger.h
hle/service/nvnflinger/parcel.h
diff --git a/src/core/debugger/gdbstub_arch.cpp b/src/core/debugger/gdbstub_arch.cpp
index f2a407dc8..452f565be 100644
--- a/src/core/debugger/gdbstub_arch.cpp
+++ b/src/core/debugger/gdbstub_arch.cpp
@@ -383,7 +383,7 @@ std::string GDBStubA32::RegRead(const Kernel::KThread* thread, size_t id) const
} else if (id == CPSR_REGISTER) {
return ValueToHex(context.pstate);
} else if (id >= D0_REGISTER && id < Q0_REGISTER) {
- return ValueToHex(fprs[id - D0_REGISTER][0]);
+ return ValueToHex(fprs[(id - D0_REGISTER) / 2][(id - D0_REGISTER) % 2]);
} else if (id >= Q0_REGISTER && id < FPSCR_REGISTER) {
return ValueToHex(fprs[id - Q0_REGISTER]);
} else if (id == FPSCR_REGISTER) {
@@ -406,7 +406,7 @@ void GDBStubA32::RegWrite(Kernel::KThread* thread, size_t id, std::string_view v
} else if (id == CPSR_REGISTER) {
context.pstate = HexToValue<u32>(value);
} else if (id >= D0_REGISTER && id < Q0_REGISTER) {
- fprs[id - D0_REGISTER] = {HexToValue<u64>(value), 0};
+ fprs[(id - D0_REGISTER) / 2][(id - D0_REGISTER) % 2] = HexToValue<u64>(value);
} else if (id >= Q0_REGISTER && id < FPSCR_REGISTER) {
fprs[id - Q0_REGISTER] = HexToValue<u128>(value);
} else if (id == FPSCR_REGISTER) {
diff --git a/src/core/hle/service/caps/caps_a.cpp b/src/core/hle/service/caps/caps_a.cpp
index 69acb3a8b..47ff072c5 100644
--- a/src/core/hle/service/caps/caps_a.cpp
+++ b/src/core/hle/service/caps/caps_a.cpp
@@ -5,7 +5,7 @@
#include "core/hle/service/caps/caps_a.h"
#include "core/hle/service/caps/caps_manager.h"
#include "core/hle/service/caps/caps_result.h"
-#include "core/hle/service/caps/caps_types.h"
+#include "core/hle/service/cmif_serialization.h"
#include "core/hle/service/ipc_helpers.h"
namespace Service::Capture {
@@ -18,9 +18,9 @@ IAlbumAccessorService::IAlbumAccessorService(Core::System& system_,
{0, nullptr, "GetAlbumFileCount"},
{1, nullptr, "GetAlbumFileList"},
{2, nullptr, "LoadAlbumFile"},
- {3, &IAlbumAccessorService::DeleteAlbumFile, "DeleteAlbumFile"},
+ {3, C<&IAlbumAccessorService::DeleteAlbumFile>, "DeleteAlbumFile"},
{4, nullptr, "StorageCopyAlbumFile"},
- {5, &IAlbumAccessorService::IsAlbumMounted, "IsAlbumMounted"},
+ {5, C<&IAlbumAccessorService::IsAlbumMounted>, "IsAlbumMounted"},
{6, nullptr, "GetAlbumUsage"},
{7, nullptr, "GetAlbumFileSize"},
{8, nullptr, "LoadAlbumFileThumbnail"},
@@ -33,18 +33,18 @@ IAlbumAccessorService::IAlbumAccessorService(Core::System& system_,
{15, nullptr, "GetAlbumUsage3"},
{16, nullptr, "GetAlbumMountResult"},
{17, nullptr, "GetAlbumUsage16"},
- {18, &IAlbumAccessorService::Unknown18, "Unknown18"},
+ {18, C<&IAlbumAccessorService::Unknown18>, "Unknown18"},
{19, nullptr, "Unknown19"},
{100, nullptr, "GetAlbumFileCountEx0"},
- {101, &IAlbumAccessorService::GetAlbumFileListEx0, "GetAlbumFileListEx0"},
+ {101, C<&IAlbumAccessorService::GetAlbumFileListEx0>, "GetAlbumFileListEx0"},
{202, nullptr, "SaveEditedScreenShot"},
{301, nullptr, "GetLastThumbnail"},
{302, nullptr, "GetLastOverlayMovieThumbnail"},
- {401, &IAlbumAccessorService::GetAutoSavingStorage, "GetAutoSavingStorage"},
+ {401, C<&IAlbumAccessorService::GetAutoSavingStorage>, "GetAutoSavingStorage"},
{501, nullptr, "GetRequiredStorageSpaceSizeToCopyAll"},
{1001, nullptr, "LoadAlbumScreenShotThumbnailImageEx0"},
- {1002, &IAlbumAccessorService::LoadAlbumScreenShotImageEx1, "LoadAlbumScreenShotImageEx1"},
- {1003, &IAlbumAccessorService::LoadAlbumScreenShotThumbnailImageEx1, "LoadAlbumScreenShotThumbnailImageEx1"},
+ {1002, C<&IAlbumAccessorService::LoadAlbumScreenShotImageEx1>, "LoadAlbumScreenShotImageEx1"},
+ {1003, C<&IAlbumAccessorService::LoadAlbumScreenShotThumbnailImageEx1>, "LoadAlbumScreenShotThumbnailImageEx1"},
{8001, nullptr, "ForceAlbumUnmounted"},
{8002, nullptr, "ResetAlbumMountStatus"},
{8011, nullptr, "RefreshAlbumCache"},
@@ -62,138 +62,70 @@ IAlbumAccessorService::IAlbumAccessorService(Core::System& system_,
IAlbumAccessorService::~IAlbumAccessorService() = default;
-void IAlbumAccessorService::DeleteAlbumFile(HLERequestContext& ctx) {
- IPC::RequestParser rp{ctx};
- const auto file_id{rp.PopRaw<AlbumFileId>()};
-
+Result IAlbumAccessorService::DeleteAlbumFile(AlbumFileId file_id) {
LOG_INFO(Service_Capture, "called, application_id=0x{:0x}, storage={}, type={}",
file_id.application_id, file_id.storage, file_id.type);
- Result result = manager->DeleteAlbumFile(file_id);
- result = TranslateResult(result);
-
- IPC::ResponseBuilder rb{ctx, 2};
- rb.Push(result);
+ const Result result = manager->DeleteAlbumFile(file_id);
+ R_RETURN(TranslateResult(result));
}
-void IAlbumAccessorService::IsAlbumMounted(HLERequestContext& ctx) {
- IPC::RequestParser rp{ctx};
- const auto storage{rp.PopEnum<AlbumStorage>()};
-
+Result IAlbumAccessorService::IsAlbumMounted(Out<bool> out_is_mounted, AlbumStorage storage) {
LOG_INFO(Service_Capture, "called, storage={}", storage);
- Result result = manager->IsAlbumMounted(storage);
- const bool is_mounted = result.IsSuccess();
- result = TranslateResult(result);
-
- IPC::ResponseBuilder rb{ctx, 3};
- rb.Push(result);
- rb.Push<u8>(is_mounted);
+ const Result result = manager->IsAlbumMounted(storage);
+ *out_is_mounted = result.IsSuccess();
+ R_RETURN(TranslateResult(result));
}
-void IAlbumAccessorService::Unknown18(HLERequestContext& ctx) {
- struct UnknownBuffer {
- INSERT_PADDING_BYTES(0x10);
- };
- static_assert(sizeof(UnknownBuffer) == 0x10, "UnknownBuffer is an invalid size");
-
+Result IAlbumAccessorService::Unknown18(
+ Out<u32> out_buffer_size,
+ OutArray<u8, BufferAttr_HipcMapAlias | BufferAttr_HipcMapTransferAllowsNonSecure> out_buffer) {
LOG_WARNING(Service_Capture, "(STUBBED) called");
-
- std::vector<UnknownBuffer> buffer{};
-
- if (!buffer.empty()) {
- ctx.WriteBuffer(buffer);
- }
-
- IPC::ResponseBuilder rb{ctx, 3};
- rb.Push(ResultSuccess);
- rb.Push(static_cast<u32>(buffer.size()));
+ *out_buffer_size = 0;
+ R_SUCCEED();
}
-void IAlbumAccessorService::GetAlbumFileListEx0(HLERequestContext& ctx) {
- IPC::RequestParser rp{ctx};
- const auto storage{rp.PopEnum<AlbumStorage>()};
- const auto flags{rp.Pop<u8>()};
- const auto album_entry_size{ctx.GetWriteBufferNumElements<AlbumEntry>()};
-
+Result IAlbumAccessorService::GetAlbumFileListEx0(
+ Out<u64> out_entries_size, AlbumStorage storage, u8 flags,
+ OutArray<AlbumEntry, BufferAttr_HipcMapAlias> out_entries) {
LOG_INFO(Service_Capture, "called, storage={}, flags={}", storage, flags);
- std::vector<AlbumEntry> entries;
- Result result = manager->GetAlbumFileList(entries, storage, flags);
- result = TranslateResult(result);
-
- entries.resize(std::min(album_entry_size, entries.size()));
-
- if (!entries.empty()) {
- ctx.WriteBuffer(entries);
- }
-
- IPC::ResponseBuilder rb{ctx, 4};
- rb.Push(result);
- rb.Push<u64>(entries.size());
+ const Result result = manager->GetAlbumFileList(out_entries, *out_entries_size, storage, flags);
+ R_RETURN(TranslateResult(result));
}
-void IAlbumAccessorService::GetAutoSavingStorage(HLERequestContext& ctx) {
+Result IAlbumAccessorService::GetAutoSavingStorage(Out<bool> out_is_autosaving) {
LOG_WARNING(Service_Capture, "(STUBBED) called");
- bool is_autosaving{};
- Result result = manager->GetAutoSavingStorage(is_autosaving);
- result = TranslateResult(result);
-
- IPC::ResponseBuilder rb{ctx, 3};
- rb.Push(result);
- rb.Push<u8>(is_autosaving);
+ const Result result = manager->GetAutoSavingStorage(*out_is_autosaving);
+ R_RETURN(TranslateResult(result));
}
-void IAlbumAccessorService::LoadAlbumScreenShotImageEx1(HLERequestContext& ctx) {
- IPC::RequestParser rp{ctx};
- const auto file_id{rp.PopRaw<AlbumFileId>()};
- const auto decoder_options{rp.PopRaw<ScreenShotDecodeOption>()};
- const auto image_buffer_size{ctx.GetWriteBufferSize(1)};
-
+Result IAlbumAccessorService::LoadAlbumScreenShotImageEx1(
+ const AlbumFileId& file_id, const ScreenShotDecodeOption& decoder_options,
+ OutLargeData<LoadAlbumScreenShotImageOutput, BufferAttr_HipcMapAlias> out_image_output,
+ OutArray<u8, BufferAttr_HipcMapAlias | BufferAttr_HipcMapTransferAllowsNonSecure> out_image,
+ OutArray<u8, BufferAttr_HipcMapAlias> out_buffer) {
LOG_INFO(Service_Capture, "called, application_id=0x{:0x}, storage={}, type={}, flags={}",
file_id.application_id, file_id.storage, file_id.type, decoder_options.flags);
- std::vector<u8> image;
- LoadAlbumScreenShotImageOutput image_output;
- Result result =
- manager->LoadAlbumScreenShotImage(image_output, image, file_id, decoder_options);
- result = TranslateResult(result);
-
- if (image.size() > image_buffer_size) {
- result = ResultWorkMemoryError;
- }
-
- if (result.IsSuccess()) {
- ctx.WriteBuffer(image_output, 0);
- ctx.WriteBuffer(image, 1);
- }
-
- IPC::ResponseBuilder rb{ctx, 2};
- rb.Push(result);
+ const Result result =
+ manager->LoadAlbumScreenShotImage(*out_image_output, out_image, file_id, decoder_options);
+ R_RETURN(TranslateResult(result));
}
-void IAlbumAccessorService::LoadAlbumScreenShotThumbnailImageEx1(HLERequestContext& ctx) {
- IPC::RequestParser rp{ctx};
- const auto file_id{rp.PopRaw<AlbumFileId>()};
- const auto decoder_options{rp.PopRaw<ScreenShotDecodeOption>()};
-
+Result IAlbumAccessorService::LoadAlbumScreenShotThumbnailImageEx1(
+ const AlbumFileId& file_id, const ScreenShotDecodeOption& decoder_options,
+ OutLargeData<LoadAlbumScreenShotImageOutput, BufferAttr_HipcMapAlias> out_image_output,
+ OutArray<u8, BufferAttr_HipcMapAlias | BufferAttr_HipcMapTransferAllowsNonSecure> out_image,
+ OutArray<u8, BufferAttr_HipcMapAlias> out_buffer) {
LOG_INFO(Service_Capture, "called, application_id=0x{:0x}, storage={}, type={}, flags={}",
file_id.application_id, file_id.storage, file_id.type, decoder_options.flags);
- std::vector<u8> image(ctx.GetWriteBufferSize(1));
- LoadAlbumScreenShotImageOutput image_output;
- Result result =
- manager->LoadAlbumScreenShotThumbnail(image_output, image, file_id, decoder_options);
- result = TranslateResult(result);
-
- if (result.IsSuccess()) {
- ctx.WriteBuffer(image_output, 0);
- ctx.WriteBuffer(image, 1);
- }
-
- IPC::ResponseBuilder rb{ctx, 2};
- rb.Push(result);
+ const Result result = manager->LoadAlbumScreenShotThumbnail(*out_image_output, out_image,
+ file_id, decoder_options);
+ R_RETURN(TranslateResult(result));
}
Result IAlbumAccessorService::TranslateResult(Result in_result) {
diff --git a/src/core/hle/service/caps/caps_a.h b/src/core/hle/service/caps/caps_a.h
index c90cff71e..2cb9b4547 100644
--- a/src/core/hle/service/caps/caps_a.h
+++ b/src/core/hle/service/caps/caps_a.h
@@ -3,6 +3,8 @@
#pragma once
+#include "core/hle/service/caps/caps_types.h"
+#include "core/hle/service/cmif_types.h"
#include "core/hle/service/service.h"
namespace Core {
@@ -19,13 +21,31 @@ public:
~IAlbumAccessorService() override;
private:
- void DeleteAlbumFile(HLERequestContext& ctx);
- void IsAlbumMounted(HLERequestContext& ctx);
- void Unknown18(HLERequestContext& ctx);
- void GetAlbumFileListEx0(HLERequestContext& ctx);
- void GetAutoSavingStorage(HLERequestContext& ctx);
- void LoadAlbumScreenShotImageEx1(HLERequestContext& ctx);
- void LoadAlbumScreenShotThumbnailImageEx1(HLERequestContext& ctx);
+ Result DeleteAlbumFile(AlbumFileId file_id);
+
+ Result IsAlbumMounted(Out<bool> out_is_mounted, AlbumStorage storage);
+
+ Result Unknown18(
+ Out<u32> out_buffer_size,
+ OutArray<u8, BufferAttr_HipcMapAlias | BufferAttr_HipcMapTransferAllowsNonSecure>
+ out_buffer);
+
+ Result GetAlbumFileListEx0(Out<u64> out_entries_size, AlbumStorage storage, u8 flags,
+ OutArray<AlbumEntry, BufferAttr_HipcMapAlias> out_entries);
+
+ Result GetAutoSavingStorage(Out<bool> out_is_autosaving);
+
+ Result LoadAlbumScreenShotImageEx1(
+ const AlbumFileId& file_id, const ScreenShotDecodeOption& decoder_options,
+ OutLargeData<LoadAlbumScreenShotImageOutput, BufferAttr_HipcMapAlias> out_image_output,
+ OutArray<u8, BufferAttr_HipcMapAlias | BufferAttr_HipcMapTransferAllowsNonSecure> out_image,
+ OutArray<u8, BufferAttr_HipcMapAlias> out_buffer);
+
+ Result LoadAlbumScreenShotThumbnailImageEx1(
+ const AlbumFileId& file_id, const ScreenShotDecodeOption& decoder_options,
+ OutLargeData<LoadAlbumScreenShotImageOutput, BufferAttr_HipcMapAlias> out_image_output,
+ OutArray<u8, BufferAttr_HipcMapAlias | BufferAttr_HipcMapTransferAllowsNonSecure> out_image,
+ OutArray<u8, BufferAttr_HipcMapAlias> out_buffer);
Result TranslateResult(Result in_result);
diff --git a/src/core/hle/service/caps/caps_c.cpp b/src/core/hle/service/caps/caps_c.cpp
index 1e7fe6474..6993c04c2 100644
--- a/src/core/hle/service/caps/caps_c.cpp
+++ b/src/core/hle/service/caps/caps_c.cpp
@@ -6,6 +6,7 @@
#include "core/hle/service/caps/caps_manager.h"
#include "core/hle/service/caps/caps_result.h"
#include "core/hle/service/caps/caps_types.h"
+#include "core/hle/service/cmif_serialization.h"
#include "core/hle/service/ipc_helpers.h"
namespace Service::Capture {
@@ -17,7 +18,7 @@ IAlbumControlService::IAlbumControlService(Core::System& system_,
static const FunctionInfo functions[] = {
{1, nullptr, "CaptureRawImage"},
{2, nullptr, "CaptureRawImageWithTimeout"},
- {33, &IAlbumControlService::SetShimLibraryVersion, "SetShimLibraryVersion"},
+ {33, C<&IAlbumControlService::SetShimLibraryVersion>, "SetShimLibraryVersion"},
{1001, nullptr, "RequestTakingScreenShot"},
{1002, nullptr, "RequestTakingScreenShotWithTimeout"},
{1011, nullptr, "NotifyTakingScreenShotRefused"},
@@ -42,16 +43,11 @@ IAlbumControlService::IAlbumControlService(Core::System& system_,
IAlbumControlService::~IAlbumControlService() = default;
-void IAlbumControlService::SetShimLibraryVersion(HLERequestContext& ctx) {
- IPC::RequestParser rp{ctx};
- const auto library_version{rp.Pop<u64>()};
- const auto applet_resource_user_id{rp.Pop<u64>()};
-
+Result IAlbumControlService::SetShimLibraryVersion(ShimLibraryVersion library_version,
+ ClientAppletResourceUserId aruid) {
LOG_WARNING(Service_Capture, "(STUBBED) called. library_version={}, applet_resource_user_id={}",
- library_version, applet_resource_user_id);
-
- IPC::ResponseBuilder rb{ctx, 2};
- rb.Push(ResultSuccess);
+ library_version, aruid.pid);
+ R_SUCCEED();
}
} // namespace Service::Capture
diff --git a/src/core/hle/service/caps/caps_c.h b/src/core/hle/service/caps/caps_c.h
index 92ba242db..0ecdfa114 100644
--- a/src/core/hle/service/caps/caps_c.h
+++ b/src/core/hle/service/caps/caps_c.h
@@ -3,6 +3,7 @@
#pragma once
+#include "core/hle/service/cmif_types.h"
#include "core/hle/service/service.h"
namespace Core {
@@ -11,6 +12,7 @@ class System;
namespace Service::Capture {
class AlbumManager;
+enum class ShimLibraryVersion : u64;
class IAlbumControlService final : public ServiceFramework<IAlbumControlService> {
public:
@@ -19,7 +21,8 @@ public:
~IAlbumControlService() override;
private:
- void SetShimLibraryVersion(HLERequestContext& ctx);
+ Result SetShimLibraryVersion(ShimLibraryVersion library_version,
+ ClientAppletResourceUserId aruid);
std::shared_ptr<AlbumManager> manager = nullptr;
};
diff --git a/src/core/hle/service/caps/caps_manager.cpp b/src/core/hle/service/caps/caps_manager.cpp
index 3a22b135f..7f0bc127f 100644
--- a/src/core/hle/service/caps/caps_manager.cpp
+++ b/src/core/hle/service/caps/caps_manager.cpp
@@ -58,8 +58,8 @@ Result AlbumManager::IsAlbumMounted(AlbumStorage storage) {
return is_mounted ? ResultSuccess : ResultIsNotMounted;
}
-Result AlbumManager::GetAlbumFileList(std::vector<AlbumEntry>& out_entries, AlbumStorage storage,
- u8 flags) const {
+Result AlbumManager::GetAlbumFileList(std::span<AlbumEntry> out_entries, u64& out_entries_count,
+ AlbumStorage storage, u8 flags) const {
if (storage > AlbumStorage::Sd) {
return ResultInvalidStorage;
}
@@ -72,51 +72,55 @@ Result AlbumManager::GetAlbumFileList(std::vector<AlbumEntry>& out_entries, Albu
if (file_id.storage != storage) {
continue;
}
- if (out_entries.size() >= SdAlbumFileLimit) {
+ if (out_entries_count >= SdAlbumFileLimit) {
+ break;
+ }
+ if (out_entries_count >= out_entries.size()) {
break;
}
const auto entry_size = Common::FS::GetSize(path);
- out_entries.push_back({
+ out_entries[out_entries_count++] = {
.entry_size = entry_size,
.file_id = file_id,
- });
+ };
}
return ResultSuccess;
}
-Result AlbumManager::GetAlbumFileList(std::vector<ApplicationAlbumFileEntry>& out_entries,
- ContentType content_type, s64 start_posix_time,
- s64 end_posix_time, u64 aruid) const {
+Result AlbumManager::GetAlbumFileList(std::span<ApplicationAlbumFileEntry> out_entries,
+ u64& out_entries_count, ContentType content_type,
+ s64 start_posix_time, s64 end_posix_time, u64 aruid) const {
if (!is_mounted) {
return ResultIsNotMounted;
}
- std::vector<ApplicationAlbumEntry> album_entries;
+ std::vector<ApplicationAlbumEntry> album_entries(out_entries.size());
const auto start_date = ConvertToAlbumDateTime(start_posix_time);
const auto end_date = ConvertToAlbumDateTime(end_posix_time);
- const auto result = GetAlbumFileList(album_entries, content_type, start_date, end_date, aruid);
+ const auto result = GetAlbumFileList(album_entries, out_entries_count, content_type, start_date,
+ end_date, aruid);
if (result.IsError()) {
return result;
}
- for (const auto& album_entry : album_entries) {
- ApplicationAlbumFileEntry entry{
- .entry = album_entry,
- .datetime = album_entry.datetime,
+ for (std::size_t i = 0; i < out_entries_count; i++) {
+ out_entries[i] = {
+ .entry = album_entries[i],
+ .datetime = album_entries[i].datetime,
.unknown = {},
};
- out_entries.push_back(entry);
}
return ResultSuccess;
}
-Result AlbumManager::GetAlbumFileList(std::vector<ApplicationAlbumEntry>& out_entries,
- ContentType content_type, AlbumFileDateTime start_date,
- AlbumFileDateTime end_date, u64 aruid) const {
+Result AlbumManager::GetAlbumFileList(std::span<ApplicationAlbumEntry> out_entries,
+ u64& out_entries_count, ContentType content_type,
+ AlbumFileDateTime start_date, AlbumFileDateTime end_date,
+ u64 aruid) const {
if (!is_mounted) {
return ResultIsNotMounted;
}
@@ -131,12 +135,15 @@ Result AlbumManager::GetAlbumFileList(std::vector<ApplicationAlbumEntry>& out_en
if (file_id.date < end_date) {
continue;
}
- if (out_entries.size() >= SdAlbumFileLimit) {
+ if (out_entries_count >= SdAlbumFileLimit) {
+ break;
+ }
+ if (out_entries_count >= out_entries.size()) {
break;
}
const auto entry_size = Common::FS::GetSize(path);
- ApplicationAlbumEntry entry{
+ out_entries[out_entries_count++] = {
.size = entry_size,
.hash{},
.datetime = file_id.date,
@@ -144,7 +151,6 @@ Result AlbumManager::GetAlbumFileList(std::vector<ApplicationAlbumEntry>& out_en
.content = content_type,
.unknown = 1,
};
- out_entries.push_back(entry);
}
return ResultSuccess;
@@ -156,8 +162,7 @@ Result AlbumManager::GetAutoSavingStorage(bool& out_is_autosaving) const {
}
Result AlbumManager::LoadAlbumScreenShotImage(LoadAlbumScreenShotImageOutput& out_image_output,
- std::vector<u8>& out_image,
- const AlbumFileId& file_id,
+ std::span<u8> out_image, const AlbumFileId& file_id,
const ScreenShotDecodeOption& decoder_options) const {
if (file_id.storage > AlbumStorage::Sd) {
return ResultInvalidStorage;
@@ -176,7 +181,9 @@ Result AlbumManager::LoadAlbumScreenShotImage(LoadAlbumScreenShotImageOutput& ou
.orientation = AlbumImageOrientation::None,
.unknown_1{},
.unknown_2{},
+ .pad163{},
},
+ .pad179{},
};
std::filesystem::path path;
@@ -186,14 +193,12 @@ Result AlbumManager::LoadAlbumScreenShotImage(LoadAlbumScreenShotImageOutput& ou
return result;
}
- out_image.resize(out_image_output.height * out_image_output.width * STBI_rgb_alpha);
-
return LoadImage(out_image, path, static_cast<int>(out_image_output.width),
+static_cast<int>(out_image_output.height), decoder_options.flags);
}
Result AlbumManager::LoadAlbumScreenShotThumbnail(
- LoadAlbumScreenShotImageOutput& out_image_output, std::vector<u8>& out_image,
+ LoadAlbumScreenShotImageOutput& out_image_output, std::span<u8> out_image,
const AlbumFileId& file_id, const ScreenShotDecodeOption& decoder_options) const {
if (file_id.storage > AlbumStorage::Sd) {
return ResultInvalidStorage;
@@ -212,7 +217,9 @@ Result AlbumManager::LoadAlbumScreenShotThumbnail(
.orientation = AlbumImageOrientation::None,
.unknown_1{},
.unknown_2{},
+ .pad163{},
},
+ .pad179{},
};
std::filesystem::path path;
@@ -222,8 +229,6 @@ Result AlbumManager::LoadAlbumScreenShotThumbnail(
return result;
}
- out_image.resize(out_image_output.height * out_image_output.width * STBI_rgb_alpha);
-
return LoadImage(out_image, path, static_cast<int>(out_image_output.width),
+static_cast<int>(out_image_output.height), decoder_options.flags);
}
diff --git a/src/core/hle/service/caps/caps_manager.h b/src/core/hle/service/caps/caps_manager.h
index 6fd34f589..893a9075a 100644
--- a/src/core/hle/service/caps/caps_manager.h
+++ b/src/core/hle/service/caps/caps_manager.h
@@ -42,20 +42,20 @@ public:
Result DeleteAlbumFile(const AlbumFileId& file_id);
Result IsAlbumMounted(AlbumStorage storage);
- Result GetAlbumFileList(std::vector<AlbumEntry>& out_entries, AlbumStorage storage,
- u8 flags) const;
- Result GetAlbumFileList(std::vector<ApplicationAlbumFileEntry>& out_entries,
- ContentType content_type, s64 start_posix_time, s64 end_posix_time,
- u64 aruid) const;
- Result GetAlbumFileList(std::vector<ApplicationAlbumEntry>& out_entries,
+ Result GetAlbumFileList(std::span<AlbumEntry> out_entries, u64& out_entries_count,
+ AlbumStorage storage, u8 flags) const;
+ Result GetAlbumFileList(std::span<ApplicationAlbumFileEntry> out_entries,
+ u64& out_entries_count, ContentType content_type, s64 start_posix_time,
+ s64 end_posix_time, u64 aruid) const;
+ Result GetAlbumFileList(std::span<ApplicationAlbumEntry> out_entries, u64& out_entries_count,
ContentType content_type, AlbumFileDateTime start_date,
AlbumFileDateTime end_date, u64 aruid) const;
Result GetAutoSavingStorage(bool& out_is_autosaving) const;
Result LoadAlbumScreenShotImage(LoadAlbumScreenShotImageOutput& out_image_output,
- std::vector<u8>& out_image, const AlbumFileId& file_id,
+ std::span<u8> out_image, const AlbumFileId& file_id,
const ScreenShotDecodeOption& decoder_options) const;
Result LoadAlbumScreenShotThumbnail(LoadAlbumScreenShotImageOutput& out_image_output,
- std::vector<u8>& out_image, const AlbumFileId& file_id,
+ std::span<u8> out_image, const AlbumFileId& file_id,
const ScreenShotDecodeOption& decoder_options) const;
Result SaveScreenShot(ApplicationAlbumEntry& out_entry, const ScreenShotAttribute& attribute,
diff --git a/src/core/hle/service/caps/caps_ss.cpp b/src/core/hle/service/caps/caps_ss.cpp
index eab023568..dfa7f1a84 100644
--- a/src/core/hle/service/caps/caps_ss.cpp
+++ b/src/core/hle/service/caps/caps_ss.cpp
@@ -3,10 +3,9 @@
#include "common/logging/log.h"
#include "core/hle/service/caps/caps_manager.h"
-#include "core/hle/service/caps/caps_types.h"
-#include "core/hle/service/ipc_helpers.h"
-
#include "core/hle/service/caps/caps_ss.h"
+#include "core/hle/service/cmif_serialization.h"
+#include "core/hle/service/ipc_helpers.h"
namespace Service::Capture {
@@ -17,9 +16,9 @@ IScreenShotService::IScreenShotService(Core::System& system_,
static const FunctionInfo functions[] = {
{201, nullptr, "SaveScreenShot"},
{202, nullptr, "SaveEditedScreenShot"},
- {203, &IScreenShotService::SaveScreenShotEx0, "SaveScreenShotEx0"},
+ {203, C<&IScreenShotService::SaveScreenShotEx0>, "SaveScreenShotEx0"},
{204, nullptr, "SaveEditedScreenShotEx0"},
- {206, &IScreenShotService::SaveEditedScreenShotEx1, "SaveEditedScreenShotEx1"},
+ {206, C<&IScreenShotService::SaveEditedScreenShotEx1>, "SaveEditedScreenShotEx1"},
{208, nullptr, "SaveScreenShotOfMovieEx1"},
{1000, nullptr, "Unknown1000"},
};
@@ -30,69 +29,38 @@ IScreenShotService::IScreenShotService(Core::System& system_,
IScreenShotService::~IScreenShotService() = default;
-void IScreenShotService::SaveScreenShotEx0(HLERequestContext& ctx) {
- IPC::RequestParser rp{ctx};
- struct Parameters {
- ScreenShotAttribute attribute{};
- AlbumReportOption report_option{};
- INSERT_PADDING_BYTES(0x4);
- u64 applet_resource_user_id{};
- };
- static_assert(sizeof(Parameters) == 0x50, "Parameters has incorrect size.");
-
- const auto parameters{rp.PopRaw<Parameters>()};
- const auto image_data_buffer = ctx.ReadBuffer();
-
+Result IScreenShotService::SaveScreenShotEx0(
+ Out<ApplicationAlbumEntry> out_entry, const ScreenShotAttribute& attribute,
+ AlbumReportOption report_option, ClientAppletResourceUserId aruid,
+ InBuffer<BufferAttr_HipcMapTransferAllowsNonSecure | BufferAttr_HipcMapAlias>
+ image_data_buffer) {
LOG_INFO(Service_Capture,
"called, report_option={}, image_data_buffer_size={}, applet_resource_user_id={}",
- parameters.report_option, image_data_buffer.size(),
- parameters.applet_resource_user_id);
+ report_option, image_data_buffer.size(), aruid.pid);
- ApplicationAlbumEntry entry{};
manager->FlipVerticallyOnWrite(false);
- const auto result =
- manager->SaveScreenShot(entry, parameters.attribute, parameters.report_option,
- image_data_buffer, parameters.applet_resource_user_id);
-
- IPC::ResponseBuilder rb{ctx, 10};
- rb.Push(result);
- rb.PushRaw(entry);
+ R_RETURN(manager->SaveScreenShot(*out_entry, attribute, report_option, image_data_buffer,
+ aruid.pid));
}
-void IScreenShotService::SaveEditedScreenShotEx1(HLERequestContext& ctx) {
- IPC::RequestParser rp{ctx};
- struct Parameters {
- ScreenShotAttribute attribute;
- u64 width;
- u64 height;
- u64 thumbnail_width;
- u64 thumbnail_height;
- AlbumFileId file_id;
- };
- static_assert(sizeof(Parameters) == 0x78, "Parameters has incorrect size.");
-
- const auto parameters{rp.PopRaw<Parameters>()};
- const auto application_data_buffer = ctx.ReadBuffer(0);
- const auto image_data_buffer = ctx.ReadBuffer(1);
- const auto thumbnail_image_data_buffer = ctx.ReadBuffer(2);
-
+Result IScreenShotService::SaveEditedScreenShotEx1(
+ Out<ApplicationAlbumEntry> out_entry, const ScreenShotAttribute& attribute, u64 width,
+ u64 height, u64 thumbnail_width, u64 thumbnail_height, const AlbumFileId& file_id,
+ const InLargeData<std::array<u8, 0x400>, BufferAttr_HipcMapAlias> application_data_buffer,
+ const InBuffer<BufferAttr_HipcMapTransferAllowsNonSecure | BufferAttr_HipcMapAlias>
+ image_data_buffer,
+ const InBuffer<BufferAttr_HipcMapTransferAllowsNonSecure | BufferAttr_HipcMapAlias>
+ thumbnail_image_data_buffer) {
LOG_INFO(Service_Capture,
"called, width={}, height={}, thumbnail_width={}, thumbnail_height={}, "
- "application_id={:016x}, storage={}, type={}, app_data_buffer_size={}, "
+ "application_id={:016x}, storage={}, type={}, "
"image_data_buffer_size={}, thumbnail_image_buffer_size={}",
- parameters.width, parameters.height, parameters.thumbnail_width,
- parameters.thumbnail_height, parameters.file_id.application_id,
- parameters.file_id.storage, parameters.file_id.type, application_data_buffer.size(),
- image_data_buffer.size(), thumbnail_image_data_buffer.size());
+ width, height, thumbnail_width, thumbnail_height, file_id.application_id,
+ file_id.storage, file_id.type, image_data_buffer.size(),
+ thumbnail_image_data_buffer.size());
- ApplicationAlbumEntry entry{};
manager->FlipVerticallyOnWrite(false);
- const auto result = manager->SaveEditedScreenShot(entry, parameters.attribute,
- parameters.file_id, image_data_buffer);
-
- IPC::ResponseBuilder rb{ctx, 10};
- rb.Push(result);
- rb.PushRaw(entry);
+ R_RETURN(manager->SaveEditedScreenShot(*out_entry, attribute, file_id, image_data_buffer));
}
} // namespace Service::Capture
diff --git a/src/core/hle/service/caps/caps_ss.h b/src/core/hle/service/caps/caps_ss.h
index a7e9972ab..da4b4cc5f 100644
--- a/src/core/hle/service/caps/caps_ss.h
+++ b/src/core/hle/service/caps/caps_ss.h
@@ -3,6 +3,8 @@
#pragma once
+#include "core/hle/service/caps/caps_types.h"
+#include "core/hle/service/cmif_types.h"
#include "core/hle/service/service.h"
namespace Core {
@@ -17,8 +19,20 @@ public:
~IScreenShotService() override;
private:
- void SaveScreenShotEx0(HLERequestContext& ctx);
- void SaveEditedScreenShotEx1(HLERequestContext& ctx);
+ Result SaveScreenShotEx0(
+ Out<ApplicationAlbumEntry> out_entry, const ScreenShotAttribute& attribute,
+ AlbumReportOption report_option, ClientAppletResourceUserId aruid,
+ InBuffer<BufferAttr_HipcMapTransferAllowsNonSecure | BufferAttr_HipcMapAlias>
+ image_data_buffer);
+
+ Result SaveEditedScreenShotEx1(
+ Out<ApplicationAlbumEntry> out_entry, const ScreenShotAttribute& attribute, u64 width,
+ u64 height, u64 thumbnail_width, u64 thumbnail_height, const AlbumFileId& file_id,
+ const InLargeData<std::array<u8, 0x400>, BufferAttr_HipcMapAlias> application_data_buffer,
+ const InBuffer<BufferAttr_HipcMapTransferAllowsNonSecure | BufferAttr_HipcMapAlias>
+ image_data_buffer,
+ const InBuffer<BufferAttr_HipcMapTransferAllowsNonSecure | BufferAttr_HipcMapAlias>
+ thumbnail_image_data_buffer);
std::shared_ptr<AlbumManager> manager;
};
diff --git a/src/core/hle/service/caps/caps_su.cpp b/src/core/hle/service/caps/caps_su.cpp
index 296b07b00..528f364f5 100644
--- a/src/core/hle/service/caps/caps_su.cpp
+++ b/src/core/hle/service/caps/caps_su.cpp
@@ -6,6 +6,7 @@
#include "core/hle/service/caps/caps_manager.h"
#include "core/hle/service/caps/caps_su.h"
#include "core/hle/service/caps/caps_types.h"
+#include "core/hle/service/cmif_serialization.h"
#include "core/hle/service/ipc_helpers.h"
#include "video_core/renderer_base.h"
@@ -16,10 +17,10 @@ IScreenShotApplicationService::IScreenShotApplicationService(
: ServiceFramework{system_, "caps:su"}, manager{album_manager} {
// clang-format off
static const FunctionInfo functions[] = {
- {32, &IScreenShotApplicationService::SetShimLibraryVersion, "SetShimLibraryVersion"},
+ {32, C<&IScreenShotApplicationService::SetShimLibraryVersion>, "SetShimLibraryVersion"},
{201, nullptr, "SaveScreenShot"},
- {203, &IScreenShotApplicationService::SaveScreenShotEx0, "SaveScreenShotEx0"},
- {205, &IScreenShotApplicationService::SaveScreenShotEx1, "SaveScreenShotEx1"},
+ {203, C<&IScreenShotApplicationService::SaveScreenShotEx0>, "SaveScreenShotEx0"},
+ {205, C<&IScreenShotApplicationService::SaveScreenShotEx1>, "SaveScreenShotEx1"},
{210, nullptr, "SaveScreenShotEx2"},
};
// clang-format on
@@ -29,77 +30,40 @@ IScreenShotApplicationService::IScreenShotApplicationService(
IScreenShotApplicationService::~IScreenShotApplicationService() = default;
-void IScreenShotApplicationService::SetShimLibraryVersion(HLERequestContext& ctx) {
- IPC::RequestParser rp{ctx};
- const auto library_version{rp.Pop<u64>()};
- const auto applet_resource_user_id{rp.Pop<u64>()};
-
+Result IScreenShotApplicationService::SetShimLibraryVersion(ShimLibraryVersion library_version,
+ ClientAppletResourceUserId aruid) {
LOG_WARNING(Service_Capture, "(STUBBED) called. library_version={}, applet_resource_user_id={}",
- library_version, applet_resource_user_id);
-
- IPC::ResponseBuilder rb{ctx, 2};
- rb.Push(ResultSuccess);
+ library_version, aruid.pid);
+ R_SUCCEED();
}
-void IScreenShotApplicationService::SaveScreenShotEx0(HLERequestContext& ctx) {
- IPC::RequestParser rp{ctx};
- struct Parameters {
- ScreenShotAttribute attribute{};
- AlbumReportOption report_option{};
- INSERT_PADDING_BYTES(0x4);
- u64 applet_resource_user_id{};
- };
- static_assert(sizeof(Parameters) == 0x50, "Parameters has incorrect size.");
-
- const auto parameters{rp.PopRaw<Parameters>()};
- const auto image_data_buffer = ctx.ReadBuffer();
-
+Result IScreenShotApplicationService::SaveScreenShotEx0(
+ Out<ApplicationAlbumEntry> out_entry, const ScreenShotAttribute& attribute,
+ AlbumReportOption report_option, ClientAppletResourceUserId aruid,
+ InBuffer<BufferAttr_HipcMapTransferAllowsNonSecure | BufferAttr_HipcMapAlias>
+ image_data_buffer) {
LOG_INFO(Service_Capture,
"called, report_option={}, image_data_buffer_size={}, applet_resource_user_id={}",
- parameters.report_option, image_data_buffer.size(),
- parameters.applet_resource_user_id);
+ report_option, image_data_buffer.size(), aruid.pid);
- ApplicationAlbumEntry entry{};
manager->FlipVerticallyOnWrite(false);
- const auto result =
- manager->SaveScreenShot(entry, parameters.attribute, parameters.report_option,
- image_data_buffer, parameters.applet_resource_user_id);
-
- IPC::ResponseBuilder rb{ctx, 10};
- rb.Push(result);
- rb.PushRaw(entry);
+ R_RETURN(manager->SaveScreenShot(*out_entry, attribute, report_option, image_data_buffer,
+ aruid.pid));
}
-void IScreenShotApplicationService::SaveScreenShotEx1(HLERequestContext& ctx) {
- IPC::RequestParser rp{ctx};
- struct Parameters {
- ScreenShotAttribute attribute{};
- AlbumReportOption report_option{};
- INSERT_PADDING_BYTES(0x4);
- u64 applet_resource_user_id{};
- };
- static_assert(sizeof(Parameters) == 0x50, "Parameters has incorrect size.");
-
- const auto parameters{rp.PopRaw<Parameters>()};
- const auto app_data_buffer = ctx.ReadBuffer(0);
- const auto image_data_buffer = ctx.ReadBuffer(1);
-
+Result IScreenShotApplicationService::SaveScreenShotEx1(
+ Out<ApplicationAlbumEntry> out_entry, const ScreenShotAttribute& attribute,
+ AlbumReportOption report_option, ClientAppletResourceUserId aruid,
+ const InLargeData<ApplicationData, BufferAttr_HipcMapAlias> app_data_buffer,
+ const InBuffer<BufferAttr_HipcMapTransferAllowsNonSecure | BufferAttr_HipcMapAlias>
+ image_data_buffer) {
LOG_INFO(Service_Capture,
"called, report_option={}, image_data_buffer_size={}, applet_resource_user_id={}",
- parameters.report_option, image_data_buffer.size(),
- parameters.applet_resource_user_id);
+ report_option, image_data_buffer.size(), aruid.pid);
- ApplicationAlbumEntry entry{};
- ApplicationData app_data{};
- std::memcpy(&app_data, app_data_buffer.data(), sizeof(ApplicationData));
manager->FlipVerticallyOnWrite(false);
- const auto result =
- manager->SaveScreenShot(entry, parameters.attribute, parameters.report_option, app_data,
- image_data_buffer, parameters.applet_resource_user_id);
-
- IPC::ResponseBuilder rb{ctx, 10};
- rb.Push(result);
- rb.PushRaw(entry);
+ R_RETURN(manager->SaveScreenShot(*out_entry, attribute, report_option, *app_data_buffer,
+ image_data_buffer, aruid.pid));
}
void IScreenShotApplicationService::CaptureAndSaveScreenshot(AlbumReportOption report_option) {
@@ -112,6 +76,7 @@ void IScreenShotApplicationService::CaptureAndSaveScreenshot(AlbumReportOption r
.orientation = Capture::AlbumImageOrientation::None,
.unknown_1{},
.unknown_2{},
+ .pad163{},
};
renderer.RequestScreenshot(
diff --git a/src/core/hle/service/caps/caps_su.h b/src/core/hle/service/caps/caps_su.h
index 21912e95f..4b4cbd09e 100644
--- a/src/core/hle/service/caps/caps_su.h
+++ b/src/core/hle/service/caps/caps_su.h
@@ -3,6 +3,8 @@
#pragma once
+#include "core/hle/service/caps/caps_types.h"
+#include "core/hle/service/cmif_types.h"
#include "core/hle/service/service.h"
namespace Core {
@@ -26,9 +28,19 @@ private:
static constexpr std::size_t screenshot_height = 720;
static constexpr std::size_t bytes_per_pixel = 4;
- void SetShimLibraryVersion(HLERequestContext& ctx);
- void SaveScreenShotEx0(HLERequestContext& ctx);
- void SaveScreenShotEx1(HLERequestContext& ctx);
+ Result SetShimLibraryVersion(ShimLibraryVersion library_version,
+ ClientAppletResourceUserId aruid);
+ Result SaveScreenShotEx0(
+ Out<ApplicationAlbumEntry> out_entry, const ScreenShotAttribute& attribute,
+ AlbumReportOption report_option, ClientAppletResourceUserId aruid,
+ InBuffer<BufferAttr_HipcMapTransferAllowsNonSecure | BufferAttr_HipcMapAlias>
+ image_data_buffer);
+ Result SaveScreenShotEx1(
+ Out<ApplicationAlbumEntry> out_entry, const ScreenShotAttribute& attribute,
+ AlbumReportOption report_option, ClientAppletResourceUserId aruid,
+ const InLargeData<ApplicationData, BufferAttr_HipcMapAlias> app_data_buffer,
+ const InBuffer<BufferAttr_HipcMapTransferAllowsNonSecure | BufferAttr_HipcMapAlias>
+ image_data_buffer);
std::array<u8, screenshot_width * screenshot_height * bytes_per_pixel> image_data;
diff --git a/src/core/hle/service/caps/caps_types.h b/src/core/hle/service/caps/caps_types.h
index 589ac28d3..3deaaad5b 100644
--- a/src/core/hle/service/caps/caps_types.h
+++ b/src/core/hle/service/caps/caps_types.h
@@ -41,6 +41,10 @@ enum class ScreenShotDecoderFlag : u64 {
EnableBlockSmoothing = 1 << 1,
};
+enum class ShimLibraryVersion : u64 {
+ Version1 = 1,
+};
+
// This is nn::capsrv::AlbumFileDateTime
struct AlbumFileDateTime {
s16 year{};
@@ -144,19 +148,23 @@ static_assert(sizeof(ApplicationAlbumFileEntry) == 0x30,
"ApplicationAlbumFileEntry has incorrect size.");
struct ApplicationData {
- std::array<u8, 0x400> data{};
- u32 data_size{};
+ std::array<u8, 0x400> data;
+ u32 data_size;
};
static_assert(sizeof(ApplicationData) == 0x404, "ApplicationData is an invalid size");
+static_assert(std::is_trivial_v<ApplicationData>,
+ "ApplicationData type must be trivially copyable.");
struct ScreenShotAttribute {
- u32 unknown_0{};
- AlbumImageOrientation orientation{};
- u32 unknown_1{};
- u32 unknown_2{};
- INSERT_PADDING_BYTES(0x30);
+ u32 unknown_0;
+ AlbumImageOrientation orientation;
+ u32 unknown_1;
+ u32 unknown_2;
+ INSERT_PADDING_BYTES_NOINIT(0x30);
};
static_assert(sizeof(ScreenShotAttribute) == 0x40, "ScreenShotAttribute is an invalid size");
+static_assert(std::is_trivial_v<ScreenShotAttribute>,
+ "ScreenShotAttribute type must be trivially copyable.");
struct ScreenShotDecodeOption {
ScreenShotDecoderFlag flags{};
@@ -165,13 +173,15 @@ struct ScreenShotDecodeOption {
static_assert(sizeof(ScreenShotDecodeOption) == 0x20, "ScreenShotDecodeOption is an invalid size");
struct LoadAlbumScreenShotImageOutput {
- s64 width{};
- s64 height{};
- ScreenShotAttribute attribute{};
- INSERT_PADDING_BYTES(0x400);
+ s64 width;
+ s64 height;
+ ScreenShotAttribute attribute;
+ INSERT_PADDING_BYTES_NOINIT(0x400);
};
static_assert(sizeof(LoadAlbumScreenShotImageOutput) == 0x450,
"LoadAlbumScreenShotImageOutput is an invalid size");
+static_assert(std::is_trivial_v<LoadAlbumScreenShotImageOutput>,
+ "LoadAlbumScreenShotImageOutput type must be trivially copyable.");
struct LoadAlbumScreenShotImageOutputForApplication {
s64 width{};
diff --git a/src/core/hle/service/caps/caps_u.cpp b/src/core/hle/service/caps/caps_u.cpp
index b6b33fb2f..40d4d05fe 100644
--- a/src/core/hle/service/caps/caps_u.cpp
+++ b/src/core/hle/service/caps/caps_u.cpp
@@ -5,6 +5,7 @@
#include "core/hle/service/caps/caps_manager.h"
#include "core/hle/service/caps/caps_types.h"
#include "core/hle/service/caps/caps_u.h"
+#include "core/hle/service/cmif_serialization.h"
#include "core/hle/service/ipc_helpers.h"
namespace Service::Capture {
@@ -14,8 +15,8 @@ IAlbumApplicationService::IAlbumApplicationService(Core::System& system_,
: ServiceFramework{system_, "caps:u"}, manager{album_manager} {
// clang-format off
static const FunctionInfo functions[] = {
- {32, &IAlbumApplicationService::SetShimLibraryVersion, "SetShimLibraryVersion"},
- {102, &IAlbumApplicationService::GetAlbumFileList0AafeAruidDeprecated, "GetAlbumFileList0AafeAruidDeprecated"},
+ {32, C<&IAlbumApplicationService::SetShimLibraryVersion>, "SetShimLibraryVersion"},
+ {102, C<&IAlbumApplicationService::GetAlbumFileList0AafeAruidDeprecated>, "GetAlbumFileList0AafeAruidDeprecated"},
{103, nullptr, "DeleteAlbumFileByAruid"},
{104, nullptr, "GetAlbumFileSizeByAruid"},
{105, nullptr, "DeleteAlbumFileByAruidForDebug"},
@@ -24,7 +25,7 @@ IAlbumApplicationService::IAlbumApplicationService(Core::System& system_,
{130, nullptr, "PrecheckToCreateContentsByAruid"},
{140, nullptr, "GetAlbumFileList1AafeAruidDeprecated"},
{141, nullptr, "GetAlbumFileList2AafeUidAruidDeprecated"},
- {142, &IAlbumApplicationService::GetAlbumFileList3AaeAruid, "GetAlbumFileList3AaeAruid"},
+ {142, C<&IAlbumApplicationService::GetAlbumFileList3AaeAruid>, "GetAlbumFileList3AaeAruid"},
{143, nullptr, "GetAlbumFileList4AaeUidAruid"},
{144, nullptr, "GetAllAlbumFileList3AaeAruid"},
{60002, nullptr, "OpenAccessorSessionForApplication"},
@@ -36,101 +37,40 @@ IAlbumApplicationService::IAlbumApplicationService(Core::System& system_,
IAlbumApplicationService::~IAlbumApplicationService() = default;
-void IAlbumApplicationService::SetShimLibraryVersion(HLERequestContext& ctx) {
- IPC::RequestParser rp{ctx};
- const auto library_version{rp.Pop<u64>()};
- const auto applet_resource_user_id{rp.Pop<u64>()};
-
+Result IAlbumApplicationService::SetShimLibraryVersion(ShimLibraryVersion library_version,
+ ClientAppletResourceUserId aruid) {
LOG_WARNING(Service_Capture, "(STUBBED) called. library_version={}, applet_resource_user_id={}",
- library_version, applet_resource_user_id);
-
- IPC::ResponseBuilder rb{ctx, 2};
- rb.Push(ResultSuccess);
+ library_version, aruid.pid);
+ R_SUCCEED();
}
-void IAlbumApplicationService::GetAlbumFileList0AafeAruidDeprecated(HLERequestContext& ctx) {
- IPC::RequestParser rp{ctx};
- struct Parameters {
- ContentType content_type;
- INSERT_PADDING_BYTES(7);
- s64 start_posix_time;
- s64 end_posix_time;
- u64 applet_resource_user_id;
- };
- static_assert(sizeof(Parameters) == 0x20, "Parameters has incorrect size.");
-
- const auto parameters{rp.PopRaw<Parameters>()};
-
+Result IAlbumApplicationService::GetAlbumFileList0AafeAruidDeprecated(
+ Out<u64> out_entries_count, ContentType content_type, s64 start_posix_time, s64 end_posix_time,
+ ClientAppletResourceUserId aruid,
+ OutArray<ApplicationAlbumFileEntry, BufferAttr_HipcMapAlias> out_entries) {
LOG_WARNING(Service_Capture,
"(STUBBED) called. content_type={}, start_posix_time={}, end_posix_time={}, "
"applet_resource_user_id={}",
- parameters.content_type, parameters.start_posix_time, parameters.end_posix_time,
- parameters.applet_resource_user_id);
-
- Result result = ResultSuccess;
-
- if (result.IsSuccess()) {
- result = manager->IsAlbumMounted(AlbumStorage::Sd);
- }
-
- std::vector<ApplicationAlbumFileEntry> entries;
- if (result.IsSuccess()) {
- result = manager->GetAlbumFileList(entries, parameters.content_type,
- parameters.start_posix_time, parameters.end_posix_time,
- parameters.applet_resource_user_id);
- }
+ content_type, start_posix_time, end_posix_time, aruid.pid);
- if (!entries.empty()) {
- ctx.WriteBuffer(entries);
- }
-
- IPC::ResponseBuilder rb{ctx, 4};
- rb.Push(result);
- rb.Push<u64>(entries.size());
+ R_TRY(manager->IsAlbumMounted(AlbumStorage::Sd));
+ R_RETURN(manager->GetAlbumFileList(out_entries, *out_entries_count, content_type,
+ start_posix_time, end_posix_time, aruid.pid));
}
-void IAlbumApplicationService::GetAlbumFileList3AaeAruid(HLERequestContext& ctx) {
- IPC::RequestParser rp{ctx};
- struct Parameters {
- ContentType content_type;
- INSERT_PADDING_BYTES(1);
- AlbumFileDateTime start_date_time;
- AlbumFileDateTime end_date_time;
- INSERT_PADDING_BYTES(6);
- u64 applet_resource_user_id;
- };
- static_assert(sizeof(Parameters) == 0x20, "Parameters has incorrect size.");
-
- const auto parameters{rp.PopRaw<Parameters>()};
-
+Result IAlbumApplicationService::GetAlbumFileList3AaeAruid(
+ Out<u64> out_entries_count, ContentType content_type, AlbumFileDateTime start_date_time,
+ AlbumFileDateTime end_date_time, ClientAppletResourceUserId aruid,
+ OutArray<ApplicationAlbumEntry, BufferAttr_HipcMapAlias> out_entries) {
LOG_WARNING(Service_Capture,
"(STUBBED) called. content_type={}, start_date={}/{}/{}, "
"end_date={}/{}/{}, applet_resource_user_id={}",
- parameters.content_type, parameters.start_date_time.year,
- parameters.start_date_time.month, parameters.start_date_time.day,
- parameters.end_date_time.year, parameters.end_date_time.month,
- parameters.end_date_time.day, parameters.applet_resource_user_id);
-
- Result result = ResultSuccess;
-
- if (result.IsSuccess()) {
- result = manager->IsAlbumMounted(AlbumStorage::Sd);
- }
-
- std::vector<ApplicationAlbumEntry> entries;
- if (result.IsSuccess()) {
- result =
- manager->GetAlbumFileList(entries, parameters.content_type, parameters.start_date_time,
- parameters.end_date_time, parameters.applet_resource_user_id);
- }
-
- if (!entries.empty()) {
- ctx.WriteBuffer(entries);
- }
+ content_type, start_date_time.year, start_date_time.month, start_date_time.day,
+ end_date_time.year, end_date_time.month, end_date_time.day, aruid.pid);
- IPC::ResponseBuilder rb{ctx, 4};
- rb.Push(result);
- rb.Push<u64>(entries.size());
+ R_TRY(manager->IsAlbumMounted(AlbumStorage::Sd));
+ R_RETURN(manager->GetAlbumFileList(out_entries, *out_entries_count, content_type,
+ start_date_time, end_date_time, aruid.pid));
}
} // namespace Service::Capture
diff --git a/src/core/hle/service/caps/caps_u.h b/src/core/hle/service/caps/caps_u.h
index 9458c128e..023ee1fe7 100644
--- a/src/core/hle/service/caps/caps_u.h
+++ b/src/core/hle/service/caps/caps_u.h
@@ -3,6 +3,7 @@
#pragma once
+#include "core/hle/service/cmif_types.h"
#include "core/hle/service/service.h"
namespace Core {
@@ -19,9 +20,18 @@ public:
~IAlbumApplicationService() override;
private:
- void SetShimLibraryVersion(HLERequestContext& ctx);
- void GetAlbumFileList0AafeAruidDeprecated(HLERequestContext& ctx);
- void GetAlbumFileList3AaeAruid(HLERequestContext& ctx);
+ Result SetShimLibraryVersion(ShimLibraryVersion library_version,
+ ClientAppletResourceUserId aruid);
+
+ Result GetAlbumFileList0AafeAruidDeprecated(
+ Out<u64> out_entries_count, ContentType content_type, s64 start_posix_time,
+ s64 end_posix_time, ClientAppletResourceUserId aruid,
+ OutArray<ApplicationAlbumFileEntry, BufferAttr_HipcMapAlias> out_entries);
+
+ Result GetAlbumFileList3AaeAruid(
+ Out<u64> out_entries_count, ContentType content_type, AlbumFileDateTime start_date_time,
+ AlbumFileDateTime end_date_time, ClientAppletResourceUserId aruid,
+ OutArray<ApplicationAlbumEntry, BufferAttr_HipcMapAlias> out_entries);
std::shared_ptr<AlbumManager> manager = nullptr;
};
diff --git a/src/core/hle/service/cmif_serialization.h b/src/core/hle/service/cmif_serialization.h
index 315475e71..e985fe317 100644
--- a/src/core/hle/service/cmif_serialization.h
+++ b/src/core/hle/service/cmif_serialization.h
@@ -115,6 +115,11 @@ struct ArgumentTraits {
static constexpr ArgumentType Type = ArgumentType::InData;
};
+template <typename... Ts>
+consteval bool ConstIfReference() {
+ return ((!std::is_reference_v<Ts> || std::is_const_v<std::remove_reference_t<Ts>>) && ... && true);
+}
+
struct RequestLayout {
u32 copy_handle_count;
u32 move_handle_count;
@@ -435,6 +440,7 @@ void CmifReplyWrapImpl(HLERequestContext& ctx, T& t, Result (T::*f)(A...)) {
}
const bool is_domain = Domain ? ctx.GetManager()->IsDomain() : false;
+ static_assert(ConstIfReference<A...>(), "Arguments taken by reference must be const");
using MethodArguments = std::tuple<std::remove_cvref_t<A>...>;
OutTemporaryBuffers buffers{};
diff --git a/src/core/hle/service/cmif_types.h b/src/core/hle/service/cmif_types.h
index dc06169f4..84f4c2456 100644
--- a/src/core/hle/service/cmif_types.h
+++ b/src/core/hle/service/cmif_types.h
@@ -4,10 +4,9 @@
#pragma once
#include <memory>
+#include <span>
-#include "common/common_funcs.h"
#include "common/common_types.h"
-#include "core/hle/service/hle_ipc.h"
namespace Service {
@@ -22,8 +21,10 @@ class Out {
public:
using Type = T;
+ /* implicit */ Out(const Out& t) : raw(t.raw) {}
/* implicit */ Out(AutoOut<Type>& t) : raw(&t.raw) {}
/* implicit */ Out(Type* t) : raw(t) {}
+ Out& operator=(const Out&) = delete;
Type* Get() const {
return raw;
@@ -37,6 +38,10 @@ public:
return raw;
}
+ operator Type*() const {
+ return raw;
+ }
+
private:
Type* raw;
};
@@ -113,8 +118,10 @@ class OutCopyHandle {
public:
using Type = T*;
+ /* implicit */ OutCopyHandle(const OutCopyHandle& t) : raw(t.raw) {}
/* implicit */ OutCopyHandle(AutoOut<Type>& t) : raw(&t.raw) {}
/* implicit */ OutCopyHandle(Type* t) : raw(t) {}
+ OutCopyHandle& operator=(const OutCopyHandle&) = delete;
Type* Get() const {
return raw;
@@ -128,6 +135,10 @@ public:
return raw;
}
+ operator Type*() const {
+ return raw;
+ }
+
private:
Type* raw;
};
@@ -137,8 +148,10 @@ class OutMoveHandle {
public:
using Type = T*;
+ /* implicit */ OutMoveHandle(const OutMoveHandle& t) : raw(t.raw) {}
/* implicit */ OutMoveHandle(AutoOut<Type>& t) : raw(&t.raw) {}
/* implicit */ OutMoveHandle(Type* t) : raw(t) {}
+ OutMoveHandle& operator=(const OutMoveHandle&) = delete;
Type* Get() const {
return raw;
@@ -152,6 +165,10 @@ public:
return raw;
}
+ operator Type*() const {
+ return raw;
+ }
+
private:
Type* raw;
};
@@ -248,8 +265,10 @@ public:
static constexpr BufferAttr Attr = static_cast<BufferAttr>(A | BufferAttr_In | BufferAttr_FixedSize);
using Type = T;
+ /* implicit */ OutLargeData(const OutLargeData& t) : raw(t.raw) {}
/* implicit */ OutLargeData(Type* t) : raw(t) {}
/* implicit */ OutLargeData(AutoOut<T>& t) : raw(&t.raw) {}
+ OutLargeData& operator=(const OutLargeData&) = delete;
Type* Get() const {
return raw;
@@ -263,6 +282,10 @@ public:
return raw;
}
+ operator Type*() const {
+ return raw;
+ }
+
private:
Type* raw;
};
diff --git a/src/core/hle/service/filesystem/fsp/fsp_srv.cpp b/src/core/hle/service/filesystem/fsp/fsp_srv.cpp
index 5fe534c73..63c2d3a58 100644
--- a/src/core/hle/service/filesystem/fsp/fsp_srv.cpp
+++ b/src/core/hle/service/filesystem/fsp/fsp_srv.cpp
@@ -115,6 +115,11 @@ private:
if (type->GetName() == "save") {
for (const auto& save_id : type->GetSubdirectories()) {
for (const auto& user_id : save_id->GetSubdirectories()) {
+ // Skip non user id subdirectories
+ if (user_id->GetName().size() != 0x20) {
+ continue;
+ }
+
const auto save_id_numeric = stoull_be(save_id->GetName());
auto user_id_numeric = Common::HexStringToArray<0x10>(user_id->GetName());
std::reverse(user_id_numeric.begin(), user_id_numeric.end());
@@ -160,6 +165,10 @@ private:
} else if (space == FileSys::SaveDataSpaceId::TemporaryStorage) {
// Temporary Storage
for (const auto& user_id : type->GetSubdirectories()) {
+ // Skip non user id subdirectories
+ if (user_id->GetName().size() != 0x20) {
+ continue;
+ }
for (const auto& title_id : user_id->GetSubdirectories()) {
if (!title_id->GetFiles().empty() ||
!title_id->GetSubdirectories().empty()) {
diff --git a/src/core/hle/service/glue/glue.cpp b/src/core/hle/service/glue/glue.cpp
index 10376bfac..ea2843462 100644
--- a/src/core/hle/service/glue/glue.cpp
+++ b/src/core/hle/service/glue/glue.cpp
@@ -31,8 +31,11 @@ void LoopProcess(Core::System& system) {
// Error Context
server_manager->RegisterNamedService("ectx:aw", std::make_shared<ECTX_AW>(system));
- // Notification Services for application
- server_manager->RegisterNamedService("notif:a", std::make_shared<NOTIF_A>(system));
+ // Notification Services
+ server_manager->RegisterNamedService(
+ "notif:a", std::make_shared<INotificationServicesForApplication>(system));
+ server_manager->RegisterNamedService("notif:s",
+ std::make_shared<INotificationServices>(system));
// Time
auto time = std::make_shared<Time::TimeManager>(system);
diff --git a/src/core/hle/service/glue/notif.cpp b/src/core/hle/service/glue/notif.cpp
index fec4ad86c..5a03d34c1 100644
--- a/src/core/hle/service/glue/notif.cpp
+++ b/src/core/hle/service/glue/notif.cpp
@@ -6,48 +6,31 @@
#include "common/assert.h"
#include "common/logging/log.h"
+#include "core/hle/service/cmif_serialization.h"
#include "core/hle/service/glue/notif.h"
#include "core/hle/service/ipc_helpers.h"
+#include "core/hle/service/kernel_helpers.h"
namespace Service::Glue {
-NOTIF_A::NOTIF_A(Core::System& system_) : ServiceFramework{system_, "notif:a"} {
- // clang-format off
- static const FunctionInfo functions[] = {
- {500, &NOTIF_A::RegisterAlarmSetting, "RegisterAlarmSetting"},
- {510, &NOTIF_A::UpdateAlarmSetting, "UpdateAlarmSetting"},
- {520, &NOTIF_A::ListAlarmSettings, "ListAlarmSettings"},
- {530, &NOTIF_A::LoadApplicationParameter, "LoadApplicationParameter"},
- {540, &NOTIF_A::DeleteAlarmSetting, "DeleteAlarmSetting"},
- {1000, &NOTIF_A::Initialize, "Initialize"},
- };
- // clang-format on
-
- RegisterHandlers(functions);
-}
-
-NOTIF_A::~NOTIF_A() = default;
+namespace {
-void NOTIF_A::RegisterAlarmSetting(HLERequestContext& ctx) {
- const auto alarm_setting_buffer_size = ctx.GetReadBufferSize(0);
- const auto application_parameter_size = ctx.GetReadBufferSize(1);
-
- ASSERT_MSG(alarm_setting_buffer_size == sizeof(AlarmSetting),
- "alarm_setting_buffer_size is not 0x40 bytes");
- ASSERT_MSG(application_parameter_size <= sizeof(ApplicationParameter),
- "application_parameter_size is bigger than 0x400 bytes");
+constexpr inline std::size_t MaxAlarms = 8;
- AlarmSetting new_alarm{};
- memcpy(&new_alarm, ctx.ReadBuffer(0).data(), sizeof(AlarmSetting));
+}
- // TODO: Count alarms per game id
- if (alarms.size() >= max_alarms) {
+Result NotificationServiceImpl::RegisterAlarmSetting(AlarmSettingId* out_alarm_setting_id,
+ const AlarmSetting& alarm_setting,
+ std::span<const u8> application_parameter) {
+ if (alarms.size() > MaxAlarms) {
LOG_ERROR(Service_NOTIF, "Alarm limit reached");
- IPC::ResponseBuilder rb{ctx, 2};
- rb.Push(ResultUnknown);
- return;
+ R_THROW(ResultUnknown);
}
+ ASSERT_MSG(application_parameter.size() <= sizeof(ApplicationParameter),
+ "application_parameter_size is bigger than 0x400 bytes");
+
+ AlarmSetting new_alarm = alarm_setting;
new_alarm.alarm_setting_id = last_alarm_setting_id++;
alarms.push_back(new_alarm);
@@ -55,100 +38,82 @@ void NOTIF_A::RegisterAlarmSetting(HLERequestContext& ctx) {
LOG_WARNING(Service_NOTIF,
"(STUBBED) called, application_parameter_size={}, setting_id={}, kind={}, muted={}",
- application_parameter_size, new_alarm.alarm_setting_id, new_alarm.kind,
+ application_parameter.size(), new_alarm.alarm_setting_id, new_alarm.kind,
new_alarm.muted);
- IPC::ResponseBuilder rb{ctx, 2};
- rb.Push(ResultSuccess);
- rb.Push(new_alarm.alarm_setting_id);
+ *out_alarm_setting_id = new_alarm.alarm_setting_id;
+ R_SUCCEED();
}
-void NOTIF_A::UpdateAlarmSetting(HLERequestContext& ctx) {
- const auto alarm_setting_buffer_size = ctx.GetReadBufferSize(0);
- const auto application_parameter_size = ctx.GetReadBufferSize(1);
-
- ASSERT_MSG(alarm_setting_buffer_size == sizeof(AlarmSetting),
- "alarm_setting_buffer_size is not 0x40 bytes");
- ASSERT_MSG(application_parameter_size <= sizeof(ApplicationParameter),
+Result NotificationServiceImpl::UpdateAlarmSetting(const AlarmSetting& alarm_setting,
+ std::span<const u8> application_parameter) {
+ ASSERT_MSG(application_parameter.size() <= sizeof(ApplicationParameter),
"application_parameter_size is bigger than 0x400 bytes");
- AlarmSetting alarm_setting{};
- memcpy(&alarm_setting, ctx.ReadBuffer(0).data(), sizeof(AlarmSetting));
-
const auto alarm_it = GetAlarmFromId(alarm_setting.alarm_setting_id);
if (alarm_it != alarms.end()) {
LOG_DEBUG(Service_NOTIF, "Alarm updated");
*alarm_it = alarm_setting;
- // TODO: Save application parameter data
}
LOG_WARNING(Service_NOTIF,
"(STUBBED) called, application_parameter_size={}, setting_id={}, kind={}, muted={}",
- application_parameter_size, alarm_setting.alarm_setting_id, alarm_setting.kind,
+ application_parameter.size(), alarm_setting.alarm_setting_id, alarm_setting.kind,
alarm_setting.muted);
-
- IPC::ResponseBuilder rb{ctx, 2};
- rb.Push(ResultSuccess);
+ R_SUCCEED();
}
-void NOTIF_A::ListAlarmSettings(HLERequestContext& ctx) {
+Result NotificationServiceImpl::ListAlarmSettings(s32* out_count,
+ std::span<AlarmSetting> out_alarms) {
LOG_INFO(Service_NOTIF, "called, alarm_count={}", alarms.size());
- // TODO: Only return alarms of this game id
- ctx.WriteBuffer(alarms);
+ const auto count = std::min(out_alarms.size(), alarms.size());
+ for (size_t i = 0; i < count; i++) {
+ out_alarms[i] = alarms[i];
+ }
- IPC::ResponseBuilder rb{ctx, 3};
- rb.Push(ResultSuccess);
- rb.Push(static_cast<u32>(alarms.size()));
+ *out_count = static_cast<s32>(count);
+ R_SUCCEED();
}
-void NOTIF_A::LoadApplicationParameter(HLERequestContext& ctx) {
- IPC::RequestParser rp{ctx};
- const auto alarm_setting_id{rp.Pop<AlarmSettingId>()};
-
+Result NotificationServiceImpl::LoadApplicationParameter(u32* out_size,
+ std::span<u8> out_application_parameter,
+ AlarmSettingId alarm_setting_id) {
const auto alarm_it = GetAlarmFromId(alarm_setting_id);
if (alarm_it == alarms.end()) {
LOG_ERROR(Service_NOTIF, "Invalid alarm setting id={}", alarm_setting_id);
- IPC::ResponseBuilder rb{ctx, 2};
- rb.Push(ResultUnknown);
- return;
+ R_THROW(ResultUnknown);
}
// TODO: Read application parameter related to this setting id
ApplicationParameter application_parameter{};
LOG_WARNING(Service_NOTIF, "(STUBBED) called, alarm_setting_id={}", alarm_setting_id);
+ std::memcpy(out_application_parameter.data(), application_parameter.data(),
+ std::min(sizeof(application_parameter), out_application_parameter.size()));
- ctx.WriteBuffer(application_parameter);
-
- IPC::ResponseBuilder rb{ctx, 2};
- rb.Push(ResultSuccess);
- rb.Push(static_cast<u32>(application_parameter.size()));
+ *out_size = static_cast<u32>(application_parameter.size());
+ R_SUCCEED();
}
-void NOTIF_A::DeleteAlarmSetting(HLERequestContext& ctx) {
- IPC::RequestParser rp{ctx};
- const auto alarm_setting_id{rp.Pop<AlarmSettingId>()};
-
+Result NotificationServiceImpl::DeleteAlarmSetting(AlarmSettingId alarm_setting_id) {
std::erase_if(alarms, [alarm_setting_id](const AlarmSetting& alarm) {
return alarm.alarm_setting_id == alarm_setting_id;
});
LOG_INFO(Service_NOTIF, "called, alarm_setting_id={}", alarm_setting_id);
- IPC::ResponseBuilder rb{ctx, 2};
- rb.Push(ResultSuccess);
+ R_SUCCEED();
}
-void NOTIF_A::Initialize(HLERequestContext& ctx) {
+Result NotificationServiceImpl::Initialize(u64 aruid) {
// TODO: Load previous alarms from config
LOG_WARNING(Service_NOTIF, "(STUBBED) called");
- IPC::ResponseBuilder rb{ctx, 2};
- rb.Push(ResultSuccess);
+ R_SUCCEED();
}
-std::vector<NOTIF_A::AlarmSetting>::iterator NOTIF_A::GetAlarmFromId(
+std::vector<AlarmSetting>::iterator NotificationServiceImpl::GetAlarmFromId(
AlarmSettingId alarm_setting_id) {
return std::find_if(alarms.begin(), alarms.end(),
[alarm_setting_id](const AlarmSetting& alarm) {
@@ -156,4 +121,174 @@ std::vector<NOTIF_A::AlarmSetting>::iterator NOTIF_A::GetAlarmFromId(
});
}
+INotificationServicesForApplication::INotificationServicesForApplication(Core::System& system_)
+ : ServiceFramework{system_, "notif:a"} {
+ // clang-format off
+ static const FunctionInfo functions[] = {
+ {500, D<&INotificationServicesForApplication::RegisterAlarmSetting>, "RegisterAlarmSetting"},
+ {510, D<&INotificationServicesForApplication::UpdateAlarmSetting>, "UpdateAlarmSetting"},
+ {520, D<&INotificationServicesForApplication::ListAlarmSettings>, "ListAlarmSettings"},
+ {530, D<&INotificationServicesForApplication::LoadApplicationParameter>, "LoadApplicationParameter"},
+ {540, D<&INotificationServicesForApplication::DeleteAlarmSetting>, "DeleteAlarmSetting"},
+ {1000, D<&INotificationServicesForApplication::Initialize>, "Initialize"},
+ };
+ // clang-format on
+
+ RegisterHandlers(functions);
+}
+
+INotificationServicesForApplication::~INotificationServicesForApplication() = default;
+
+Result INotificationServicesForApplication::RegisterAlarmSetting(
+ Out<AlarmSettingId> out_alarm_setting_id,
+ InLargeData<AlarmSetting, BufferAttr_HipcMapAlias> alarm_setting,
+ InBuffer<BufferAttr_HipcMapAlias> application_parameter) {
+ R_RETURN(impl.RegisterAlarmSetting(out_alarm_setting_id.Get(), *alarm_setting,
+ application_parameter));
+}
+
+Result INotificationServicesForApplication::UpdateAlarmSetting(
+ InLargeData<AlarmSetting, BufferAttr_HipcMapAlias> alarm_setting,
+ InBuffer<BufferAttr_HipcMapAlias> application_parameter) {
+ R_RETURN(impl.UpdateAlarmSetting(*alarm_setting, application_parameter));
+}
+
+Result INotificationServicesForApplication::ListAlarmSettings(
+ Out<s32> out_count, OutArray<AlarmSetting, BufferAttr_HipcMapAlias> out_alarms) {
+ R_RETURN(impl.ListAlarmSettings(out_count.Get(), out_alarms));
+}
+
+Result INotificationServicesForApplication::LoadApplicationParameter(
+ Out<u32> out_size, OutBuffer<BufferAttr_HipcMapAlias> out_application_parameter,
+ AlarmSettingId alarm_setting_id) {
+ R_RETURN(
+ impl.LoadApplicationParameter(out_size.Get(), out_application_parameter, alarm_setting_id));
+}
+
+Result INotificationServicesForApplication::DeleteAlarmSetting(AlarmSettingId alarm_setting_id) {
+ R_RETURN(impl.DeleteAlarmSetting(alarm_setting_id));
+}
+
+Result INotificationServicesForApplication::Initialize(ClientAppletResourceUserId aruid) {
+ R_RETURN(impl.Initialize(*aruid));
+}
+
+class INotificationSystemEventAccessor final
+ : public ServiceFramework<INotificationSystemEventAccessor> {
+public:
+ explicit INotificationSystemEventAccessor(Core::System& system_)
+ : ServiceFramework{system_, "INotificationSystemEventAccessor"},
+ service_context{system_, "INotificationSystemEventAccessor"} {
+ // clang-format off
+ static const FunctionInfo functions[] = {
+ {0, D<&INotificationSystemEventAccessor::GetSystemEvent>, "GetSystemEvent"},
+ };
+ // clang-format on
+
+ RegisterHandlers(functions);
+
+ notification_event =
+ service_context.CreateEvent("INotificationSystemEventAccessor:NotificationEvent");
+ }
+
+ ~INotificationSystemEventAccessor() {
+ service_context.CloseEvent(notification_event);
+ }
+
+private:
+ Result GetSystemEvent(OutCopyHandle<Kernel::KReadableEvent> out_readable_event) {
+ LOG_WARNING(Service_NOTIF, "(STUBBED) called");
+
+ *out_readable_event = &notification_event->GetReadableEvent();
+ R_SUCCEED();
+ }
+
+ KernelHelpers::ServiceContext service_context;
+ Kernel::KEvent* notification_event;
+};
+
+INotificationServices::INotificationServices(Core::System& system_)
+ : ServiceFramework{system_, "notif:s"} {
+ // clang-format off
+ static const FunctionInfo functions[] = {
+ {500, D<&INotificationServices::RegisterAlarmSetting>, "RegisterAlarmSetting"},
+ {510, D<&INotificationServices::UpdateAlarmSetting>, "UpdateAlarmSetting"},
+ {520, D<&INotificationServices::ListAlarmSettings>, "ListAlarmSettings"},
+ {530, D<&INotificationServices::LoadApplicationParameter>, "LoadApplicationParameter"},
+ {540, D<&INotificationServices::DeleteAlarmSetting>, "DeleteAlarmSetting"},
+ {1000, D<&INotificationServices::Initialize>, "Initialize"},
+ {1010, nullptr, "ListNotifications"},
+ {1020, nullptr, "DeleteNotification"},
+ {1030, nullptr, "ClearNotifications"},
+ {1040, D<&INotificationServices::OpenNotificationSystemEventAccessor>, "OpenNotificationSystemEventAccessor"},
+ {1500, nullptr, "SetNotificationPresentationSetting"},
+ {1510, D<&INotificationServices::GetNotificationPresentationSetting>, "GetNotificationPresentationSetting"},
+ {2000, nullptr, "GetAlarmSetting"},
+ {2001, nullptr, "GetAlarmSettingWithApplicationParameter"},
+ {2010, nullptr, "MuteAlarmSetting"},
+ {2020, nullptr, "IsAlarmSettingReady"},
+ {8000, nullptr, "RegisterAppletResourceUserId"},
+ {8010, nullptr, "UnregisterAppletResourceUserId"},
+ {8999, nullptr, "GetCurrentTime"},
+ {9000, nullptr, "GetAlarmSettingNextNotificationTime"},
+ };
+ // clang-format on
+
+ RegisterHandlers(functions);
+}
+
+INotificationServices::~INotificationServices() = default;
+
+Result INotificationServices::RegisterAlarmSetting(
+ Out<AlarmSettingId> out_alarm_setting_id,
+ InLargeData<AlarmSetting, BufferAttr_HipcMapAlias> alarm_setting,
+ InBuffer<BufferAttr_HipcMapAlias> application_parameter) {
+ R_RETURN(impl.RegisterAlarmSetting(out_alarm_setting_id.Get(), *alarm_setting,
+ application_parameter));
+}
+
+Result INotificationServices::UpdateAlarmSetting(
+ InLargeData<AlarmSetting, BufferAttr_HipcMapAlias> alarm_setting,
+ InBuffer<BufferAttr_HipcMapAlias> application_parameter) {
+ R_RETURN(impl.UpdateAlarmSetting(*alarm_setting, application_parameter));
+}
+
+Result INotificationServices::ListAlarmSettings(
+ Out<s32> out_count, OutArray<AlarmSetting, BufferAttr_HipcMapAlias> out_alarms) {
+ R_RETURN(impl.ListAlarmSettings(out_count.Get(), out_alarms));
+}
+
+Result INotificationServices::LoadApplicationParameter(
+ Out<u32> out_size, OutBuffer<BufferAttr_HipcMapAlias> out_application_parameter,
+ AlarmSettingId alarm_setting_id) {
+ R_RETURN(
+ impl.LoadApplicationParameter(out_size.Get(), out_application_parameter, alarm_setting_id));
+}
+
+Result INotificationServices::DeleteAlarmSetting(AlarmSettingId alarm_setting_id) {
+ R_RETURN(impl.DeleteAlarmSetting(alarm_setting_id));
+}
+
+Result INotificationServices::Initialize(ClientAppletResourceUserId aruid) {
+ R_RETURN(impl.Initialize(*aruid));
+}
+
+Result INotificationServices::OpenNotificationSystemEventAccessor(
+ Out<SharedPointer<INotificationSystemEventAccessor>> out_notification_system_event_accessor) {
+ LOG_WARNING(Service_NOTIF, "(STUBBED) called");
+
+ *out_notification_system_event_accessor =
+ std::make_shared<INotificationSystemEventAccessor>(system);
+ R_SUCCEED();
+}
+
+Result INotificationServices::GetNotificationPresentationSetting(
+ Out<NotificationPresentationSetting> out_notification_presentation_setting,
+ NotificationChannel notification_channel) {
+ LOG_WARNING(Service_NOTIF, "(STUBBED) called");
+
+ *out_notification_presentation_setting = {};
+ R_SUCCEED();
+}
+
} // namespace Service::Glue
diff --git a/src/core/hle/service/glue/notif.h b/src/core/hle/service/glue/notif.h
index b1187f3a3..ef2522fdf 100644
--- a/src/core/hle/service/glue/notif.h
+++ b/src/core/hle/service/glue/notif.h
@@ -7,6 +7,7 @@
#include <vector>
#include "common/uuid.h"
+#include "core/hle/service/cmif_types.h"
#include "core/hle/service/service.h"
namespace Core {
@@ -15,58 +16,117 @@ class System;
namespace Service::Glue {
-class NOTIF_A final : public ServiceFramework<NOTIF_A> {
+// This is nn::notification::AlarmSettingId
+using AlarmSettingId = u16;
+static_assert(sizeof(AlarmSettingId) == 0x2, "AlarmSettingId is an invalid size");
+
+using ApplicationParameter = std::array<u8, 0x400>;
+static_assert(sizeof(ApplicationParameter) == 0x400, "ApplicationParameter is an invalid size");
+
+struct DailyAlarmSetting {
+ s8 hour;
+ s8 minute;
+};
+static_assert(sizeof(DailyAlarmSetting) == 0x2, "DailyAlarmSetting is an invalid size");
+
+struct WeeklyScheduleAlarmSetting {
+ INSERT_PADDING_BYTES_NOINIT(0xA);
+ std::array<DailyAlarmSetting, 0x7> day_of_week;
+};
+static_assert(sizeof(WeeklyScheduleAlarmSetting) == 0x18,
+ "WeeklyScheduleAlarmSetting is an invalid size");
+
+// This is nn::notification::AlarmSetting
+struct AlarmSetting {
+ AlarmSettingId alarm_setting_id;
+ u8 kind;
+ u8 muted;
+ INSERT_PADDING_BYTES_NOINIT(0x4);
+ Common::UUID account_id;
+ u64 application_id;
+ INSERT_PADDING_BYTES_NOINIT(0x8);
+ WeeklyScheduleAlarmSetting schedule;
+};
+static_assert(sizeof(AlarmSetting) == 0x40, "AlarmSetting is an invalid size");
+
+enum class NotificationChannel : u8 {
+ Unknown0 = 0,
+};
+
+struct NotificationPresentationSetting {
+ INSERT_PADDING_BYTES_NOINIT(0x10);
+};
+static_assert(sizeof(NotificationPresentationSetting) == 0x10,
+ "NotificationPresentationSetting is an invalid size");
+
+class NotificationServiceImpl {
public:
- explicit NOTIF_A(Core::System& system_);
- ~NOTIF_A() override;
+ Result RegisterAlarmSetting(AlarmSettingId* out_alarm_setting_id,
+ const AlarmSetting& alarm_setting,
+ std::span<const u8> application_parameter);
+ Result UpdateAlarmSetting(const AlarmSetting& alarm_setting,
+ std::span<const u8> application_parameter);
+ Result ListAlarmSettings(s32* out_count, std::span<AlarmSetting> out_alarms);
+ Result LoadApplicationParameter(u32* out_size, std::span<u8> out_application_parameter,
+ AlarmSettingId alarm_setting_id);
+ Result DeleteAlarmSetting(AlarmSettingId alarm_setting_id);
+ Result Initialize(u64 aruid);
private:
- static constexpr std::size_t max_alarms = 8;
-
- // This is nn::notification::AlarmSettingId
- using AlarmSettingId = u16;
- static_assert(sizeof(AlarmSettingId) == 0x2, "AlarmSettingId is an invalid size");
-
- using ApplicationParameter = std::array<u8, 0x400>;
- static_assert(sizeof(ApplicationParameter) == 0x400, "ApplicationParameter is an invalid size");
-
- struct DailyAlarmSetting {
- s8 hour;
- s8 minute;
- };
- static_assert(sizeof(DailyAlarmSetting) == 0x2, "DailyAlarmSetting is an invalid size");
-
- struct WeeklyScheduleAlarmSetting {
- INSERT_PADDING_BYTES(0xA);
- std::array<DailyAlarmSetting, 0x7> day_of_week;
- };
- static_assert(sizeof(WeeklyScheduleAlarmSetting) == 0x18,
- "WeeklyScheduleAlarmSetting is an invalid size");
-
- // This is nn::notification::AlarmSetting
- struct AlarmSetting {
- AlarmSettingId alarm_setting_id;
- u8 kind;
- u8 muted;
- INSERT_PADDING_BYTES(0x4);
- Common::UUID account_id;
- u64 application_id;
- INSERT_PADDING_BYTES(0x8);
- WeeklyScheduleAlarmSetting schedule;
- };
- static_assert(sizeof(AlarmSetting) == 0x40, "AlarmSetting is an invalid size");
-
- void RegisterAlarmSetting(HLERequestContext& ctx);
- void UpdateAlarmSetting(HLERequestContext& ctx);
- void ListAlarmSettings(HLERequestContext& ctx);
- void LoadApplicationParameter(HLERequestContext& ctx);
- void DeleteAlarmSetting(HLERequestContext& ctx);
- void Initialize(HLERequestContext& ctx);
-
std::vector<AlarmSetting>::iterator GetAlarmFromId(AlarmSettingId alarm_setting_id);
-
std::vector<AlarmSetting> alarms{};
AlarmSettingId last_alarm_setting_id{};
};
+class INotificationServicesForApplication final
+ : public ServiceFramework<INotificationServicesForApplication> {
+public:
+ explicit INotificationServicesForApplication(Core::System& system_);
+ ~INotificationServicesForApplication() override;
+
+private:
+ Result RegisterAlarmSetting(Out<AlarmSettingId> out_alarm_setting_id,
+ InLargeData<AlarmSetting, BufferAttr_HipcMapAlias> alarm_setting,
+ InBuffer<BufferAttr_HipcMapAlias> application_parameter);
+ Result UpdateAlarmSetting(InLargeData<AlarmSetting, BufferAttr_HipcMapAlias> alarm_setting,
+ InBuffer<BufferAttr_HipcMapAlias> application_parameter);
+ Result ListAlarmSettings(Out<s32> out_count,
+ OutArray<AlarmSetting, BufferAttr_HipcMapAlias> out_alarms);
+ Result LoadApplicationParameter(Out<u32> out_size,
+ OutBuffer<BufferAttr_HipcMapAlias> out_application_parameter,
+ AlarmSettingId alarm_setting_id);
+ Result DeleteAlarmSetting(AlarmSettingId alarm_setting_id);
+ Result Initialize(ClientAppletResourceUserId aruid);
+
+ NotificationServiceImpl impl;
+};
+
+class INotificationSystemEventAccessor;
+
+class INotificationServices final : public ServiceFramework<INotificationServices> {
+public:
+ explicit INotificationServices(Core::System& system_);
+ ~INotificationServices() override;
+
+private:
+ Result RegisterAlarmSetting(Out<AlarmSettingId> out_alarm_setting_id,
+ InLargeData<AlarmSetting, BufferAttr_HipcMapAlias> alarm_setting,
+ InBuffer<BufferAttr_HipcMapAlias> application_parameter);
+ Result UpdateAlarmSetting(InLargeData<AlarmSetting, BufferAttr_HipcMapAlias> alarm_setting,
+ InBuffer<BufferAttr_HipcMapAlias> application_parameter);
+ Result ListAlarmSettings(Out<s32> out_count,
+ OutArray<AlarmSetting, BufferAttr_HipcMapAlias> out_alarms);
+ Result LoadApplicationParameter(Out<u32> out_size,
+ OutBuffer<BufferAttr_HipcMapAlias> out_application_parameter,
+ AlarmSettingId alarm_setting_id);
+ Result DeleteAlarmSetting(AlarmSettingId alarm_setting_id);
+ Result Initialize(ClientAppletResourceUserId aruid);
+ Result OpenNotificationSystemEventAccessor(Out<SharedPointer<INotificationSystemEventAccessor>>
+ out_notification_system_event_accessor);
+ Result GetNotificationPresentationSetting(
+ Out<NotificationPresentationSetting> out_notification_presentation_setting,
+ NotificationChannel notification_channel);
+
+ NotificationServiceImpl impl;
+};
} // namespace Service::Glue
diff --git a/src/core/hle/service/glue/time/static.cpp b/src/core/hle/service/glue/time/static.cpp
index f56db76e1..f8c1218f3 100644
--- a/src/core/hle/service/glue/time/static.cpp
+++ b/src/core/hle/service/glue/time/static.cpp
@@ -200,7 +200,7 @@ Result StaticService::GetStandardUserSystemClockAutomaticCorrectionUpdatedTime(
}
Result StaticService::CalculateMonotonicSystemClockBaseTimePoint(
- Out<s64> out_time, Service::PSC::Time::SystemClockContext& context) {
+ Out<s64> out_time, const Service::PSC::Time::SystemClockContext& context) {
SCOPE_EXIT({ LOG_DEBUG(Service_Time, "called. context={} out_time={}", context, *out_time); });
R_RETURN(m_wrapped_service->CalculateMonotonicSystemClockBaseTimePoint(out_time, context));
@@ -216,8 +216,8 @@ Result StaticService::GetClockSnapshot(OutClockSnapshot out_snapshot,
Result StaticService::GetClockSnapshotFromSystemClockContext(
Service::PSC::Time::TimeType type, OutClockSnapshot out_snapshot,
- Service::PSC::Time::SystemClockContext& user_context,
- Service::PSC::Time::SystemClockContext& network_context) {
+ const Service::PSC::Time::SystemClockContext& user_context,
+ const Service::PSC::Time::SystemClockContext& network_context) {
SCOPE_EXIT({
LOG_DEBUG(Service_Time,
"called. type={} out_snapshot={} user_context={} network_context={}", type,
diff --git a/src/core/hle/service/glue/time/static.h b/src/core/hle/service/glue/time/static.h
index d3cc0fdd6..5d3623182 100644
--- a/src/core/hle/service/glue/time/static.h
+++ b/src/core/hle/service/glue/time/static.h
@@ -58,12 +58,12 @@ public:
Result GetStandardUserSystemClockAutomaticCorrectionUpdatedTime(
Out<Service::PSC::Time::SteadyClockTimePoint> out_time_point);
Result CalculateMonotonicSystemClockBaseTimePoint(
- Out<s64> out_time, Service::PSC::Time::SystemClockContext& context);
+ Out<s64> out_time, const Service::PSC::Time::SystemClockContext& context);
Result GetClockSnapshot(OutClockSnapshot out_snapshot, Service::PSC::Time::TimeType type);
Result GetClockSnapshotFromSystemClockContext(
Service::PSC::Time::TimeType type, OutClockSnapshot out_snapshot,
- Service::PSC::Time::SystemClockContext& user_context,
- Service::PSC::Time::SystemClockContext& network_context);
+ const Service::PSC::Time::SystemClockContext& user_context,
+ const Service::PSC::Time::SystemClockContext& network_context);
Result CalculateStandardUserSystemClockDifferenceByUser(Out<s64> out_difference,
InClockSnapshot a, InClockSnapshot b);
Result CalculateSpanBetween(Out<s64> out_time, InClockSnapshot a, InClockSnapshot b);
diff --git a/src/core/hle/service/glue/time/time_zone.cpp b/src/core/hle/service/glue/time/time_zone.cpp
index 98d928697..36f163419 100644
--- a/src/core/hle/service/glue/time/time_zone.cpp
+++ b/src/core/hle/service/glue/time/time_zone.cpp
@@ -62,7 +62,8 @@ Result TimeZoneService::GetDeviceLocationName(
R_RETURN(m_wrapped_service->GetDeviceLocationName(out_location_name));
}
-Result TimeZoneService::SetDeviceLocationName(Service::PSC::Time::LocationName& location_name) {
+Result TimeZoneService::SetDeviceLocationName(
+ const Service::PSC::Time::LocationName& location_name) {
LOG_DEBUG(Service_Time, "called. location_name={}", location_name);
R_UNLESS(m_can_write_timezone_device_location, Service::PSC::Time::ResultPermissionDenied);
@@ -110,7 +111,8 @@ Result TimeZoneService::LoadLocationNameList(
R_RETURN(GetTimeZoneLocationList(*out_count, out_names, out_names.size(), index));
}
-Result TimeZoneService::LoadTimeZoneRule(OutRule out_rule, Service::PSC::Time::LocationName& name) {
+Result TimeZoneService::LoadTimeZoneRule(OutRule out_rule,
+ const Service::PSC::Time::LocationName& name) {
LOG_DEBUG(Service_Time, "called. name={}", name);
std::scoped_lock l{m_mutex};
@@ -139,7 +141,8 @@ Result TimeZoneService::GetDeviceLocationNameAndUpdatedTime(
}
Result TimeZoneService::SetDeviceLocationNameWithTimeZoneRule(
- Service::PSC::Time::LocationName& location_name, InBuffer<BufferAttr_HipcAutoSelect> binary) {
+ const Service::PSC::Time::LocationName& location_name,
+ InBuffer<BufferAttr_HipcAutoSelect> binary) {
LOG_DEBUG(Service_Time, "called. location_name={}", location_name);
R_UNLESS(m_can_write_timezone_device_location, Service::PSC::Time::ResultPermissionDenied);
diff --git a/src/core/hle/service/glue/time/time_zone.h b/src/core/hle/service/glue/time/time_zone.h
index 9c1530966..beb54ddde 100644
--- a/src/core/hle/service/glue/time/time_zone.h
+++ b/src/core/hle/service/glue/time/time_zone.h
@@ -46,18 +46,20 @@ public:
~TimeZoneService() override;
Result GetDeviceLocationName(Out<Service::PSC::Time::LocationName> out_location_name);
- Result SetDeviceLocationName(Service::PSC::Time::LocationName& location_name);
+ Result SetDeviceLocationName(const Service::PSC::Time::LocationName& location_name);
Result GetTotalLocationNameCount(Out<u32> out_count);
Result LoadLocationNameList(
Out<u32> out_count,
OutArray<Service::PSC::Time::LocationName, BufferAttr_HipcMapAlias> out_names, u32 index);
- Result LoadTimeZoneRule(OutRule out_rule, Service::PSC::Time::LocationName& location_name);
+ Result LoadTimeZoneRule(OutRule out_rule,
+ const Service::PSC::Time::LocationName& location_name);
Result GetTimeZoneRuleVersion(Out<Service::PSC::Time::RuleVersion> out_rule_version);
Result GetDeviceLocationNameAndUpdatedTime(
Out<Service::PSC::Time::LocationName> location_name,
Out<Service::PSC::Time::SteadyClockTimePoint> out_time_point);
- Result SetDeviceLocationNameWithTimeZoneRule(Service::PSC::Time::LocationName& location_name,
- InBuffer<BufferAttr_HipcAutoSelect> binary);
+ Result SetDeviceLocationNameWithTimeZoneRule(
+ const Service::PSC::Time::LocationName& location_name,
+ InBuffer<BufferAttr_HipcAutoSelect> binary);
Result ParseTimeZoneBinary(OutRule out_rule, InBuffer<BufferAttr_HipcAutoSelect> binary);
Result GetDeviceLocationNameOperationEventReadableHandle(
OutCopyHandle<Kernel::KReadableEvent> out_event);
diff --git a/src/core/hle/service/glue/time/time_zone_binary.cpp b/src/core/hle/service/glue/time/time_zone_binary.cpp
index cc50b6b7b..18c6abd6b 100644
--- a/src/core/hle/service/glue/time/time_zone_binary.cpp
+++ b/src/core/hle/service/glue/time/time_zone_binary.cpp
@@ -65,6 +65,7 @@ Result MountTimeZoneBinary(Core::System& system) {
// Validate that the romfs is readable, using invalid firmware keys can cause this to get
// set but the files to be garbage. In that case, we want to hit the next path and
// synthesise them instead.
+ g_time_zone_binary_mount_result = ResultSuccess;
Service::PSC::Time::LocationName name{"Etc/GMT"};
if (!IsTimeZoneBinaryValid(name)) {
ResetTimeZoneBinary();
@@ -98,7 +99,7 @@ void GetTimeZoneBinaryVersionPath(std::string& out_path) {
out_path = "/version.txt";
}
-void GetTimeZoneZonePath(std::string& out_path, Service::PSC::Time::LocationName& name) {
+void GetTimeZoneZonePath(std::string& out_path, const Service::PSC::Time::LocationName& name) {
if (g_time_zone_binary_mount_result != ResultSuccess) {
return;
}
@@ -106,7 +107,7 @@ void GetTimeZoneZonePath(std::string& out_path, Service::PSC::Time::LocationName
out_path = fmt::format("/zoneinfo/{}", name.data());
}
-bool IsTimeZoneBinaryValid(Service::PSC::Time::LocationName& name) {
+bool IsTimeZoneBinaryValid(const Service::PSC::Time::LocationName& name) {
std::string path{};
GetTimeZoneZonePath(path, name);
@@ -155,7 +156,7 @@ Result GetTimeZoneVersion(Service::PSC::Time::RuleVersion& out_rule_version) {
}
Result GetTimeZoneRule(std::span<const u8>& out_rule, size_t& out_rule_size,
- Service::PSC::Time::LocationName& name) {
+ const Service::PSC::Time::LocationName& name) {
std::string path{};
GetTimeZoneZonePath(path, name);
diff --git a/src/core/hle/service/glue/time/time_zone_binary.h b/src/core/hle/service/glue/time/time_zone_binary.h
index 461f4577e..9d0a8dfe9 100644
--- a/src/core/hle/service/glue/time/time_zone_binary.h
+++ b/src/core/hle/service/glue/time/time_zone_binary.h
@@ -19,12 +19,12 @@ void ResetTimeZoneBinary();
Result MountTimeZoneBinary(Core::System& system);
void GetTimeZoneBinaryListPath(std::string& out_path);
void GetTimeZoneBinaryVersionPath(std::string& out_path);
-void GetTimeZoneZonePath(std::string& out_path, Service::PSC::Time::LocationName& name);
-bool IsTimeZoneBinaryValid(Service::PSC::Time::LocationName& name);
+void GetTimeZoneZonePath(std::string& out_path, const Service::PSC::Time::LocationName& name);
+bool IsTimeZoneBinaryValid(const Service::PSC::Time::LocationName& name);
u32 GetTimeZoneCount();
Result GetTimeZoneVersion(Service::PSC::Time::RuleVersion& out_rule_version);
Result GetTimeZoneRule(std::span<const u8>& out_rule, size_t& out_rule_size,
- Service::PSC::Time::LocationName& name);
+ const Service::PSC::Time::LocationName& name);
Result GetTimeZoneLocationList(u32& out_count,
std::span<Service::PSC::Time::LocationName> out_names,
size_t max_names, u32 index);
diff --git a/src/core/hle/service/hid/hid.cpp b/src/core/hle/service/hid/hid.cpp
index 5b28be577..b60fb9139 100644
--- a/src/core/hle/service/hid/hid.cpp
+++ b/src/core/hle/service/hid/hid.cpp
@@ -18,9 +18,10 @@ namespace Service::HID {
void LoopProcess(Core::System& system) {
auto server_manager = std::make_unique<ServerManager>(system);
- std::shared_ptr<ResourceManager> resource_manager = std::make_shared<ResourceManager>(system);
std::shared_ptr<HidFirmwareSettings> firmware_settings =
std::make_shared<HidFirmwareSettings>(system);
+ std::shared_ptr<ResourceManager> resource_manager =
+ std::make_shared<ResourceManager>(system, firmware_settings);
// TODO: Remove this hack when am is emulated properly.
resource_manager->Initialize();
@@ -31,7 +32,7 @@ void LoopProcess(Core::System& system) {
server_manager->RegisterNamedService(
"hid", std::make_shared<IHidServer>(system, resource_manager, firmware_settings));
server_manager->RegisterNamedService(
- "hid:dbg", std::make_shared<IHidDebugServer>(system, resource_manager));
+ "hid:dbg", std::make_shared<IHidDebugServer>(system, resource_manager, firmware_settings));
server_manager->RegisterNamedService(
"hid:sys", std::make_shared<IHidSystemServer>(system, resource_manager, firmware_settings));
diff --git a/src/core/hle/service/hid/hid_debug_server.cpp b/src/core/hle/service/hid/hid_debug_server.cpp
index f2a767d37..4e2663672 100644
--- a/src/core/hle/service/hid/hid_debug_server.cpp
+++ b/src/core/hle/service/hid/hid_debug_server.cpp
@@ -1,27 +1,37 @@
// SPDX-FileCopyrightText: Copyright 2023 yuzu Emulator Project
// SPDX-License-Identifier: GPL-3.0-or-later
+#include <algorithm>
+
+#include "core/hle/service/cmif_serialization.h"
#include "core/hle/service/hid/hid_debug_server.h"
#include "core/hle/service/ipc_helpers.h"
+#include "hid_core/hid_types.h"
#include "hid_core/resource_manager.h"
+#include "hid_core/resources/hid_firmware_settings.h"
+
+#include "hid_core/resources/touch_screen/gesture.h"
+#include "hid_core/resources/touch_screen/touch_screen.h"
namespace Service::HID {
-IHidDebugServer::IHidDebugServer(Core::System& system_, std::shared_ptr<ResourceManager> resource)
- : ServiceFramework{system_, "hid:dbg"}, resource_manager{resource} {
+IHidDebugServer::IHidDebugServer(Core::System& system_, std::shared_ptr<ResourceManager> resource,
+ std::shared_ptr<HidFirmwareSettings> settings)
+ : ServiceFramework{system_, "hid:dbg"}, resource_manager{resource}, firmware_settings{
+ settings} {
// clang-format off
static const FunctionInfo functions[] = {
{0, nullptr, "DeactivateDebugPad"},
{1, nullptr, "SetDebugPadAutoPilotState"},
{2, nullptr, "UnsetDebugPadAutoPilotState"},
- {10, nullptr, "DeactivateTouchScreen"},
- {11, nullptr, "SetTouchScreenAutoPilotState"},
- {12, nullptr, "UnsetTouchScreenAutoPilotState"},
- {13, nullptr, "GetTouchScreenConfiguration"},
- {14, nullptr, "ProcessTouchScreenAutoTune"},
- {15, nullptr, "ForceStopTouchScreenManagement"},
- {16, nullptr, "ForceRestartTouchScreenManagement"},
- {17, nullptr, "IsTouchScreenManaged"},
+ {10, C<&IHidDebugServer::DeactivateTouchScreen>, "DeactivateTouchScreen"},
+ {11, C<&IHidDebugServer::SetTouchScreenAutoPilotState>, "SetTouchScreenAutoPilotState"},
+ {12, C<&IHidDebugServer::UnsetTouchScreenAutoPilotState>, "UnsetTouchScreenAutoPilotState"},
+ {13, C<&IHidDebugServer::GetTouchScreenConfiguration>, "GetTouchScreenConfiguration"},
+ {14, C<&IHidDebugServer::ProcessTouchScreenAutoTune>, "ProcessTouchScreenAutoTune"},
+ {15, C<&IHidDebugServer::ForceStopTouchScreenManagement>, "ForceStopTouchScreenManagement"},
+ {16, C<&IHidDebugServer::ForceRestartTouchScreenManagement>, "ForceRestartTouchScreenManagement"},
+ {17, C<&IHidDebugServer::IsTouchScreenManaged>, "IsTouchScreenManaged"},
{20, nullptr, "DeactivateMouse"},
{21, nullptr, "SetMouseAutoPilotState"},
{22, nullptr, "UnsetMouseAutoPilotState"},
@@ -37,7 +47,7 @@ IHidDebugServer::IHidDebugServer(Core::System& system_, std::shared_ptr<Resource
{60, nullptr, "ClearNpadSystemCommonPolicy"},
{61, nullptr, "DeactivateNpad"},
{62, nullptr, "ForceDisconnectNpad"},
- {91, nullptr, "DeactivateGesture"},
+ {91, C<&IHidDebugServer::DeactivateGesture>, "DeactivateGesture"},
{110, nullptr, "DeactivateHomeButton"},
{111, nullptr, "SetHomeButtonAutoPilotState"},
{112, nullptr, "UnsetHomeButtonAutoPilotState"},
@@ -151,6 +161,123 @@ IHidDebugServer::IHidDebugServer(Core::System& system_, std::shared_ptr<Resource
IHidDebugServer::~IHidDebugServer() = default;
+Result IHidDebugServer::DeactivateTouchScreen() {
+ LOG_INFO(Service_HID, "called");
+
+ if (!firmware_settings->IsDeviceManaged()) {
+ R_RETURN(GetResourceManager()->GetTouchScreen()->Deactivate());
+ }
+
+ R_SUCCEED();
+}
+
+Result IHidDebugServer::SetTouchScreenAutoPilotState(
+ InArray<TouchState, BufferAttr_HipcMapAlias> auto_pilot_buffer) {
+ AutoPilotState auto_pilot{};
+
+ auto_pilot.count =
+ static_cast<u64>(std::min(auto_pilot_buffer.size(), auto_pilot.state.size()));
+ memcpy(auto_pilot.state.data(), auto_pilot_buffer.data(),
+ auto_pilot.count * sizeof(TouchState));
+
+ LOG_INFO(Service_HID, "called, auto_pilot_count={}", auto_pilot.count);
+
+ R_RETURN(GetResourceManager()->GetTouchScreen()->SetTouchScreenAutoPilotState(auto_pilot));
+}
+
+Result IHidDebugServer::UnsetTouchScreenAutoPilotState() {
+ LOG_INFO(Service_HID, "called");
+ R_RETURN(GetResourceManager()->GetTouchScreen()->UnsetTouchScreenAutoPilotState());
+}
+
+Result IHidDebugServer::GetTouchScreenConfiguration(
+ Out<Core::HID::TouchScreenConfigurationForNx> out_touchscreen_config,
+ ClientAppletResourceUserId aruid) {
+ LOG_INFO(Service_HID, "called, applet_resource_user_id={}", aruid.pid);
+
+ R_TRY(GetResourceManager()->GetTouchScreen()->GetTouchScreenConfiguration(
+ *out_touchscreen_config, aruid.pid));
+
+ if (out_touchscreen_config->mode != Core::HID::TouchScreenModeForNx::Heat2 &&
+ out_touchscreen_config->mode != Core::HID::TouchScreenModeForNx::Finger) {
+ out_touchscreen_config->mode = Core::HID::TouchScreenModeForNx::UseSystemSetting;
+ }
+
+ R_SUCCEED();
+}
+
+Result IHidDebugServer::ProcessTouchScreenAutoTune() {
+ LOG_INFO(Service_HID, "called");
+ R_RETURN(GetResourceManager()->GetTouchScreen()->ProcessTouchScreenAutoTune());
+}
+
+Result IHidDebugServer::ForceStopTouchScreenManagement() {
+ LOG_INFO(Service_HID, "called");
+
+ if (!firmware_settings->IsDeviceManaged()) {
+ R_SUCCEED();
+ }
+
+ auto touch_screen = GetResourceManager()->GetTouchScreen();
+ auto gesture = GetResourceManager()->GetGesture();
+
+ if (firmware_settings->IsTouchI2cManaged()) {
+ bool is_touch_active{};
+ bool is_gesture_active{};
+ R_TRY(touch_screen->IsActive(is_touch_active));
+ R_TRY(gesture->IsActive(is_gesture_active));
+
+ if (is_touch_active) {
+ R_TRY(touch_screen->Deactivate());
+ }
+ if (is_gesture_active) {
+ R_TRY(gesture->Deactivate());
+ }
+ }
+
+ R_SUCCEED();
+}
+
+Result IHidDebugServer::ForceRestartTouchScreenManagement(u32 basic_gesture_id,
+ ClientAppletResourceUserId aruid) {
+ LOG_INFO(Service_HID, "called, basic_gesture_id={}, applet_resource_user_id={}",
+ basic_gesture_id, aruid.pid);
+
+ auto touch_screen = GetResourceManager()->GetTouchScreen();
+ auto gesture = GetResourceManager()->GetGesture();
+
+ if (firmware_settings->IsDeviceManaged() && firmware_settings->IsTouchI2cManaged()) {
+ R_TRY(gesture->Activate());
+ R_TRY(gesture->Activate(aruid.pid, basic_gesture_id));
+ R_TRY(touch_screen->Activate());
+ R_TRY(touch_screen->Activate(aruid.pid));
+ }
+
+ R_SUCCEED();
+}
+
+Result IHidDebugServer::IsTouchScreenManaged(Out<bool> out_is_managed) {
+ LOG_INFO(Service_HID, "called");
+
+ bool is_touch_active{};
+ bool is_gesture_active{};
+ R_TRY(GetResourceManager()->GetTouchScreen()->IsActive(is_touch_active));
+ R_TRY(GetResourceManager()->GetGesture()->IsActive(is_gesture_active));
+
+ *out_is_managed = is_touch_active || is_gesture_active;
+ R_SUCCEED();
+}
+
+Result IHidDebugServer::DeactivateGesture() {
+ LOG_INFO(Service_HID, "called");
+
+ if (!firmware_settings->IsDeviceManaged()) {
+ R_RETURN(GetResourceManager()->GetGesture()->Deactivate());
+ }
+
+ R_SUCCEED();
+}
+
std::shared_ptr<ResourceManager> IHidDebugServer::GetResourceManager() {
resource_manager->Initialize();
return resource_manager;
diff --git a/src/core/hle/service/hid/hid_debug_server.h b/src/core/hle/service/hid/hid_debug_server.h
index 406db2211..3a483f07e 100644
--- a/src/core/hle/service/hid/hid_debug_server.h
+++ b/src/core/hle/service/hid/hid_debug_server.h
@@ -3,7 +3,9 @@
#pragma once
+#include "core/hle/service/cmif_types.h"
#include "core/hle/service/service.h"
+#include "hid_core/resources/touch_screen/touch_types.h"
namespace Core {
class System;
@@ -11,16 +13,33 @@ class System;
namespace Service::HID {
class ResourceManager;
+class HidFirmwareSettings;
class IHidDebugServer final : public ServiceFramework<IHidDebugServer> {
public:
- explicit IHidDebugServer(Core::System& system_, std::shared_ptr<ResourceManager> resource);
+ explicit IHidDebugServer(Core::System& system_, std::shared_ptr<ResourceManager> resource,
+ std::shared_ptr<HidFirmwareSettings> settings);
~IHidDebugServer() override;
private:
+ Result DeactivateTouchScreen();
+ Result SetTouchScreenAutoPilotState(
+ InArray<TouchState, BufferAttr_HipcMapAlias> auto_pilot_buffer);
+ Result UnsetTouchScreenAutoPilotState();
+ Result GetTouchScreenConfiguration(
+ Out<Core::HID::TouchScreenConfigurationForNx> out_touchscreen_config,
+ ClientAppletResourceUserId aruid);
+ Result ProcessTouchScreenAutoTune();
+ Result ForceStopTouchScreenManagement();
+ Result ForceRestartTouchScreenManagement(u32 basic_gesture_id,
+ ClientAppletResourceUserId aruid);
+ Result IsTouchScreenManaged(Out<bool> out_is_managed);
+ Result DeactivateGesture();
+
std::shared_ptr<ResourceManager> GetResourceManager();
std::shared_ptr<ResourceManager> resource_manager;
+ std::shared_ptr<HidFirmwareSettings> firmware_settings;
};
} // namespace Service::HID
diff --git a/src/core/hle/service/hid/hid_server.cpp b/src/core/hle/service/hid/hid_server.cpp
index 938b93451..3603d8ccf 100644
--- a/src/core/hle/service/hid/hid_server.cpp
+++ b/src/core/hle/service/hid/hid_server.cpp
@@ -990,8 +990,7 @@ void IHidServer::ActivateGesture(HLERequestContext& ctx) {
}
if (result.IsSuccess()) {
- // TODO: Use gesture id here
- result = gesture->Activate(parameters.applet_resource_user_id);
+ result = gesture->Activate(parameters.applet_resource_user_id, parameters.basic_gesture_id);
}
IPC::ResponseBuilder rb{ctx, 2};
@@ -2470,14 +2469,22 @@ void IHidServer::GetNpadCommunicationMode(HLERequestContext& ctx) {
void IHidServer::SetTouchScreenConfiguration(HLERequestContext& ctx) {
IPC::RequestParser rp{ctx};
- const auto touchscreen_mode{rp.PopRaw<Core::HID::TouchScreenConfigurationForNx>()};
+ auto touchscreen_config{rp.PopRaw<Core::HID::TouchScreenConfigurationForNx>()};
const auto applet_resource_user_id{rp.Pop<u64>()};
- LOG_WARNING(Service_HID, "(STUBBED) called, touchscreen_mode={}, applet_resource_user_id={}",
- touchscreen_mode.mode, applet_resource_user_id);
+ LOG_INFO(Service_HID, "called, touchscreen_config={}, applet_resource_user_id={}",
+ touchscreen_config.mode, applet_resource_user_id);
+
+ if (touchscreen_config.mode != Core::HID::TouchScreenModeForNx::Heat2 &&
+ touchscreen_config.mode != Core::HID::TouchScreenModeForNx::Finger) {
+ touchscreen_config.mode = Core::HID::TouchScreenModeForNx::UseSystemSetting;
+ }
+
+ const Result result = GetResourceManager()->GetTouchScreen()->SetTouchScreenConfiguration(
+ touchscreen_config, applet_resource_user_id);
IPC::ResponseBuilder rb{ctx, 2};
- rb.Push(ResultSuccess);
+ rb.Push(result);
}
void IHidServer::IsFirmwareUpdateNeededForNotification(HLERequestContext& ctx) {
@@ -2505,11 +2512,12 @@ void IHidServer::SetTouchScreenResolution(HLERequestContext& ctx) {
const auto height{rp.Pop<u32>()};
const auto applet_resource_user_id{rp.Pop<u64>()};
- GetResourceManager()->GetTouchScreen()->SetTouchscreenDimensions(width, height);
-
LOG_INFO(Service_HID, "called, width={}, height={}, applet_resource_user_id={}", width, height,
applet_resource_user_id);
+ GetResourceManager()->GetTouchScreen()->SetTouchScreenResolution(width, height,
+ applet_resource_user_id);
+
IPC::ResponseBuilder rb{ctx, 2};
rb.Push(ResultSuccess);
}
diff --git a/src/core/hle/service/hid/hid_system_server.cpp b/src/core/hle/service/hid/hid_system_server.cpp
index d1ec42edc..22471e9e2 100644
--- a/src/core/hle/service/hid/hid_system_server.cpp
+++ b/src/core/hle/service/hid/hid_system_server.cpp
@@ -155,9 +155,9 @@ IHidSystemServer::IHidSystemServer(Core::System& system_, std::shared_ptr<Resour
{1133, nullptr, "StartUsbFirmwareUpdate"},
{1134, nullptr, "GetUsbFirmwareUpdateState"},
{1135, &IHidSystemServer::InitializeUsbFirmwareUpdateWithoutMemory, "InitializeUsbFirmwareUpdateWithoutMemory"},
- {1150, nullptr, "SetTouchScreenMagnification"},
- {1151, nullptr, "GetTouchScreenFirmwareVersion"},
- {1152, nullptr, "SetTouchScreenDefaultConfiguration"},
+ {1150, &IHidSystemServer::SetTouchScreenMagnification, "SetTouchScreenMagnification"},
+ {1151, &IHidSystemServer::GetTouchScreenFirmwareVersion, "GetTouchScreenFirmwareVersion"},
+ {1152, &IHidSystemServer::SetTouchScreenDefaultConfiguration, "SetTouchScreenDefaultConfiguration"},
{1153, &IHidSystemServer::GetTouchScreenDefaultConfiguration, "GetTouchScreenDefaultConfiguration"},
{1154, nullptr, "IsFirmwareAvailableForNotification"},
{1155, &IHidSystemServer::SetForceHandheldStyleVibration, "SetForceHandheldStyleVibration"},
@@ -845,12 +845,60 @@ void IHidSystemServer::InitializeUsbFirmwareUpdateWithoutMemory(HLERequestContex
rb.Push(ResultSuccess);
}
+void IHidSystemServer::SetTouchScreenMagnification(HLERequestContext& ctx) {
+ IPC::RequestParser rp{ctx};
+ const auto point1x{rp.Pop<f32>()};
+ const auto point1y{rp.Pop<f32>()};
+ const auto point2x{rp.Pop<f32>()};
+ const auto point2y{rp.Pop<f32>()};
+
+ LOG_INFO(Service_HID, "called, point1=-({},{}), point2=({},{})", point1x, point1y, point2x,
+ point2y);
+
+ const Result result = GetResourceManager()->GetTouchScreen()->SetTouchScreenMagnification(
+ point1x, point1y, point2x, point2y);
+
+ IPC::ResponseBuilder rb{ctx, 2};
+ rb.Push(result);
+}
+
+void IHidSystemServer::GetTouchScreenFirmwareVersion(HLERequestContext& ctx) {
+ LOG_INFO(Service_HID, "called");
+
+ Core::HID::FirmwareVersion firmware{};
+ const auto result = GetResourceManager()->GetTouchScreenFirmwareVersion(firmware);
+
+ IPC::ResponseBuilder rb{ctx, 6};
+ rb.Push(result);
+ rb.PushRaw(firmware);
+}
+
+void IHidSystemServer::SetTouchScreenDefaultConfiguration(HLERequestContext& ctx) {
+ IPC::RequestParser rp{ctx};
+ auto touchscreen_config{rp.PopRaw<Core::HID::TouchScreenConfigurationForNx>()};
+
+ LOG_INFO(Service_HID, "called, touchscreen_config={}", touchscreen_config.mode);
+
+ if (touchscreen_config.mode != Core::HID::TouchScreenModeForNx::Heat2 &&
+ touchscreen_config.mode != Core::HID::TouchScreenModeForNx::Finger) {
+ touchscreen_config.mode = Core::HID::TouchScreenModeForNx::UseSystemSetting;
+ }
+
+ const Result result =
+ GetResourceManager()->GetTouchScreen()->SetTouchScreenDefaultConfiguration(
+ touchscreen_config);
+
+ IPC::ResponseBuilder rb{ctx, 2};
+ rb.Push(result);
+}
+
void IHidSystemServer::GetTouchScreenDefaultConfiguration(HLERequestContext& ctx) {
- LOG_WARNING(Service_HID, "(STUBBED) called");
+ LOG_INFO(Service_HID, "called");
- Core::HID::TouchScreenConfigurationForNx touchscreen_config{
- .mode = Core::HID::TouchScreenModeForNx::Finger,
- };
+ Core::HID::TouchScreenConfigurationForNx touchscreen_config{};
+ const Result result =
+ GetResourceManager()->GetTouchScreen()->GetTouchScreenDefaultConfiguration(
+ touchscreen_config);
if (touchscreen_config.mode != Core::HID::TouchScreenModeForNx::Heat2 &&
touchscreen_config.mode != Core::HID::TouchScreenModeForNx::Finger) {
@@ -858,7 +906,7 @@ void IHidSystemServer::GetTouchScreenDefaultConfiguration(HLERequestContext& ctx
}
IPC::ResponseBuilder rb{ctx, 6};
- rb.Push(ResultSuccess);
+ rb.Push(result);
rb.PushRaw(touchscreen_config);
}
diff --git a/src/core/hle/service/hid/hid_system_server.h b/src/core/hle/service/hid/hid_system_server.h
index 4ab4d3931..738313e08 100644
--- a/src/core/hle/service/hid/hid_system_server.h
+++ b/src/core/hle/service/hid/hid_system_server.h
@@ -71,6 +71,9 @@ private:
void FinalizeUsbFirmwareUpdate(HLERequestContext& ctx);
void CheckUsbFirmwareUpdateRequired(HLERequestContext& ctx);
void InitializeUsbFirmwareUpdateWithoutMemory(HLERequestContext& ctx);
+ void SetTouchScreenMagnification(HLERequestContext& ctx);
+ void GetTouchScreenFirmwareVersion(HLERequestContext& ctx);
+ void SetTouchScreenDefaultConfiguration(HLERequestContext& ctx);
void GetTouchScreenDefaultConfiguration(HLERequestContext& ctx);
void SetForceHandheldStyleVibration(HLERequestContext& ctx);
void IsUsingCustomButtonConfig(HLERequestContext& ctx);
diff --git a/src/core/hle/service/hid/irs.cpp b/src/core/hle/service/hid/irs.cpp
index 18e544f2f..7d7368ff9 100644
--- a/src/core/hle/service/hid/irs.cpp
+++ b/src/core/hle/service/hid/irs.cpp
@@ -9,6 +9,7 @@
#include "core/hle/kernel/k_shared_memory.h"
#include "core/hle/kernel/k_transfer_memory.h"
#include "core/hle/kernel/kernel.h"
+#include "core/hle/service/cmif_serialization.h"
#include "core/hle/service/hid/irs.h"
#include "core/hle/service/ipc_helpers.h"
#include "core/memory.h"
@@ -28,24 +29,24 @@ namespace Service::IRS {
IRS::IRS(Core::System& system_) : ServiceFramework{system_, "irs"} {
// clang-format off
static const FunctionInfo functions[] = {
- {302, &IRS::ActivateIrsensor, "ActivateIrsensor"},
- {303, &IRS::DeactivateIrsensor, "DeactivateIrsensor"},
- {304, &IRS::GetIrsensorSharedMemoryHandle, "GetIrsensorSharedMemoryHandle"},
- {305, &IRS::StopImageProcessor, "StopImageProcessor"},
- {306, &IRS::RunMomentProcessor, "RunMomentProcessor"},
- {307, &IRS::RunClusteringProcessor, "RunClusteringProcessor"},
- {308, &IRS::RunImageTransferProcessor, "RunImageTransferProcessor"},
- {309, &IRS::GetImageTransferProcessorState, "GetImageTransferProcessorState"},
- {310, &IRS::RunTeraPluginProcessor, "RunTeraPluginProcessor"},
- {311, &IRS::GetNpadIrCameraHandle, "GetNpadIrCameraHandle"},
- {312, &IRS::RunPointingProcessor, "RunPointingProcessor"},
- {313, &IRS::SuspendImageProcessor, "SuspendImageProcessor"},
- {314, &IRS::CheckFirmwareVersion, "CheckFirmwareVersion"},
- {315, &IRS::SetFunctionLevel, "SetFunctionLevel"},
- {316, &IRS::RunImageTransferExProcessor, "RunImageTransferExProcessor"},
- {317, &IRS::RunIrLedProcessor, "RunIrLedProcessor"},
- {318, &IRS::StopImageProcessorAsync, "StopImageProcessorAsync"},
- {319, &IRS::ActivateIrsensorWithFunctionLevel, "ActivateIrsensorWithFunctionLevel"},
+ {302, C<&IRS::ActivateIrsensor>, "ActivateIrsensor"},
+ {303, C<&IRS::DeactivateIrsensor>, "DeactivateIrsensor"},
+ {304, C<&IRS::GetIrsensorSharedMemoryHandle>, "GetIrsensorSharedMemoryHandle"},
+ {305, C<&IRS::StopImageProcessor>, "StopImageProcessor"},
+ {306, C<&IRS::RunMomentProcessor>, "RunMomentProcessor"},
+ {307, C<&IRS::RunClusteringProcessor>, "RunClusteringProcessor"},
+ {308, C<&IRS::RunImageTransferProcessor>, "RunImageTransferProcessor"},
+ {309, C<&IRS::GetImageTransferProcessorState>, "GetImageTransferProcessorState"},
+ {310, C<&IRS::RunTeraPluginProcessor>, "RunTeraPluginProcessor"},
+ {311, C<&IRS::GetNpadIrCameraHandle>, "GetNpadIrCameraHandle"},
+ {312, C<&IRS::RunPointingProcessor>, "RunPointingProcessor"},
+ {313, C<&IRS::SuspendImageProcessor>, "SuspendImageProcessor"},
+ {314, C<&IRS::CheckFirmwareVersion>, "CheckFirmwareVersion"},
+ {315, C<&IRS::SetFunctionLevel>, "SetFunctionLevel"},
+ {316, C<&IRS::RunImageTransferExProcessor>, "RunImageTransferExProcessor"},
+ {317, C<&IRS::RunIrLedProcessor>, "RunIrLedProcessor"},
+ {318, C<&IRS::StopImageProcessorAsync>, "StopImageProcessorAsync"},
+ {319, C<&IRS::ActivateIrsensorWithFunctionLevel>, "ActivateIrsensorWithFunctionLevel"},
};
// clang-format on
@@ -57,489 +58,292 @@ IRS::IRS(Core::System& system_) : ServiceFramework{system_, "irs"} {
}
IRS::~IRS() = default;
-void IRS::ActivateIrsensor(HLERequestContext& ctx) {
- IPC::RequestParser rp{ctx};
- const auto applet_resource_user_id{rp.Pop<u64>()};
-
- LOG_WARNING(Service_IRS, "(STUBBED) called, applet_resource_user_id={}",
- applet_resource_user_id);
-
- IPC::ResponseBuilder rb{ctx, 2};
- rb.Push(ResultSuccess);
+Result IRS::ActivateIrsensor(ClientAppletResourceUserId aruid) {
+ LOG_WARNING(Service_IRS, "(STUBBED) called, applet_resource_user_id={}", aruid.pid);
+ R_SUCCEED();
}
-void IRS::DeactivateIrsensor(HLERequestContext& ctx) {
- IPC::RequestParser rp{ctx};
- const auto applet_resource_user_id{rp.Pop<u64>()};
-
- LOG_WARNING(Service_IRS, "(STUBBED) called, applet_resource_user_id={}",
- applet_resource_user_id);
-
- IPC::ResponseBuilder rb{ctx, 2};
- rb.Push(ResultSuccess);
+Result IRS::DeactivateIrsensor(ClientAppletResourceUserId aruid) {
+ LOG_WARNING(Service_IRS, "(STUBBED) called, applet_resource_user_id={}", aruid.pid);
+ R_SUCCEED();
}
-void IRS::GetIrsensorSharedMemoryHandle(HLERequestContext& ctx) {
- IPC::RequestParser rp{ctx};
- const auto applet_resource_user_id{rp.Pop<u64>()};
-
- LOG_DEBUG(Service_IRS, "called, applet_resource_user_id={}", applet_resource_user_id);
+Result IRS::GetIrsensorSharedMemoryHandle(OutCopyHandle<Kernel::KSharedMemory> out_shared_memory,
+ ClientAppletResourceUserId aruid) {
+ LOG_DEBUG(Service_IRS, "called, applet_resource_user_id={}", aruid.pid);
- IPC::ResponseBuilder rb{ctx, 2, 1};
- rb.Push(ResultSuccess);
- rb.PushCopyObjects(&system.Kernel().GetIrsSharedMem());
+ *out_shared_memory = &system.Kernel().GetIrsSharedMem();
+ R_SUCCEED();
}
-void IRS::StopImageProcessor(HLERequestContext& ctx) {
- IPC::RequestParser rp{ctx};
- struct Parameters {
- Core::IrSensor::IrCameraHandle camera_handle;
- INSERT_PADDING_WORDS_NOINIT(1);
- u64 applet_resource_user_id;
- };
- static_assert(sizeof(Parameters) == 0x10, "Parameters has incorrect size.");
-
- const auto parameters{rp.PopRaw<Parameters>()};
-
+Result IRS::StopImageProcessor(Core::IrSensor::IrCameraHandle camera_handle,
+ ClientAppletResourceUserId aruid) {
LOG_WARNING(Service_IRS,
"(STUBBED) called, npad_type={}, npad_id={}, applet_resource_user_id={}",
- parameters.camera_handle.npad_type, parameters.camera_handle.npad_id,
- parameters.applet_resource_user_id);
-
- auto result = IsIrCameraHandleValid(parameters.camera_handle);
- if (result.IsSuccess()) {
- // TODO: Stop Image processor
- npad_device->SetPollingMode(Core::HID::EmulatedDeviceIndex::RightIndex,
- Common::Input::PollingMode::Active);
- result = ResultSuccess;
- }
+ camera_handle.npad_type, camera_handle.npad_id, aruid.pid);
- IPC::ResponseBuilder rb{ctx, 2};
- rb.Push(result);
-}
-
-void IRS::RunMomentProcessor(HLERequestContext& ctx) {
- IPC::RequestParser rp{ctx};
- struct Parameters {
- Core::IrSensor::IrCameraHandle camera_handle;
- INSERT_PADDING_WORDS_NOINIT(1);
- u64 applet_resource_user_id;
- Core::IrSensor::PackedMomentProcessorConfig processor_config;
- };
- static_assert(sizeof(Parameters) == 0x30, "Parameters has incorrect size.");
+ R_TRY(IsIrCameraHandleValid(camera_handle));
- const auto parameters{rp.PopRaw<Parameters>()};
+ // TODO: Stop Image processor
+ npad_device->SetPollingMode(Core::HID::EmulatedDeviceIndex::RightIndex,
+ Common::Input::PollingMode::Active);
+ R_SUCCEED();
+}
+Result IRS::RunMomentProcessor(
+ Core::IrSensor::IrCameraHandle camera_handle, ClientAppletResourceUserId aruid,
+ const Core::IrSensor::PackedMomentProcessorConfig& processor_config) {
LOG_WARNING(Service_IRS,
"(STUBBED) called, npad_type={}, npad_id={}, applet_resource_user_id={}",
- parameters.camera_handle.npad_type, parameters.camera_handle.npad_id,
- parameters.applet_resource_user_id);
-
- const auto result = IsIrCameraHandleValid(parameters.camera_handle);
-
- if (result.IsSuccess()) {
- auto& device = GetIrCameraSharedMemoryDeviceEntry(parameters.camera_handle);
- MakeProcessorWithCoreContext<MomentProcessor>(parameters.camera_handle, device);
- auto& image_transfer_processor = GetProcessor<MomentProcessor>(parameters.camera_handle);
- image_transfer_processor.SetConfig(parameters.processor_config);
- npad_device->SetPollingMode(Core::HID::EmulatedDeviceIndex::RightIndex,
- Common::Input::PollingMode::IR);
- }
+ camera_handle.npad_type, camera_handle.npad_id, aruid.pid);
- IPC::ResponseBuilder rb{ctx, 2};
- rb.Push(result);
-}
+ R_TRY(IsIrCameraHandleValid(camera_handle));
-void IRS::RunClusteringProcessor(HLERequestContext& ctx) {
- IPC::RequestParser rp{ctx};
- struct Parameters {
- Core::IrSensor::IrCameraHandle camera_handle;
- INSERT_PADDING_WORDS_NOINIT(1);
- u64 applet_resource_user_id;
- Core::IrSensor::PackedClusteringProcessorConfig processor_config;
- };
- static_assert(sizeof(Parameters) == 0x38, "Parameters has incorrect size.");
+ auto& device = GetIrCameraSharedMemoryDeviceEntry(camera_handle);
+ MakeProcessorWithCoreContext<MomentProcessor>(camera_handle, device);
+ auto& image_transfer_processor = GetProcessor<MomentProcessor>(camera_handle);
+ image_transfer_processor.SetConfig(processor_config);
+ npad_device->SetPollingMode(Core::HID::EmulatedDeviceIndex::RightIndex,
+ Common::Input::PollingMode::IR);
- const auto parameters{rp.PopRaw<Parameters>()};
+ R_SUCCEED();
+}
+Result IRS::RunClusteringProcessor(
+ Core::IrSensor::IrCameraHandle camera_handle, ClientAppletResourceUserId aruid,
+ const Core::IrSensor::PackedClusteringProcessorConfig& processor_config) {
LOG_WARNING(Service_IRS,
"(STUBBED) called, npad_type={}, npad_id={}, applet_resource_user_id={}",
- parameters.camera_handle.npad_type, parameters.camera_handle.npad_id,
- parameters.applet_resource_user_id);
-
- auto result = IsIrCameraHandleValid(parameters.camera_handle);
-
- if (result.IsSuccess()) {
- auto& device = GetIrCameraSharedMemoryDeviceEntry(parameters.camera_handle);
- MakeProcessorWithCoreContext<ClusteringProcessor>(parameters.camera_handle, device);
- auto& image_transfer_processor =
- GetProcessor<ClusteringProcessor>(parameters.camera_handle);
- image_transfer_processor.SetConfig(parameters.processor_config);
- npad_device->SetPollingMode(Core::HID::EmulatedDeviceIndex::RightIndex,
- Common::Input::PollingMode::IR);
- }
+ camera_handle.npad_type, camera_handle.npad_id, aruid.pid);
- IPC::ResponseBuilder rb{ctx, 2};
- rb.Push(result);
-}
+ R_TRY(IsIrCameraHandleValid(camera_handle));
-void IRS::RunImageTransferProcessor(HLERequestContext& ctx) {
- IPC::RequestParser rp{ctx};
- struct Parameters {
- Core::IrSensor::IrCameraHandle camera_handle;
- INSERT_PADDING_WORDS_NOINIT(1);
- u64 applet_resource_user_id;
- Core::IrSensor::PackedImageTransferProcessorConfig processor_config;
- u32 transfer_memory_size;
- };
- static_assert(sizeof(Parameters) == 0x30, "Parameters has incorrect size.");
+ auto& device = GetIrCameraSharedMemoryDeviceEntry(camera_handle);
+ MakeProcessorWithCoreContext<ClusteringProcessor>(camera_handle, device);
+ auto& image_transfer_processor = GetProcessor<ClusteringProcessor>(camera_handle);
+ image_transfer_processor.SetConfig(processor_config);
+ npad_device->SetPollingMode(Core::HID::EmulatedDeviceIndex::RightIndex,
+ Common::Input::PollingMode::IR);
- const auto parameters{rp.PopRaw<Parameters>()};
- const auto t_mem_handle{ctx.GetCopyHandle(0)};
+ R_SUCCEED();
+}
- auto t_mem = ctx.GetObjectFromHandle<Kernel::KTransferMemory>(t_mem_handle);
+Result IRS::RunImageTransferProcessor(
+ Core::IrSensor::IrCameraHandle camera_handle, ClientAppletResourceUserId aruid,
+ const Core::IrSensor::PackedImageTransferProcessorConfig& processor_config,
+ u64 transfer_memory_size, InCopyHandle<Kernel::KTransferMemory> t_mem) {
- if (t_mem.IsNull()) {
- LOG_ERROR(Service_IRS, "t_mem is a nullptr for handle=0x{:08X}", t_mem_handle);
- IPC::ResponseBuilder rb{ctx, 2};
- rb.Push(ResultUnknown);
- return;
- }
-
- ASSERT_MSG(t_mem->GetSize() == parameters.transfer_memory_size, "t_mem has incorrect size");
+ ASSERT_MSG(t_mem->GetSize() == transfer_memory_size, "t_mem has incorrect size");
LOG_INFO(Service_IRS,
"called, npad_type={}, npad_id={}, transfer_memory_size={}, transfer_memory_size={}, "
"applet_resource_user_id={}",
- parameters.camera_handle.npad_type, parameters.camera_handle.npad_id,
- parameters.transfer_memory_size, t_mem->GetSize(), parameters.applet_resource_user_id);
-
- const auto result = IsIrCameraHandleValid(parameters.camera_handle);
-
- if (result.IsSuccess()) {
- auto& device = GetIrCameraSharedMemoryDeviceEntry(parameters.camera_handle);
- MakeProcessorWithCoreContext<ImageTransferProcessor>(parameters.camera_handle, device);
- auto& image_transfer_processor =
- GetProcessor<ImageTransferProcessor>(parameters.camera_handle);
- image_transfer_processor.SetConfig(parameters.processor_config);
- image_transfer_processor.SetTransferMemoryAddress(t_mem->GetSourceAddress());
- npad_device->SetPollingMode(Core::HID::EmulatedDeviceIndex::RightIndex,
- Common::Input::PollingMode::IR);
- }
+ camera_handle.npad_type, camera_handle.npad_id, transfer_memory_size, t_mem->GetSize(),
+ aruid.pid);
- IPC::ResponseBuilder rb{ctx, 2};
- rb.Push(result);
-}
+ R_TRY(IsIrCameraHandleValid(camera_handle));
-void IRS::GetImageTransferProcessorState(HLERequestContext& ctx) {
- IPC::RequestParser rp{ctx};
- struct Parameters {
- Core::IrSensor::IrCameraHandle camera_handle;
- INSERT_PADDING_WORDS_NOINIT(1);
- u64 applet_resource_user_id;
- };
- static_assert(sizeof(Parameters) == 0x10, "Parameters has incorrect size.");
+ auto& device = GetIrCameraSharedMemoryDeviceEntry(camera_handle);
+ MakeProcessorWithCoreContext<ImageTransferProcessor>(camera_handle, device);
+ auto& image_transfer_processor = GetProcessor<ImageTransferProcessor>(camera_handle);
+ image_transfer_processor.SetConfig(processor_config);
+ image_transfer_processor.SetTransferMemoryAddress(t_mem->GetSourceAddress());
+ npad_device->SetPollingMode(Core::HID::EmulatedDeviceIndex::RightIndex,
+ Common::Input::PollingMode::IR);
- const auto parameters{rp.PopRaw<Parameters>()};
+ R_SUCCEED();
+}
+Result IRS::GetImageTransferProcessorState(
+ Out<Core::IrSensor::ImageTransferProcessorState> out_state,
+ Core::IrSensor::IrCameraHandle camera_handle, ClientAppletResourceUserId aruid,
+ OutBuffer<BufferAttr_HipcMapAlias> out_buffer_data) {
LOG_DEBUG(Service_IRS, "(STUBBED) called, npad_type={}, npad_id={}, applet_resource_user_id={}",
- parameters.camera_handle.npad_type, parameters.camera_handle.npad_id,
- parameters.applet_resource_user_id);
-
- const auto result = IsIrCameraHandleValid(parameters.camera_handle);
- if (result.IsError()) {
- IPC::ResponseBuilder rb{ctx, 2};
- rb.Push(result);
- return;
- }
+ camera_handle.npad_type, camera_handle.npad_id, aruid.pid);
- const auto& device = GetIrCameraSharedMemoryDeviceEntry(parameters.camera_handle);
+ R_TRY(IsIrCameraHandleValid(camera_handle));
- if (device.mode != Core::IrSensor::IrSensorMode::ImageTransferProcessor) {
- IPC::ResponseBuilder rb{ctx, 2};
- rb.Push(InvalidProcessorState);
- return;
- }
+ const auto& device = GetIrCameraSharedMemoryDeviceEntry(camera_handle);
+
+ R_TRY(IsIrCameraHandleValid(camera_handle));
+ R_UNLESS(device.mode == Core::IrSensor::IrSensorMode::ImageTransferProcessor,
+ InvalidProcessorState);
- std::vector<u8> data{};
- const auto& image_transfer_processor =
- GetProcessor<ImageTransferProcessor>(parameters.camera_handle);
- const auto& state = image_transfer_processor.GetState(data);
+ *out_state = GetProcessor<ImageTransferProcessor>(camera_handle).GetState(out_buffer_data);
- ctx.WriteBuffer(data);
- IPC::ResponseBuilder rb{ctx, 6};
- rb.Push(ResultSuccess);
- rb.PushRaw(state);
+ R_SUCCEED();
}
-void IRS::RunTeraPluginProcessor(HLERequestContext& ctx) {
- IPC::RequestParser rp{ctx};
- struct Parameters {
- Core::IrSensor::IrCameraHandle camera_handle;
- Core::IrSensor::PackedTeraPluginProcessorConfig processor_config;
- INSERT_PADDING_WORDS_NOINIT(1);
- u64 applet_resource_user_id;
- };
- static_assert(sizeof(Parameters) == 0x18, "Parameters has incorrect size.");
+Result IRS::RunTeraPluginProcessor(Core::IrSensor::IrCameraHandle camera_handle,
+ Core::IrSensor::PackedTeraPluginProcessorConfig processor_config,
+ ClientAppletResourceUserId aruid) {
+ LOG_WARNING(Service_IRS,
+ "(STUBBED) called, npad_type={}, npad_id={}, mode={}, mcu_version={}.{}, "
+ "applet_resource_user_id={}",
+ camera_handle.npad_type, camera_handle.npad_id, processor_config.mode,
+ processor_config.required_mcu_version.major,
+ processor_config.required_mcu_version.minor, aruid.pid);
- const auto parameters{rp.PopRaw<Parameters>()};
+ R_TRY(IsIrCameraHandleValid(camera_handle));
- LOG_WARNING(
- Service_IRS,
- "(STUBBED) called, npad_type={}, npad_id={}, mode={}, mcu_version={}.{}, "
- "applet_resource_user_id={}",
- parameters.camera_handle.npad_type, parameters.camera_handle.npad_id,
- parameters.processor_config.mode, parameters.processor_config.required_mcu_version.major,
- parameters.processor_config.required_mcu_version.minor, parameters.applet_resource_user_id);
-
- const auto result = IsIrCameraHandleValid(parameters.camera_handle);
-
- if (result.IsSuccess()) {
- auto& device = GetIrCameraSharedMemoryDeviceEntry(parameters.camera_handle);
- MakeProcessor<TeraPluginProcessor>(parameters.camera_handle, device);
- auto& image_transfer_processor =
- GetProcessor<TeraPluginProcessor>(parameters.camera_handle);
- image_transfer_processor.SetConfig(parameters.processor_config);
- npad_device->SetPollingMode(Core::HID::EmulatedDeviceIndex::RightIndex,
- Common::Input::PollingMode::IR);
- }
+ auto& device = GetIrCameraSharedMemoryDeviceEntry(camera_handle);
+ MakeProcessor<TeraPluginProcessor>(camera_handle, device);
+ auto& image_transfer_processor = GetProcessor<TeraPluginProcessor>(camera_handle);
+ image_transfer_processor.SetConfig(processor_config);
+ npad_device->SetPollingMode(Core::HID::EmulatedDeviceIndex::RightIndex,
+ Common::Input::PollingMode::IR);
- IPC::ResponseBuilder rb{ctx, 2};
- rb.Push(result);
+ R_SUCCEED();
}
-void IRS::GetNpadIrCameraHandle(HLERequestContext& ctx) {
- IPC::RequestParser rp{ctx};
- const auto npad_id{rp.PopEnum<Core::HID::NpadIdType>()};
-
- if (npad_id > Core::HID::NpadIdType::Player8 && npad_id != Core::HID::NpadIdType::Invalid &&
- npad_id != Core::HID::NpadIdType::Handheld) {
- IPC::ResponseBuilder rb{ctx, 2};
- rb.Push(Service::HID::ResultInvalidNpadId);
- return;
- }
+Result IRS::GetNpadIrCameraHandle(Out<Core::IrSensor::IrCameraHandle> out_camera_handle,
+ Core::HID::NpadIdType npad_id) {
+ R_UNLESS(HID::IsNpadIdValid(npad_id), HID::ResultInvalidNpadId);
- Core::IrSensor::IrCameraHandle camera_handle{
+ *out_camera_handle = {
.npad_id = static_cast<u8>(HID::NpadIdTypeToIndex(npad_id)),
.npad_type = Core::HID::NpadStyleIndex::None,
};
LOG_INFO(Service_IRS, "called, npad_id={}, camera_npad_id={}, camera_npad_type={}", npad_id,
- camera_handle.npad_id, camera_handle.npad_type);
+ out_camera_handle->npad_id, out_camera_handle->npad_type);
- IPC::ResponseBuilder rb{ctx, 3};
- rb.Push(ResultSuccess);
- rb.PushRaw(camera_handle);
+ R_SUCCEED();
}
-void IRS::RunPointingProcessor(HLERequestContext& ctx) {
- IPC::RequestParser rp{ctx};
- const auto camera_handle{rp.PopRaw<Core::IrSensor::IrCameraHandle>()};
- const auto processor_config{rp.PopRaw<Core::IrSensor::PackedPointingProcessorConfig>()};
- const auto applet_resource_user_id{rp.Pop<u64>()};
-
+Result IRS::RunPointingProcessor(
+ Core::IrSensor::IrCameraHandle camera_handle,
+ const Core::IrSensor::PackedPointingProcessorConfig& processor_config,
+ ClientAppletResourceUserId aruid) {
LOG_WARNING(
Service_IRS,
"(STUBBED) called, npad_type={}, npad_id={}, mcu_version={}.{}, applet_resource_user_id={}",
camera_handle.npad_type, camera_handle.npad_id, processor_config.required_mcu_version.major,
- processor_config.required_mcu_version.minor, applet_resource_user_id);
+ processor_config.required_mcu_version.minor, aruid.pid);
- auto result = IsIrCameraHandleValid(camera_handle);
+ R_TRY(IsIrCameraHandleValid(camera_handle));
- if (result.IsSuccess()) {
- auto& device = GetIrCameraSharedMemoryDeviceEntry(camera_handle);
- MakeProcessor<PointingProcessor>(camera_handle, device);
- auto& image_transfer_processor = GetProcessor<PointingProcessor>(camera_handle);
- image_transfer_processor.SetConfig(processor_config);
- npad_device->SetPollingMode(Core::HID::EmulatedDeviceIndex::RightIndex,
- Common::Input::PollingMode::IR);
- }
+ auto& device = GetIrCameraSharedMemoryDeviceEntry(camera_handle);
+ MakeProcessor<PointingProcessor>(camera_handle, device);
+ auto& image_transfer_processor = GetProcessor<PointingProcessor>(camera_handle);
+ image_transfer_processor.SetConfig(processor_config);
+ npad_device->SetPollingMode(Core::HID::EmulatedDeviceIndex::RightIndex,
+ Common::Input::PollingMode::IR);
- IPC::ResponseBuilder rb{ctx, 2};
- rb.Push(result);
+ R_SUCCEED();
}
-void IRS::SuspendImageProcessor(HLERequestContext& ctx) {
- IPC::RequestParser rp{ctx};
- struct Parameters {
- Core::IrSensor::IrCameraHandle camera_handle;
- INSERT_PADDING_WORDS_NOINIT(1);
- u64 applet_resource_user_id;
- };
- static_assert(sizeof(Parameters) == 0x10, "Parameters has incorrect size.");
-
- const auto parameters{rp.PopRaw<Parameters>()};
-
+Result IRS::SuspendImageProcessor(Core::IrSensor::IrCameraHandle camera_handle,
+ ClientAppletResourceUserId aruid) {
LOG_WARNING(Service_IRS,
"(STUBBED) called, npad_type={}, npad_id={}, applet_resource_user_id={}",
- parameters.camera_handle.npad_type, parameters.camera_handle.npad_id,
- parameters.applet_resource_user_id);
+ camera_handle.npad_type, camera_handle.npad_id, aruid.pid);
- auto result = IsIrCameraHandleValid(parameters.camera_handle);
- if (result.IsSuccess()) {
- // TODO: Suspend image processor
- result = ResultSuccess;
- }
+ R_TRY(IsIrCameraHandleValid(camera_handle));
- IPC::ResponseBuilder rb{ctx, 2};
- rb.Push(result);
-}
+ // TODO: Suspend image processor
-void IRS::CheckFirmwareVersion(HLERequestContext& ctx) {
- IPC::RequestParser rp{ctx};
- const auto camera_handle{rp.PopRaw<Core::IrSensor::IrCameraHandle>()};
- const auto mcu_version{rp.PopRaw<Core::IrSensor::PackedMcuVersion>()};
- const auto applet_resource_user_id{rp.Pop<u64>()};
+ R_SUCCEED();
+}
+Result IRS::CheckFirmwareVersion(Core::IrSensor::IrCameraHandle camera_handle,
+ Core::IrSensor::PackedMcuVersion mcu_version,
+ ClientAppletResourceUserId aruid) {
LOG_WARNING(
Service_IRS,
"(STUBBED) called, npad_type={}, npad_id={}, applet_resource_user_id={}, mcu_version={}.{}",
- camera_handle.npad_type, camera_handle.npad_id, applet_resource_user_id, mcu_version.major,
+ camera_handle.npad_type, camera_handle.npad_id, aruid.pid, mcu_version.major,
mcu_version.minor);
- auto result = IsIrCameraHandleValid(camera_handle);
- if (result.IsSuccess()) {
- // TODO: Check firmware version
- result = ResultSuccess;
- }
+ R_TRY(IsIrCameraHandleValid(camera_handle));
- IPC::ResponseBuilder rb{ctx, 2};
- rb.Push(result);
-}
+ // TODO: Check firmware version
-void IRS::SetFunctionLevel(HLERequestContext& ctx) {
- IPC::RequestParser rp{ctx};
- const auto camera_handle{rp.PopRaw<Core::IrSensor::IrCameraHandle>()};
- const auto function_level{rp.PopRaw<Core::IrSensor::PackedFunctionLevel>()};
- const auto applet_resource_user_id{rp.Pop<u64>()};
+ R_SUCCEED();
+}
+Result IRS::SetFunctionLevel(Core::IrSensor::IrCameraHandle camera_handle,
+ Core::IrSensor::PackedFunctionLevel function_level,
+ ClientAppletResourceUserId aruid) {
LOG_WARNING(
Service_IRS,
"(STUBBED) called, npad_type={}, npad_id={}, function_level={}, applet_resource_user_id={}",
- camera_handle.npad_type, camera_handle.npad_id, function_level.function_level,
- applet_resource_user_id);
+ camera_handle.npad_type, camera_handle.npad_id, function_level.function_level, aruid.pid);
- auto result = IsIrCameraHandleValid(camera_handle);
- if (result.IsSuccess()) {
- // TODO: Set Function level
- result = ResultSuccess;
- }
+ R_TRY(IsIrCameraHandleValid(camera_handle));
- IPC::ResponseBuilder rb{ctx, 2};
- rb.Push(result);
-}
+ // TODO: Set Function level
-void IRS::RunImageTransferExProcessor(HLERequestContext& ctx) {
- IPC::RequestParser rp{ctx};
- struct Parameters {
- Core::IrSensor::IrCameraHandle camera_handle;
- INSERT_PADDING_WORDS_NOINIT(1);
- u64 applet_resource_user_id;
- Core::IrSensor::PackedImageTransferProcessorExConfig processor_config;
- u64 transfer_memory_size;
- };
- static_assert(sizeof(Parameters) == 0x38, "Parameters has incorrect size.");
+ R_SUCCEED();
+}
- const auto parameters{rp.PopRaw<Parameters>()};
- const auto t_mem_handle{ctx.GetCopyHandle(0)};
+Result IRS::RunImageTransferExProcessor(
+ Core::IrSensor::IrCameraHandle camera_handle, ClientAppletResourceUserId aruid,
+ const Core::IrSensor::PackedImageTransferProcessorExConfig& processor_config,
+ u64 transfer_memory_size, InCopyHandle<Kernel::KTransferMemory> t_mem) {
- auto t_mem = ctx.GetObjectFromHandle<Kernel::KTransferMemory>(t_mem_handle);
+ ASSERT_MSG(t_mem->GetSize() == transfer_memory_size, "t_mem has incorrect size");
LOG_INFO(Service_IRS,
"called, npad_type={}, npad_id={}, transfer_memory_size={}, "
"applet_resource_user_id={}",
- parameters.camera_handle.npad_type, parameters.camera_handle.npad_id,
- parameters.transfer_memory_size, parameters.applet_resource_user_id);
-
- auto result = IsIrCameraHandleValid(parameters.camera_handle);
-
- if (result.IsSuccess()) {
- auto& device = GetIrCameraSharedMemoryDeviceEntry(parameters.camera_handle);
- MakeProcessorWithCoreContext<ImageTransferProcessor>(parameters.camera_handle, device);
- auto& image_transfer_processor =
- GetProcessor<ImageTransferProcessor>(parameters.camera_handle);
- image_transfer_processor.SetConfig(parameters.processor_config);
- image_transfer_processor.SetTransferMemoryAddress(t_mem->GetSourceAddress());
- npad_device->SetPollingMode(Core::HID::EmulatedDeviceIndex::RightIndex,
- Common::Input::PollingMode::IR);
- }
+ camera_handle.npad_type, camera_handle.npad_id, transfer_memory_size, aruid.pid);
- IPC::ResponseBuilder rb{ctx, 2};
- rb.Push(result);
-}
+ R_TRY(IsIrCameraHandleValid(camera_handle));
+
+ auto& device = GetIrCameraSharedMemoryDeviceEntry(camera_handle);
+ MakeProcessorWithCoreContext<ImageTransferProcessor>(camera_handle, device);
+ auto& image_transfer_processor = GetProcessor<ImageTransferProcessor>(camera_handle);
+ image_transfer_processor.SetConfig(processor_config);
+ image_transfer_processor.SetTransferMemoryAddress(t_mem->GetSourceAddress());
+ npad_device->SetPollingMode(Core::HID::EmulatedDeviceIndex::RightIndex,
+ Common::Input::PollingMode::IR);
-void IRS::RunIrLedProcessor(HLERequestContext& ctx) {
- IPC::RequestParser rp{ctx};
- const auto camera_handle{rp.PopRaw<Core::IrSensor::IrCameraHandle>()};
- const auto processor_config{rp.PopRaw<Core::IrSensor::PackedIrLedProcessorConfig>()};
- const auto applet_resource_user_id{rp.Pop<u64>()};
+ R_SUCCEED();
+}
+Result IRS::RunIrLedProcessor(Core::IrSensor::IrCameraHandle camera_handle,
+ Core::IrSensor::PackedIrLedProcessorConfig processor_config,
+ ClientAppletResourceUserId aruid) {
LOG_WARNING(Service_IRS,
"(STUBBED) called, npad_type={}, npad_id={}, light_target={}, mcu_version={}.{} "
"applet_resource_user_id={}",
camera_handle.npad_type, camera_handle.npad_id, processor_config.light_target,
processor_config.required_mcu_version.major,
- processor_config.required_mcu_version.minor, applet_resource_user_id);
+ processor_config.required_mcu_version.minor, aruid.pid);
- auto result = IsIrCameraHandleValid(camera_handle);
+ R_TRY(IsIrCameraHandleValid(camera_handle));
- if (result.IsSuccess()) {
- auto& device = GetIrCameraSharedMemoryDeviceEntry(camera_handle);
- MakeProcessor<IrLedProcessor>(camera_handle, device);
- auto& image_transfer_processor = GetProcessor<IrLedProcessor>(camera_handle);
- image_transfer_processor.SetConfig(processor_config);
- npad_device->SetPollingMode(Core::HID::EmulatedDeviceIndex::RightIndex,
- Common::Input::PollingMode::IR);
- }
+ auto& device = GetIrCameraSharedMemoryDeviceEntry(camera_handle);
+ MakeProcessor<IrLedProcessor>(camera_handle, device);
+ auto& image_transfer_processor = GetProcessor<IrLedProcessor>(camera_handle);
+ image_transfer_processor.SetConfig(processor_config);
+ npad_device->SetPollingMode(Core::HID::EmulatedDeviceIndex::RightIndex,
+ Common::Input::PollingMode::IR);
- IPC::ResponseBuilder rb{ctx, 2};
- rb.Push(result);
+ R_SUCCEED();
}
-void IRS::StopImageProcessorAsync(HLERequestContext& ctx) {
- IPC::RequestParser rp{ctx};
- struct Parameters {
- Core::IrSensor::IrCameraHandle camera_handle;
- INSERT_PADDING_WORDS_NOINIT(1);
- u64 applet_resource_user_id;
- };
- static_assert(sizeof(Parameters) == 0x10, "Parameters has incorrect size.");
-
- const auto parameters{rp.PopRaw<Parameters>()};
-
+Result IRS::StopImageProcessorAsync(Core::IrSensor::IrCameraHandle camera_handle,
+ ClientAppletResourceUserId aruid) {
LOG_WARNING(Service_IRS,
"(STUBBED) called, npad_type={}, npad_id={}, applet_resource_user_id={}",
- parameters.camera_handle.npad_type, parameters.camera_handle.npad_id,
- parameters.applet_resource_user_id);
-
- auto result = IsIrCameraHandleValid(parameters.camera_handle);
- if (result.IsSuccess()) {
- // TODO: Stop image processor async
- npad_device->SetPollingMode(Core::HID::EmulatedDeviceIndex::RightIndex,
- Common::Input::PollingMode::Active);
- result = ResultSuccess;
- }
+ camera_handle.npad_type, camera_handle.npad_id, aruid.pid);
- IPC::ResponseBuilder rb{ctx, 2};
- rb.Push(result);
-}
+ R_TRY(IsIrCameraHandleValid(camera_handle));
-void IRS::ActivateIrsensorWithFunctionLevel(HLERequestContext& ctx) {
- IPC::RequestParser rp{ctx};
- struct Parameters {
- Core::IrSensor::PackedFunctionLevel function_level;
- INSERT_PADDING_WORDS_NOINIT(1);
- u64 applet_resource_user_id;
- };
- static_assert(sizeof(Parameters) == 0x10, "Parameters has incorrect size.");
+ // TODO: Stop image processor async
+ npad_device->SetPollingMode(Core::HID::EmulatedDeviceIndex::RightIndex,
+ Common::Input::PollingMode::Active);
- const auto parameters{rp.PopRaw<Parameters>()};
+ R_SUCCEED();
+}
+Result IRS::ActivateIrsensorWithFunctionLevel(Core::IrSensor::PackedFunctionLevel function_level,
+ ClientAppletResourceUserId aruid) {
LOG_WARNING(Service_IRS, "(STUBBED) called, function_level={}, applet_resource_user_id={}",
- parameters.function_level.function_level, parameters.applet_resource_user_id);
-
- IPC::ResponseBuilder rb{ctx, 2};
- rb.Push(ResultSuccess);
+ function_level.function_level, aruid.pid);
+ R_SUCCEED();
}
Result IRS::IsIrCameraHandleValid(const Core::IrSensor::IrCameraHandle& camera_handle) const {
diff --git a/src/core/hle/service/hid/irs.h b/src/core/hle/service/hid/irs.h
index 06b7279ee..58dfee6c3 100644
--- a/src/core/hle/service/hid/irs.h
+++ b/src/core/hle/service/hid/irs.h
@@ -4,6 +4,7 @@
#pragma once
#include "core/core.h"
+#include "core/hle/service/cmif_types.h"
#include "core/hle/service/service.h"
#include "hid_core/hid_types.h"
#include "hid_core/irsensor/irs_types.h"
@@ -35,26 +36,73 @@ private:
};
static_assert(sizeof(StatusManager) == 0x8000, "StatusManager is an invalid size");
- void ActivateIrsensor(HLERequestContext& ctx);
- void DeactivateIrsensor(HLERequestContext& ctx);
- void GetIrsensorSharedMemoryHandle(HLERequestContext& ctx);
- void StopImageProcessor(HLERequestContext& ctx);
- void RunMomentProcessor(HLERequestContext& ctx);
- void RunClusteringProcessor(HLERequestContext& ctx);
- void RunImageTransferProcessor(HLERequestContext& ctx);
- void GetImageTransferProcessorState(HLERequestContext& ctx);
- void RunTeraPluginProcessor(HLERequestContext& ctx);
- void GetNpadIrCameraHandle(HLERequestContext& ctx);
- void RunPointingProcessor(HLERequestContext& ctx);
- void SuspendImageProcessor(HLERequestContext& ctx);
- void CheckFirmwareVersion(HLERequestContext& ctx);
- void SetFunctionLevel(HLERequestContext& ctx);
- void RunImageTransferExProcessor(HLERequestContext& ctx);
- void RunIrLedProcessor(HLERequestContext& ctx);
- void StopImageProcessorAsync(HLERequestContext& ctx);
- void ActivateIrsensorWithFunctionLevel(HLERequestContext& ctx);
+ Result ActivateIrsensor(ClientAppletResourceUserId aruid);
+
+ Result DeactivateIrsensor(ClientAppletResourceUserId aruid);
+
+ Result GetIrsensorSharedMemoryHandle(OutCopyHandle<Kernel::KSharedMemory> out_shared_memory,
+ ClientAppletResourceUserId aruid);
+ Result StopImageProcessor(Core::IrSensor::IrCameraHandle camera_handle,
+ ClientAppletResourceUserId aruid);
+
+ Result RunMomentProcessor(Core::IrSensor::IrCameraHandle camera_handle,
+ ClientAppletResourceUserId aruid,
+ const Core::IrSensor::PackedMomentProcessorConfig& processor_config);
+
+ Result RunClusteringProcessor(
+ Core::IrSensor::IrCameraHandle camera_handle, ClientAppletResourceUserId aruid,
+ const Core::IrSensor::PackedClusteringProcessorConfig& processor_config);
+
+ Result RunImageTransferProcessor(
+ Core::IrSensor::IrCameraHandle camera_handle, ClientAppletResourceUserId aruid,
+ const Core::IrSensor::PackedImageTransferProcessorConfig& processor_config,
+ u64 transfer_memory_size, InCopyHandle<Kernel::KTransferMemory> t_mem);
+
+ Result GetImageTransferProcessorState(
+ Out<Core::IrSensor::ImageTransferProcessorState> out_state,
+ Core::IrSensor::IrCameraHandle camera_handle, ClientAppletResourceUserId aruid,
+ OutBuffer<BufferAttr_HipcMapAlias> out_buffer_data);
+
+ Result RunTeraPluginProcessor(Core::IrSensor::IrCameraHandle camera_handle,
+ Core::IrSensor::PackedTeraPluginProcessorConfig processor_config,
+ ClientAppletResourceUserId aruid);
+
+ Result GetNpadIrCameraHandle(Out<Core::IrSensor::IrCameraHandle> out_camera_handle,
+ Core::HID::NpadIdType npad_id);
+
+ Result RunPointingProcessor(
+ Core::IrSensor::IrCameraHandle camera_handle,
+ const Core::IrSensor::PackedPointingProcessorConfig& processor_config,
+ ClientAppletResourceUserId aruid);
+
+ Result SuspendImageProcessor(Core::IrSensor::IrCameraHandle camera_handle,
+ ClientAppletResourceUserId aruid);
+
+ Result CheckFirmwareVersion(Core::IrSensor::IrCameraHandle camera_handle,
+ Core::IrSensor::PackedMcuVersion mcu_version,
+ ClientAppletResourceUserId aruid);
+
+ Result SetFunctionLevel(Core::IrSensor::IrCameraHandle camera_handle,
+ Core::IrSensor::PackedFunctionLevel function_level,
+ ClientAppletResourceUserId aruid);
+
+ Result RunImageTransferExProcessor(
+ Core::IrSensor::IrCameraHandle camera_handle, ClientAppletResourceUserId aruid,
+ const Core::IrSensor::PackedImageTransferProcessorExConfig& processor_config,
+ u64 transfer_memory_size, InCopyHandle<Kernel::KTransferMemory> t_mem);
+
+ Result RunIrLedProcessor(Core::IrSensor::IrCameraHandle camera_handle,
+ Core::IrSensor::PackedIrLedProcessorConfig processor_config,
+ ClientAppletResourceUserId aruid);
+
+ Result StopImageProcessorAsync(Core::IrSensor::IrCameraHandle camera_handle,
+ ClientAppletResourceUserId aruid);
+
+ Result ActivateIrsensorWithFunctionLevel(Core::IrSensor::PackedFunctionLevel function_level,
+ ClientAppletResourceUserId aruid);
Result IsIrCameraHandleValid(const Core::IrSensor::IrCameraHandle& camera_handle) const;
+
Core::IrSensor::DeviceFormat& GetIrCameraSharedMemoryDeviceEntry(
const Core::IrSensor::IrCameraHandle& camera_handle);
diff --git a/src/core/hle/service/jit/jit.cpp b/src/core/hle/service/jit/jit.cpp
index 1f2cbcb61..4941a71a0 100644
--- a/src/core/hle/service/jit/jit.cpp
+++ b/src/core/hle/service/jit/jit.cpp
@@ -126,7 +126,7 @@ public:
R_THROW(ResultUnknown);
}
- Result LoadPlugin(u64 tmem_size, InCopyHandle<Kernel::KTransferMemory>& tmem,
+ Result LoadPlugin(u64 tmem_size, InCopyHandle<Kernel::KTransferMemory> tmem,
InBuffer<BufferAttr_HipcMapAlias> nrr,
InBuffer<BufferAttr_HipcMapAlias> nro) {
if (!tmem) {
@@ -268,9 +268,9 @@ public:
private:
Result CreateJitEnvironment(Out<SharedPointer<IJitEnvironment>> out_jit_environment,
- u64 rx_size, u64 ro_size, InCopyHandle<Kernel::KProcess>& process,
- InCopyHandle<Kernel::KCodeMemory>& rx_mem,
- InCopyHandle<Kernel::KCodeMemory>& ro_mem) {
+ u64 rx_size, u64 ro_size, InCopyHandle<Kernel::KProcess> process,
+ InCopyHandle<Kernel::KCodeMemory> rx_mem,
+ InCopyHandle<Kernel::KCodeMemory> ro_mem) {
if (!process) {
LOG_ERROR(Service_JIT, "process is null");
R_THROW(ResultUnknown);
diff --git a/src/core/hle/service/mii/mii.cpp b/src/core/hle/service/mii/mii.cpp
index efb7f6e32..0086f82c5 100644
--- a/src/core/hle/service/mii/mii.cpp
+++ b/src/core/hle/service/mii/mii.cpp
@@ -189,7 +189,7 @@ private:
R_RETURN(manager->Move(metadata, new_index, create_id));
}
- Result AddOrReplace(StoreData& store_data) {
+ Result AddOrReplace(const StoreData& store_data) {
LOG_INFO(Service_Mii, "called");
R_UNLESS(is_system, ResultPermissionDenied);
diff --git a/src/core/hle/service/nvdrv/devices/nvdisp_disp0.cpp b/src/core/hle/service/nvdrv/devices/nvdisp_disp0.cpp
index c1ebbd62d..abe95303e 100644
--- a/src/core/hle/service/nvdrv/devices/nvdisp_disp0.cpp
+++ b/src/core/hle/service/nvdrv/devices/nvdisp_disp0.cpp
@@ -1,6 +1,8 @@
// SPDX-FileCopyrightText: Copyright 2018 yuzu Emulator Project
// SPDX-License-Identifier: GPL-2.0-or-later
+#include <boost/container/small_vector.hpp>
+
#include "common/assert.h"
#include "common/logging/log.h"
#include "core/core.h"
@@ -38,19 +40,30 @@ NvResult nvdisp_disp0::Ioctl3(DeviceFD fd, Ioctl command, std::span<const u8> in
void nvdisp_disp0::OnOpen(NvCore::SessionId session_id, DeviceFD fd) {}
void nvdisp_disp0::OnClose(DeviceFD fd) {}
-void nvdisp_disp0::flip(u32 buffer_handle, u32 offset, android::PixelFormat format, u32 width,
- u32 height, u32 stride, android::BufferTransformFlags transform,
- const Common::Rectangle<int>& crop_rect,
- std::array<Service::Nvidia::NvFence, 4>& fences, u32 num_fences) {
- const DAddr addr = nvmap.GetHandleAddress(buffer_handle);
- LOG_TRACE(Service,
- "Drawing from address {:X} offset {:08X} Width {} Height {} Stride {} Format {}",
- addr, offset, width, height, stride, format);
+void nvdisp_disp0::Composite(std::span<const Nvnflinger::HwcLayer> sorted_layers) {
+ std::vector<Tegra::FramebufferConfig> output_layers;
+ std::vector<Service::Nvidia::NvFence> output_fences;
+ output_layers.reserve(sorted_layers.size());
+ output_fences.reserve(sorted_layers.size());
+
+ for (auto& layer : sorted_layers) {
+ output_layers.emplace_back(Tegra::FramebufferConfig{
+ .address = nvmap.GetHandleAddress(layer.buffer_handle),
+ .offset = layer.offset,
+ .width = layer.width,
+ .height = layer.height,
+ .stride = layer.stride,
+ .pixel_format = layer.format,
+ .transform_flags = layer.transform,
+ .crop_rect = layer.crop_rect,
+ });
- const Tegra::FramebufferConfig framebuffer{addr, offset, width, height,
- stride, format, transform, crop_rect};
+ for (size_t i = 0; i < layer.acquire_fence.num_fences; i++) {
+ output_fences.push_back(layer.acquire_fence.fences[i]);
+ }
+ }
- system.GPU().RequestSwapBuffers(&framebuffer, fences, num_fences);
+ system.GPU().RequestComposite(std::move(output_layers), std::move(output_fences));
system.SpeedLimiter().DoSpeedLimiting(system.CoreTiming().GetGlobalTimeUs());
system.GetPerfStats().EndSystemFrame();
system.GetPerfStats().BeginSystemFrame();
diff --git a/src/core/hle/service/nvdrv/devices/nvdisp_disp0.h b/src/core/hle/service/nvdrv/devices/nvdisp_disp0.h
index 5f13a50a2..1082b85c2 100644
--- a/src/core/hle/service/nvdrv/devices/nvdisp_disp0.h
+++ b/src/core/hle/service/nvdrv/devices/nvdisp_disp0.h
@@ -8,8 +8,7 @@
#include "common/common_types.h"
#include "common/math_util.h"
#include "core/hle/service/nvdrv/devices/nvdevice.h"
-#include "core/hle/service/nvnflinger/buffer_transform_flags.h"
-#include "core/hle/service/nvnflinger/pixel_format.h"
+#include "core/hle/service/nvnflinger/hwc_layer.h"
namespace Service::Nvidia::NvCore {
class Container;
@@ -35,11 +34,8 @@ public:
void OnOpen(NvCore::SessionId session_id, DeviceFD fd) override;
void OnClose(DeviceFD fd) override;
- /// Performs a screen flip, drawing the buffer pointed to by the handle.
- void flip(u32 buffer_handle, u32 offset, android::PixelFormat format, u32 width, u32 height,
- u32 stride, android::BufferTransformFlags transform,
- const Common::Rectangle<int>& crop_rect,
- std::array<Service::Nvidia::NvFence, 4>& fences, u32 num_fences);
+ /// Performs a screen flip, compositing each buffer.
+ void Composite(std::span<const Nvnflinger::HwcLayer> sorted_layers);
Kernel::KEvent* QueryEvent(u32 event_id) override;
diff --git a/src/core/hle/service/nvnflinger/hardware_composer.cpp b/src/core/hle/service/nvnflinger/hardware_composer.cpp
new file mode 100644
index 000000000..ba2b5c28c
--- /dev/null
+++ b/src/core/hle/service/nvnflinger/hardware_composer.cpp
@@ -0,0 +1,215 @@
+// SPDX-FileCopyrightText: Copyright 2024 yuzu Emulator Project
+// SPDX-License-Identifier: GPL-3.0-or-later
+
+#include <boost/container/small_vector.hpp>
+
+#include "common/microprofile.h"
+#include "core/hle/service/nvdrv/devices/nvdisp_disp0.h"
+#include "core/hle/service/nvnflinger/buffer_item.h"
+#include "core/hle/service/nvnflinger/buffer_item_consumer.h"
+#include "core/hle/service/nvnflinger/hardware_composer.h"
+#include "core/hle/service/nvnflinger/hwc_layer.h"
+#include "core/hle/service/nvnflinger/ui/graphic_buffer.h"
+#include "core/hle/service/vi/display/vi_display.h"
+#include "core/hle/service/vi/layer/vi_layer.h"
+
+namespace Service::Nvnflinger {
+
+namespace {
+
+s32 NormalizeSwapInterval(f32* out_speed_scale, s32 swap_interval) {
+ if (swap_interval <= 0) {
+ // As an extension, treat nonpositive swap interval as speed multiplier.
+ if (out_speed_scale) {
+ *out_speed_scale = 2.f * static_cast<f32>(1 - swap_interval);
+ }
+
+ swap_interval = 1;
+ }
+
+ if (swap_interval >= 5) {
+ // As an extension, treat high swap interval as precise speed control.
+ if (out_speed_scale) {
+ *out_speed_scale = static_cast<f32>(swap_interval) / 100.f;
+ }
+
+ swap_interval = 1;
+ }
+
+ return swap_interval;
+}
+
+} // namespace
+
+HardwareComposer::HardwareComposer() = default;
+HardwareComposer::~HardwareComposer() = default;
+
+u32 HardwareComposer::ComposeLocked(f32* out_speed_scale, VI::Display& display,
+ Nvidia::Devices::nvdisp_disp0& nvdisp) {
+ boost::container::small_vector<HwcLayer, 2> composition_stack;
+
+ // Set default speed limit to 100%.
+ *out_speed_scale = 1.0f;
+
+ // Determine the number of vsync periods to wait before composing again.
+ std::optional<s32> swap_interval{};
+ bool has_acquired_buffer{};
+
+ // Acquire all necessary framebuffers.
+ for (size_t i = 0; i < display.GetNumLayers(); i++) {
+ auto& layer = display.GetLayer(i);
+ auto layer_id = layer.GetLayerId();
+
+ // Try to fetch the framebuffer (either new or stale).
+ const auto result = this->CacheFramebufferLocked(layer, layer_id);
+
+ // If we failed, skip this layer.
+ if (result == CacheStatus::NoBufferAvailable) {
+ continue;
+ }
+
+ // If we acquired a new buffer, we need to present.
+ if (result == CacheStatus::BufferAcquired) {
+ has_acquired_buffer = true;
+ }
+
+ const auto& buffer = m_framebuffers[layer_id];
+ const auto& item = buffer.item;
+ const auto& igbp_buffer = *item.graphic_buffer;
+
+ // TODO: get proper Z-index from layer
+ composition_stack.emplace_back(HwcLayer{
+ .buffer_handle = igbp_buffer.BufferId(),
+ .offset = igbp_buffer.Offset(),
+ .format = igbp_buffer.ExternalFormat(),
+ .width = igbp_buffer.Width(),
+ .height = igbp_buffer.Height(),
+ .stride = igbp_buffer.Stride(),
+ .z_index = 0,
+ .transform = static_cast<android::BufferTransformFlags>(item.transform),
+ .crop_rect = item.crop,
+ .acquire_fence = item.fence,
+ });
+
+ // We need to compose again either before this frame is supposed to
+ // be released, or exactly on the vsync period it should be released.
+ const s32 item_swap_interval = NormalizeSwapInterval(out_speed_scale, item.swap_interval);
+
+ // TODO: handle cases where swap intervals are relatively prime. So far,
+ // only swap intervals of 0, 1 and 2 have been observed, but if 3 were
+ // to be introduced, this would cause an issue.
+ if (swap_interval) {
+ swap_interval = std::min(*swap_interval, item_swap_interval);
+ } else {
+ swap_interval = item_swap_interval;
+ }
+ }
+
+ // If any new buffers were acquired, we can present.
+ if (has_acquired_buffer) {
+ // Sort by Z-index.
+ std::stable_sort(composition_stack.begin(), composition_stack.end(),
+ [&](auto& l, auto& r) { return l.z_index < r.z_index; });
+
+ // Composite.
+ nvdisp.Composite(composition_stack);
+ }
+
+ // Render MicroProfile.
+ MicroProfileFlip();
+
+ // Advance by at least one frame.
+ const u32 frame_advance = swap_interval.value_or(1);
+ m_frame_number += frame_advance;
+
+ // Release any necessary framebuffers.
+ for (auto& [layer_id, framebuffer] : m_framebuffers) {
+ if (framebuffer.release_frame_number > m_frame_number) {
+ // Not yet ready to release this framebuffer.
+ continue;
+ }
+
+ if (!framebuffer.is_acquired) {
+ // Already released.
+ continue;
+ }
+
+ if (auto* layer = display.FindLayer(layer_id); layer != nullptr) {
+ // TODO: support release fence
+ // This is needed to prevent screen tearing
+ layer->GetConsumer().ReleaseBuffer(framebuffer.item, android::Fence::NoFence());
+ framebuffer.is_acquired = false;
+ }
+ }
+
+ return frame_advance;
+}
+
+void HardwareComposer::RemoveLayerLocked(VI::Display& display, LayerId layer_id) {
+ // Check if we are tracking a slot with this layer_id.
+ const auto it = m_framebuffers.find(layer_id);
+ if (it == m_framebuffers.end()) {
+ return;
+ }
+
+ // Try to release the buffer item.
+ auto* const layer = display.FindLayer(layer_id);
+ if (layer && it->second.is_acquired) {
+ layer->GetConsumer().ReleaseBuffer(it->second.item, android::Fence::NoFence());
+ }
+
+ // Erase the slot.
+ m_framebuffers.erase(it);
+}
+
+bool HardwareComposer::TryAcquireFramebufferLocked(VI::Layer& layer, Framebuffer& framebuffer) {
+ // Attempt the update.
+ const auto status = layer.GetConsumer().AcquireBuffer(&framebuffer.item, {}, false);
+ if (status != android::Status::NoError) {
+ return false;
+ }
+
+ // We succeeded, so set the new release frame info.
+ framebuffer.release_frame_number =
+ NormalizeSwapInterval(nullptr, framebuffer.item.swap_interval);
+ framebuffer.is_acquired = true;
+
+ return true;
+}
+
+HardwareComposer::CacheStatus HardwareComposer::CacheFramebufferLocked(VI::Layer& layer,
+ LayerId layer_id) {
+ // Check if this framebuffer is already present.
+ const auto it = m_framebuffers.find(layer_id);
+ if (it != m_framebuffers.end()) {
+ // If it's currently still acquired, we are done.
+ if (it->second.is_acquired) {
+ return CacheStatus::CachedBufferReused;
+ }
+
+ // Try to acquire a new item.
+ if (this->TryAcquireFramebufferLocked(layer, it->second)) {
+ // We got a new item.
+ return CacheStatus::BufferAcquired;
+ } else {
+ // We didn't acquire a new item, but we can reuse the slot.
+ return CacheStatus::CachedBufferReused;
+ }
+ }
+
+ // Framebuffer is not present, so try to create it.
+ Framebuffer framebuffer{};
+
+ if (this->TryAcquireFramebufferLocked(layer, framebuffer)) {
+ // Move the buffer item into a new slot.
+ m_framebuffers.emplace(layer_id, std::move(framebuffer));
+
+ // We succeeded.
+ return CacheStatus::BufferAcquired;
+ }
+
+ // We couldn't acquire the buffer item, so don't create a slot.
+ return CacheStatus::NoBufferAvailable;
+}
+
+} // namespace Service::Nvnflinger
diff --git a/src/core/hle/service/nvnflinger/hardware_composer.h b/src/core/hle/service/nvnflinger/hardware_composer.h
new file mode 100644
index 000000000..28392c512
--- /dev/null
+++ b/src/core/hle/service/nvnflinger/hardware_composer.h
@@ -0,0 +1,59 @@
+// SPDX-FileCopyrightText: Copyright 2024 yuzu Emulator Project
+// SPDX-License-Identifier: GPL-3.0-or-later
+
+#pragma once
+
+#include <memory>
+#include <boost/container/flat_map.hpp>
+
+#include "core/hle/service/nvnflinger/buffer_item.h"
+
+namespace Service::Nvidia::Devices {
+class nvdisp_disp0;
+}
+
+namespace Service::VI {
+class Display;
+class Layer;
+} // namespace Service::VI
+
+namespace Service::Nvnflinger {
+
+using LayerId = u64;
+
+class HardwareComposer {
+public:
+ explicit HardwareComposer();
+ ~HardwareComposer();
+
+ u32 ComposeLocked(f32* out_speed_scale, VI::Display& display,
+ Nvidia::Devices::nvdisp_disp0& nvdisp);
+ void RemoveLayerLocked(VI::Display& display, LayerId layer_id);
+
+private:
+ // TODO: do we want to track frame number in vi instead?
+ u64 m_frame_number{0};
+
+private:
+ using ReleaseFrameNumber = u64;
+
+ struct Framebuffer {
+ android::BufferItem item{};
+ ReleaseFrameNumber release_frame_number{};
+ bool is_acquired{false};
+ };
+
+ enum class CacheStatus : u32 {
+ NoBufferAvailable,
+ BufferAcquired,
+ CachedBufferReused,
+ };
+
+ boost::container::flat_map<LayerId, Framebuffer> m_framebuffers{};
+
+private:
+ bool TryAcquireFramebufferLocked(VI::Layer& layer, Framebuffer& framebuffer);
+ CacheStatus CacheFramebufferLocked(VI::Layer& layer, LayerId layer_id);
+};
+
+} // namespace Service::Nvnflinger
diff --git a/src/core/hle/service/nvnflinger/hwc_layer.h b/src/core/hle/service/nvnflinger/hwc_layer.h
new file mode 100644
index 000000000..3af668a25
--- /dev/null
+++ b/src/core/hle/service/nvnflinger/hwc_layer.h
@@ -0,0 +1,27 @@
+// SPDX-FileCopyrightText: Copyright 2024 yuzu Emulator Project
+// SPDX-License-Identifier: GPL-3.0-or-later
+
+#pragma once
+
+#include "common/math_util.h"
+#include "core/hle/service/nvdrv/nvdata.h"
+#include "core/hle/service/nvnflinger/buffer_transform_flags.h"
+#include "core/hle/service/nvnflinger/pixel_format.h"
+#include "core/hle/service/nvnflinger/ui/fence.h"
+
+namespace Service::Nvnflinger {
+
+struct HwcLayer {
+ u32 buffer_handle;
+ u32 offset;
+ android::PixelFormat format;
+ u32 width;
+ u32 height;
+ u32 stride;
+ s32 z_index;
+ android::BufferTransformFlags transform;
+ Common::Rectangle<int> crop_rect;
+ android::Fence acquire_fence;
+};
+
+} // namespace Service::Nvnflinger
diff --git a/src/core/hle/service/nvnflinger/nvnflinger.cpp b/src/core/hle/service/nvnflinger/nvnflinger.cpp
index 51133853c..d8ba89d43 100644
--- a/src/core/hle/service/nvnflinger/nvnflinger.cpp
+++ b/src/core/hle/service/nvnflinger/nvnflinger.cpp
@@ -18,6 +18,7 @@
#include "core/hle/service/nvnflinger/buffer_item_consumer.h"
#include "core/hle/service/nvnflinger/buffer_queue_core.h"
#include "core/hle/service/nvnflinger/fb_share_buffer_manager.h"
+#include "core/hle/service/nvnflinger/hardware_composer.h"
#include "core/hle/service/nvnflinger/hos_binder_driver_server.h"
#include "core/hle/service/nvnflinger/nvnflinger.h"
#include "core/hle/service/nvnflinger/ui/graphic_buffer.h"
@@ -279,45 +280,18 @@ void Nvnflinger::Compose() {
SCOPE_EXIT({ display.SignalVSyncEvent(); });
// Don't do anything for displays without layers.
- if (!display.HasLayers())
- continue;
-
- // TODO(Subv): Support more than 1 layer.
- VI::Layer& layer = display.GetLayer(0);
-
- android::BufferItem buffer{};
- const auto status = layer.GetConsumer().AcquireBuffer(&buffer, {}, false);
-
- if (status != android::Status::NoError) {
+ if (!display.HasLayers()) {
continue;
}
- const auto& igbp_buffer = *buffer.graphic_buffer;
-
if (!system.IsPoweredOn()) {
return; // We are likely shutting down
}
- // Now send the buffer to the GPU for drawing.
- // TODO(Subv): Support more than just disp0. The display device selection is probably based
- // on which display we're drawing (Default, Internal, External, etc)
auto nvdisp = nvdrv->GetDevice<Nvidia::Devices::nvdisp_disp0>(disp_fd);
ASSERT(nvdisp);
- Common::Rectangle<int> crop_rect{
- static_cast<int>(buffer.crop.Left()), static_cast<int>(buffer.crop.Top()),
- static_cast<int>(buffer.crop.Right()), static_cast<int>(buffer.crop.Bottom())};
-
- nvdisp->flip(igbp_buffer.BufferId(), igbp_buffer.Offset(), igbp_buffer.ExternalFormat(),
- igbp_buffer.Width(), igbp_buffer.Height(), igbp_buffer.Stride(),
- static_cast<android::BufferTransformFlags>(buffer.transform), crop_rect,
- buffer.fence.fences, buffer.fence.num_fences);
-
- MicroProfileFlip();
-
- swap_interval = buffer.swap_interval;
-
- layer.GetConsumer().ReleaseBuffer(buffer, android::Fence::NoFence());
+ swap_interval = display.GetComposer().ComposeLocked(&compose_speed_scale, display, *nvdisp);
}
}
@@ -334,15 +308,16 @@ s64 Nvnflinger::GetNextTicks() const {
speed_scale = 0.01f;
}
}
+
+ // Adjust by speed limit determined during composition.
+ speed_scale /= compose_speed_scale;
+
if (system.GetNVDECActive() && settings.use_video_framerate.GetValue()) {
// Run at intended presentation rate during video playback.
speed_scale = 1.f;
}
- // As an extension, treat nonpositive swap interval as framerate multiplier.
- const f32 effective_fps = swap_interval <= 0 ? 120.f * static_cast<f32>(1 - swap_interval)
- : 60.f / static_cast<f32>(swap_interval);
-
+ const f32 effective_fps = 60.f / static_cast<f32>(swap_interval);
return static_cast<s64>(speed_scale * (1000000000.f / effective_fps));
}
diff --git a/src/core/hle/service/nvnflinger/nvnflinger.h b/src/core/hle/service/nvnflinger/nvnflinger.h
index 369439142..c984d55a0 100644
--- a/src/core/hle/service/nvnflinger/nvnflinger.h
+++ b/src/core/hle/service/nvnflinger/nvnflinger.h
@@ -46,6 +46,7 @@ class BufferQueueProducer;
namespace Service::Nvnflinger {
class FbShareBufferManager;
+class HardwareComposer;
class HosBinderDriverServer;
class Nvnflinger final {
@@ -143,6 +144,7 @@ private:
u32 next_buffer_queue_id = 1;
s32 swap_interval = 1;
+ f32 compose_speed_scale = 1.0f;
bool is_abandoned = false;
diff --git a/src/core/hle/service/psc/time/clocks/context_writers.cpp b/src/core/hle/service/psc/time/clocks/context_writers.cpp
index ac8700f76..a44486b43 100644
--- a/src/core/hle/service/psc/time/clocks/context_writers.cpp
+++ b/src/core/hle/service/psc/time/clocks/context_writers.cpp
@@ -22,7 +22,7 @@ LocalSystemClockContextWriter::LocalSystemClockContextWriter(Core::System& syste
SharedMemory& shared_memory)
: m_system{system}, m_shared_memory{shared_memory} {}
-Result LocalSystemClockContextWriter::Write(SystemClockContext& context) {
+Result LocalSystemClockContextWriter::Write(const SystemClockContext& context) {
if (m_in_use) {
R_SUCCEED_IF(context == m_context);
m_context = context;
@@ -43,7 +43,7 @@ NetworkSystemClockContextWriter::NetworkSystemClockContextWriter(Core::System& s
SystemClockCore& system_clock)
: m_system{system}, m_shared_memory{shared_memory}, m_system_clock{system_clock} {}
-Result NetworkSystemClockContextWriter::Write(SystemClockContext& context) {
+Result NetworkSystemClockContextWriter::Write(const SystemClockContext& context) {
s64 time{};
[[maybe_unused]] auto res = m_system_clock.GetCurrentTime(&time);
@@ -66,7 +66,7 @@ EphemeralNetworkSystemClockContextWriter::EphemeralNetworkSystemClockContextWrit
Core::System& system)
: m_system{system} {}
-Result EphemeralNetworkSystemClockContextWriter::Write(SystemClockContext& context) {
+Result EphemeralNetworkSystemClockContextWriter::Write(const SystemClockContext& context) {
if (m_in_use) {
R_SUCCEED_IF(context == m_context);
m_context = context;
diff --git a/src/core/hle/service/psc/time/clocks/context_writers.h b/src/core/hle/service/psc/time/clocks/context_writers.h
index afd3725d4..6643fc9f2 100644
--- a/src/core/hle/service/psc/time/clocks/context_writers.h
+++ b/src/core/hle/service/psc/time/clocks/context_writers.h
@@ -24,7 +24,7 @@ private:
public:
virtual ~ContextWriter() = default;
- virtual Result Write(SystemClockContext& context) = 0;
+ virtual Result Write(const SystemClockContext& context) = 0;
void SignalAllNodes();
void Link(OperationEvent& operation_event);
@@ -37,7 +37,7 @@ class LocalSystemClockContextWriter : public ContextWriter {
public:
explicit LocalSystemClockContextWriter(Core::System& system, SharedMemory& shared_memory);
- Result Write(SystemClockContext& context) override;
+ Result Write(const SystemClockContext& context) override;
private:
Core::System& m_system;
@@ -52,7 +52,7 @@ public:
explicit NetworkSystemClockContextWriter(Core::System& system, SharedMemory& shared_memory,
SystemClockCore& system_clock);
- Result Write(SystemClockContext& context) override;
+ Result Write(const SystemClockContext& context) override;
private:
Core::System& m_system;
@@ -67,7 +67,7 @@ class EphemeralNetworkSystemClockContextWriter : public ContextWriter {
public:
EphemeralNetworkSystemClockContextWriter(Core::System& system);
- Result Write(SystemClockContext& context) override;
+ Result Write(const SystemClockContext& context) override;
private:
Core::System& m_system;
diff --git a/src/core/hle/service/psc/time/clocks/standard_local_system_clock_core.cpp b/src/core/hle/service/psc/time/clocks/standard_local_system_clock_core.cpp
index 36dca6689..6a74d4594 100644
--- a/src/core/hle/service/psc/time/clocks/standard_local_system_clock_core.cpp
+++ b/src/core/hle/service/psc/time/clocks/standard_local_system_clock_core.cpp
@@ -5,7 +5,7 @@
namespace Service::PSC::Time {
-void StandardLocalSystemClockCore::Initialize(SystemClockContext& context, s64 time) {
+void StandardLocalSystemClockCore::Initialize(const SystemClockContext& context, s64 time) {
SteadyClockTimePoint time_point{};
if (GetCurrentTimePoint(time_point) == ResultSuccess &&
context.steady_time_point.IdMatches(time_point)) {
diff --git a/src/core/hle/service/psc/time/clocks/standard_local_system_clock_core.h b/src/core/hle/service/psc/time/clocks/standard_local_system_clock_core.h
index 176ba3e94..5722d8e96 100644
--- a/src/core/hle/service/psc/time/clocks/standard_local_system_clock_core.h
+++ b/src/core/hle/service/psc/time/clocks/standard_local_system_clock_core.h
@@ -17,7 +17,7 @@ public:
: SystemClockCore{steady_clock} {}
~StandardLocalSystemClockCore() override = default;
- void Initialize(SystemClockContext& context, s64 time);
+ void Initialize(const SystemClockContext& context, s64 time);
};
} // namespace Service::PSC::Time
diff --git a/src/core/hle/service/psc/time/clocks/standard_network_system_clock_core.cpp b/src/core/hle/service/psc/time/clocks/standard_network_system_clock_core.cpp
index 8d6cb7db1..6938d369f 100644
--- a/src/core/hle/service/psc/time/clocks/standard_network_system_clock_core.cpp
+++ b/src/core/hle/service/psc/time/clocks/standard_network_system_clock_core.cpp
@@ -5,7 +5,7 @@
namespace Service::PSC::Time {
-void StandardNetworkSystemClockCore::Initialize(SystemClockContext& context, s64 accuracy) {
+void StandardNetworkSystemClockCore::Initialize(const SystemClockContext& context, s64 accuracy) {
if (SetContextAndWrite(context) != ResultSuccess) {
LOG_ERROR(Service_Time, "Failed to SetContext");
}
diff --git a/src/core/hle/service/psc/time/clocks/standard_network_system_clock_core.h b/src/core/hle/service/psc/time/clocks/standard_network_system_clock_core.h
index 933d2c8e3..bfafc7d71 100644
--- a/src/core/hle/service/psc/time/clocks/standard_network_system_clock_core.h
+++ b/src/core/hle/service/psc/time/clocks/standard_network_system_clock_core.h
@@ -19,7 +19,7 @@ public:
: SystemClockCore{steady_clock} {}
~StandardNetworkSystemClockCore() override = default;
- void Initialize(SystemClockContext& context, s64 accuracy);
+ void Initialize(const SystemClockContext& context, s64 accuracy);
bool IsAccuracySufficient();
private:
diff --git a/src/core/hle/service/psc/time/clocks/standard_user_system_clock_core.cpp b/src/core/hle/service/psc/time/clocks/standard_user_system_clock_core.cpp
index 9e9be05d6..31ed27396 100644
--- a/src/core/hle/service/psc/time/clocks/standard_user_system_clock_core.cpp
+++ b/src/core/hle/service/psc/time/clocks/standard_user_system_clock_core.cpp
@@ -46,7 +46,7 @@ Result StandardUserSystemClockCore::GetContext(SystemClockContext& out_context)
R_RETURN(m_local_system_clock.GetContext(out_context));
}
-Result StandardUserSystemClockCore::SetContext(SystemClockContext& context) {
+Result StandardUserSystemClockCore::SetContext(const SystemClockContext& context) {
R_RETURN(ResultNotImplemented);
}
diff --git a/src/core/hle/service/psc/time/clocks/standard_user_system_clock_core.h b/src/core/hle/service/psc/time/clocks/standard_user_system_clock_core.h
index a7fe7648d..32b8bc3bc 100644
--- a/src/core/hle/service/psc/time/clocks/standard_user_system_clock_core.h
+++ b/src/core/hle/service/psc/time/clocks/standard_user_system_clock_core.h
@@ -36,7 +36,7 @@ public:
Result SetAutomaticCorrection(bool automatic_correction);
Result GetContext(SystemClockContext& out_context) const override;
- Result SetContext(SystemClockContext& context) override;
+ Result SetContext(const SystemClockContext& context) override;
Result GetTimePoint(SteadyClockTimePoint& out_time_point);
void SetTimePointAndSignal(SteadyClockTimePoint& time_point);
diff --git a/src/core/hle/service/psc/time/clocks/system_clock_core.cpp b/src/core/hle/service/psc/time/clocks/system_clock_core.cpp
index c507ef517..2b7466831 100644
--- a/src/core/hle/service/psc/time/clocks/system_clock_core.cpp
+++ b/src/core/hle/service/psc/time/clocks/system_clock_core.cpp
@@ -51,12 +51,12 @@ Result SystemClockCore::GetContext(SystemClockContext& out_context) const {
R_SUCCEED();
}
-Result SystemClockCore::SetContext(SystemClockContext& context) {
+Result SystemClockCore::SetContext(const SystemClockContext& context) {
m_context = context;
R_SUCCEED();
}
-Result SystemClockCore::SetContextAndWrite(SystemClockContext& context) {
+Result SystemClockCore::SetContextAndWrite(const SystemClockContext& context) {
R_TRY(SetContext(context));
if (m_context_writer) {
diff --git a/src/core/hle/service/psc/time/clocks/system_clock_core.h b/src/core/hle/service/psc/time/clocks/system_clock_core.h
index 73811712e..0b928432f 100644
--- a/src/core/hle/service/psc/time/clocks/system_clock_core.h
+++ b/src/core/hle/service/psc/time/clocks/system_clock_core.h
@@ -41,8 +41,8 @@ public:
}
virtual Result GetContext(SystemClockContext& out_context) const;
- virtual Result SetContext(SystemClockContext& context);
- Result SetContextAndWrite(SystemClockContext& context);
+ virtual Result SetContext(const SystemClockContext& context);
+ Result SetContextAndWrite(const SystemClockContext& context);
void LinkOperationEvent(OperationEvent& operation_event);
diff --git a/src/core/hle/service/psc/time/service_manager.cpp b/src/core/hle/service/psc/time/service_manager.cpp
index 4e1643fcb..ed9fb32cd 100644
--- a/src/core/hle/service/psc/time/service_manager.cpp
+++ b/src/core/hle/service/psc/time/service_manager.cpp
@@ -78,8 +78,9 @@ Result ServiceManager::GetStaticServiceAsServiceManager(OutInterface<StaticServi
}
Result ServiceManager::SetupStandardSteadyClockCore(bool is_rtc_reset_detected,
- Common::UUID& clock_source_id, s64 rtc_offset,
- s64 internal_offset, s64 test_offset) {
+ const Common::UUID& clock_source_id,
+ s64 rtc_offset, s64 internal_offset,
+ s64 test_offset) {
LOG_DEBUG(Service_Time,
"called. is_rtc_reset_detected={} clock_source_id={} rtc_offset={} "
"internal_offset={} test_offset={}",
@@ -102,7 +103,8 @@ Result ServiceManager::SetupStandardSteadyClockCore(bool is_rtc_reset_detected,
R_SUCCEED();
}
-Result ServiceManager::SetupStandardLocalSystemClockCore(SystemClockContext& context, s64 time) {
+Result ServiceManager::SetupStandardLocalSystemClockCore(const SystemClockContext& context,
+ s64 time) {
LOG_DEBUG(Service_Time,
"called. context={} context.steady_time_point.clock_source_id={} time={}", context,
context.steady_time_point.clock_source_id.RawString(), time);
@@ -114,7 +116,7 @@ Result ServiceManager::SetupStandardLocalSystemClockCore(SystemClockContext& con
R_SUCCEED();
}
-Result ServiceManager::SetupStandardNetworkSystemClockCore(SystemClockContext& context,
+Result ServiceManager::SetupStandardNetworkSystemClockCore(SystemClockContext context,
s64 accuracy) {
LOG_DEBUG(Service_Time, "called. context={} steady_time_point.clock_source_id={} accuracy={}",
context, context.steady_time_point.clock_source_id.RawString(), accuracy);
@@ -131,7 +133,7 @@ Result ServiceManager::SetupStandardNetworkSystemClockCore(SystemClockContext& c
}
Result ServiceManager::SetupStandardUserSystemClockCore(bool automatic_correction,
- SteadyClockTimePoint& time_point) {
+ SteadyClockTimePoint time_point) {
LOG_DEBUG(Service_Time, "called. automatic_correction={} time_point={} clock_source_id={}",
automatic_correction, time_point, time_point.clock_source_id.RawString());
@@ -144,9 +146,9 @@ Result ServiceManager::SetupStandardUserSystemClockCore(bool automatic_correctio
R_SUCCEED();
}
-Result ServiceManager::SetupTimeZoneServiceCore(LocationName& name, RuleVersion& rule_version,
- u32 location_count,
- SteadyClockTimePoint& time_point,
+Result ServiceManager::SetupTimeZoneServiceCore(const LocationName& name,
+ const RuleVersion& rule_version, u32 location_count,
+ const SteadyClockTimePoint& time_point,
InBuffer<BufferAttr_HipcAutoSelect> rule_buffer) {
LOG_DEBUG(Service_Time,
"called. name={} rule_version={} location_count={} time_point={} "
diff --git a/src/core/hle/service/psc/time/service_manager.h b/src/core/hle/service/psc/time/service_manager.h
index 25d361d4f..22720e161 100644
--- a/src/core/hle/service/psc/time/service_manager.h
+++ b/src/core/hle/service/psc/time/service_manager.h
@@ -34,14 +34,15 @@ public:
Result GetStaticServiceAsAdmin(OutInterface<StaticService> out_service);
Result GetStaticServiceAsRepair(OutInterface<StaticService> out_service);
Result GetStaticServiceAsServiceManager(OutInterface<StaticService> out_service);
- Result SetupStandardSteadyClockCore(bool is_rtc_reset_detected, Common::UUID& clock_source_id,
- s64 rtc_offset, s64 internal_offset, s64 test_offset);
- Result SetupStandardLocalSystemClockCore(SystemClockContext& context, s64 time);
- Result SetupStandardNetworkSystemClockCore(SystemClockContext& context, s64 accuracy);
+ Result SetupStandardSteadyClockCore(bool is_rtc_reset_detected,
+ const Common::UUID& clock_source_id, s64 rtc_offset,
+ s64 internal_offset, s64 test_offset);
+ Result SetupStandardLocalSystemClockCore(const SystemClockContext& context, s64 time);
+ Result SetupStandardNetworkSystemClockCore(SystemClockContext context, s64 accuracy);
Result SetupStandardUserSystemClockCore(bool automatic_correction,
- SteadyClockTimePoint& time_point);
- Result SetupTimeZoneServiceCore(LocationName& name, RuleVersion& rule_version,
- u32 location_count, SteadyClockTimePoint& time_point,
+ SteadyClockTimePoint time_point);
+ Result SetupTimeZoneServiceCore(const LocationName& name, const RuleVersion& rule_version,
+ u32 location_count, const SteadyClockTimePoint& time_point,
InBuffer<BufferAttr_HipcAutoSelect> rule_buffer);
Result SetupEphemeralNetworkSystemClockCore();
Result GetStandardLocalClockOperationEvent(OutCopyHandle<Kernel::KReadableEvent> out_event);
diff --git a/src/core/hle/service/psc/time/shared_memory.cpp b/src/core/hle/service/psc/time/shared_memory.cpp
index defaceebe..adef6bcd8 100644
--- a/src/core/hle/service/psc/time/shared_memory.cpp
+++ b/src/core/hle/service/psc/time/shared_memory.cpp
@@ -51,11 +51,11 @@ SharedMemory::SharedMemory(Core::System& system)
std::memset(m_shared_memory_ptr, 0, sizeof(*m_shared_memory_ptr));
}
-void SharedMemory::SetLocalSystemContext(SystemClockContext& context) {
+void SharedMemory::SetLocalSystemContext(const SystemClockContext& context) {
WriteToLockFreeAtomicType(&m_shared_memory_ptr->local_system_clock_contexts, context);
}
-void SharedMemory::SetNetworkSystemContext(SystemClockContext& context) {
+void SharedMemory::SetNetworkSystemContext(const SystemClockContext& context) {
WriteToLockFreeAtomicType(&m_shared_memory_ptr->network_system_clock_contexts, context);
}
@@ -64,7 +64,7 @@ void SharedMemory::SetSteadyClockTimePoint(ClockSourceId clock_source_id, s64 ti
{time_point, clock_source_id});
}
-void SharedMemory::SetContinuousAdjustment(ContinuousAdjustmentTimePoint& time_point) {
+void SharedMemory::SetContinuousAdjustment(const ContinuousAdjustmentTimePoint& time_point) {
WriteToLockFreeAtomicType(&m_shared_memory_ptr->continuous_adjustment_time_points, time_point);
}
diff --git a/src/core/hle/service/psc/time/shared_memory.h b/src/core/hle/service/psc/time/shared_memory.h
index f9bf97d5c..b7bd00fc1 100644
--- a/src/core/hle/service/psc/time/shared_memory.h
+++ b/src/core/hle/service/psc/time/shared_memory.h
@@ -54,10 +54,10 @@ public:
return m_k_shared_memory;
}
- void SetLocalSystemContext(SystemClockContext& context);
- void SetNetworkSystemContext(SystemClockContext& context);
+ void SetLocalSystemContext(const SystemClockContext& context);
+ void SetNetworkSystemContext(const SystemClockContext& context);
void SetSteadyClockTimePoint(ClockSourceId clock_source_id, s64 time_diff);
- void SetContinuousAdjustment(ContinuousAdjustmentTimePoint& time_point);
+ void SetContinuousAdjustment(const ContinuousAdjustmentTimePoint& time_point);
void SetAutomaticCorrection(bool automatic_correction);
void UpdateBaseTime(s64 time);
diff --git a/src/core/hle/service/psc/time/static.cpp b/src/core/hle/service/psc/time/static.cpp
index 3ca3311af..24b85cc61 100644
--- a/src/core/hle/service/psc/time/static.cpp
+++ b/src/core/hle/service/psc/time/static.cpp
@@ -198,8 +198,8 @@ Result StaticService::GetStandardUserSystemClockAutomaticCorrectionUpdatedTime(
R_SUCCEED();
}
-Result StaticService::CalculateMonotonicSystemClockBaseTimePoint(Out<s64> out_time,
- SystemClockContext& context) {
+Result StaticService::CalculateMonotonicSystemClockBaseTimePoint(
+ Out<s64> out_time, const SystemClockContext& context) {
SCOPE_EXIT({ LOG_DEBUG(Service_Time, "called. context={} out_time={}", context, *out_time); });
R_UNLESS(m_time->m_standard_steady_clock.IsInitialized(), ResultClockUninitialized);
@@ -231,10 +231,9 @@ Result StaticService::GetClockSnapshot(OutClockSnapshot out_snapshot, TimeType t
R_RETURN(GetClockSnapshotImpl(out_snapshot, user_context, network_context, type));
}
-Result StaticService::GetClockSnapshotFromSystemClockContext(TimeType type,
- OutClockSnapshot out_snapshot,
- SystemClockContext& user_context,
- SystemClockContext& network_context) {
+Result StaticService::GetClockSnapshotFromSystemClockContext(
+ TimeType type, OutClockSnapshot out_snapshot, const SystemClockContext& user_context,
+ const SystemClockContext& network_context) {
SCOPE_EXIT({
LOG_DEBUG(Service_Time,
"called. type={} user_context={} network_context={} out_snapshot={}", type,
@@ -294,8 +293,9 @@ Result StaticService::CalculateSpanBetween(Out<s64> out_time, InClockSnapshot a,
}
Result StaticService::GetClockSnapshotImpl(OutClockSnapshot out_snapshot,
- SystemClockContext& user_context,
- SystemClockContext& network_context, TimeType type) {
+ const SystemClockContext& user_context,
+ const SystemClockContext& network_context,
+ TimeType type) {
out_snapshot->user_context = user_context;
out_snapshot->network_context = network_context;
diff --git a/src/core/hle/service/psc/time/static.h b/src/core/hle/service/psc/time/static.h
index 120bab259..e11db8093 100644
--- a/src/core/hle/service/psc/time/static.h
+++ b/src/core/hle/service/psc/time/static.h
@@ -55,18 +55,19 @@ public:
Result GetStandardUserSystemClockAutomaticCorrectionUpdatedTime(
Out<SteadyClockTimePoint> out_time_point);
Result CalculateMonotonicSystemClockBaseTimePoint(Out<s64> out_time,
- SystemClockContext& context);
+ const SystemClockContext& context);
Result GetClockSnapshot(OutClockSnapshot out_snapshot, TimeType type);
Result GetClockSnapshotFromSystemClockContext(TimeType type, OutClockSnapshot out_snapshot,
- SystemClockContext& user_context,
- SystemClockContext& network_context);
+ const SystemClockContext& user_context,
+ const SystemClockContext& network_context);
Result CalculateStandardUserSystemClockDifferenceByUser(Out<s64> out_difference,
InClockSnapshot a, InClockSnapshot b);
Result CalculateSpanBetween(Out<s64> out_time, InClockSnapshot a, InClockSnapshot b);
private:
- Result GetClockSnapshotImpl(OutClockSnapshot out_snapshot, SystemClockContext& user_context,
- SystemClockContext& network_context, TimeType type);
+ Result GetClockSnapshotImpl(OutClockSnapshot out_snapshot,
+ const SystemClockContext& user_context,
+ const SystemClockContext& network_context, TimeType type);
Core::System& m_system;
StaticServiceSetupInfo m_setup_info;
diff --git a/src/core/hle/service/psc/time/system_clock.cpp b/src/core/hle/service/psc/time/system_clock.cpp
index 0695502d5..b4e9264d8 100644
--- a/src/core/hle/service/psc/time/system_clock.cpp
+++ b/src/core/hle/service/psc/time/system_clock.cpp
@@ -53,7 +53,7 @@ Result SystemClock::GetSystemClockContext(Out<SystemClockContext> out_context) {
R_RETURN(m_clock_core.GetContext(*out_context));
}
-Result SystemClock::SetSystemClockContext(SystemClockContext& context) {
+Result SystemClock::SetSystemClockContext(const SystemClockContext& context) {
LOG_DEBUG(Service_Time, "called. context={}", context);
R_UNLESS(m_can_write_clock, ResultPermissionDenied);
diff --git a/src/core/hle/service/psc/time/system_clock.h b/src/core/hle/service/psc/time/system_clock.h
index b40d73595..3c11fb2f8 100644
--- a/src/core/hle/service/psc/time/system_clock.h
+++ b/src/core/hle/service/psc/time/system_clock.h
@@ -26,7 +26,7 @@ public:
Result GetCurrentTime(Out<s64> out_time);
Result SetCurrentTime(s64 time);
Result GetSystemClockContext(Out<SystemClockContext> out_context);
- Result SetSystemClockContext(SystemClockContext& context);
+ Result SetSystemClockContext(const SystemClockContext& context);
Result GetOperationEventReadableHandle(OutCopyHandle<Kernel::KReadableEvent> out_event);
private:
diff --git a/src/core/hle/service/psc/time/time_zone.cpp b/src/core/hle/service/psc/time/time_zone.cpp
index cc855c763..81bfb9092 100644
--- a/src/core/hle/service/psc/time/time_zone.cpp
+++ b/src/core/hle/service/psc/time/time_zone.cpp
@@ -55,7 +55,7 @@ constexpr bool GetTimeZoneTime(s64& out_time, const Tz::Rule& rule, s64 time, s3
}
} // namespace
-void TimeZone::SetTimePoint(SteadyClockTimePoint& time_point) {
+void TimeZone::SetTimePoint(const SteadyClockTimePoint& time_point) {
std::scoped_lock l{m_mutex};
m_steady_clock_time_point = time_point;
}
@@ -65,7 +65,7 @@ void TimeZone::SetTotalLocationNameCount(u32 count) {
m_total_location_name_count = count;
}
-void TimeZone::SetRuleVersion(RuleVersion& rule_version) {
+void TimeZone::SetRuleVersion(const RuleVersion& rule_version) {
std::scoped_lock l{m_mutex};
m_rule_version = rule_version;
}
@@ -123,7 +123,7 @@ Result TimeZone::ToCalendarTimeWithMyRule(CalendarTime& calendar_time,
R_RETURN(ToCalendarTimeImpl(calendar_time, calendar_additional, time, m_my_rule));
}
-Result TimeZone::ParseBinary(LocationName& name, std::span<const u8> binary) {
+Result TimeZone::ParseBinary(const LocationName& name, std::span<const u8> binary) {
std::scoped_lock l{m_mutex};
Tz::Rule tmp_rule{};
diff --git a/src/core/hle/service/psc/time/time_zone.h b/src/core/hle/service/psc/time/time_zone.h
index 6248e45f9..0e4ed6ed0 100644
--- a/src/core/hle/service/psc/time/time_zone.h
+++ b/src/core/hle/service/psc/time/time_zone.h
@@ -23,9 +23,9 @@ public:
m_initialized = true;
}
- void SetTimePoint(SteadyClockTimePoint& time_point);
+ void SetTimePoint(const SteadyClockTimePoint& time_point);
void SetTotalLocationNameCount(u32 count);
- void SetRuleVersion(RuleVersion& rule_version);
+ void SetRuleVersion(const RuleVersion& rule_version);
Result GetLocationName(LocationName& out_name);
Result GetTotalLocationCount(u32& out_count);
Result GetRuleVersion(RuleVersion& out_rule_version);
@@ -36,7 +36,7 @@ public:
const Tz::Rule& rule);
Result ToCalendarTimeWithMyRule(CalendarTime& calendar_time,
CalendarAdditionalInfo& calendar_additional, s64 time);
- Result ParseBinary(LocationName& name, std::span<const u8> binary);
+ Result ParseBinary(const LocationName& name, std::span<const u8> binary);
Result ParseBinaryInto(Tz::Rule& out_rule, std::span<const u8> binary);
Result ToPosixTime(u32& out_count, std::span<s64> out_times, size_t out_times_max_count,
const CalendarTime& calendar, const Tz::Rule& rule);
diff --git a/src/core/hle/service/psc/time/time_zone_service.cpp b/src/core/hle/service/psc/time/time_zone_service.cpp
index eb81f5b03..2f80030a4 100644
--- a/src/core/hle/service/psc/time/time_zone_service.cpp
+++ b/src/core/hle/service/psc/time/time_zone_service.cpp
@@ -42,7 +42,7 @@ Result TimeZoneService::GetDeviceLocationName(Out<LocationName> out_location_nam
R_RETURN(m_time_zone.GetLocationName(*out_location_name));
}
-Result TimeZoneService::SetDeviceLocationName(LocationName& location_name) {
+Result TimeZoneService::SetDeviceLocationName(const LocationName& location_name) {
LOG_DEBUG(Service_Time, "called. This function is not implemented!");
R_UNLESS(m_can_write_timezone_device_location, ResultPermissionDenied);
@@ -62,7 +62,7 @@ Result TimeZoneService::LoadLocationNameList(
R_RETURN(ResultNotImplemented);
}
-Result TimeZoneService::LoadTimeZoneRule(OutRule out_rule, LocationName& location_name) {
+Result TimeZoneService::LoadTimeZoneRule(OutRule out_rule, const LocationName& location_name) {
LOG_DEBUG(Service_Time, "called. This function is not implemented!");
R_RETURN(ResultNotImplemented);
@@ -86,7 +86,7 @@ Result TimeZoneService::GetDeviceLocationNameAndUpdatedTime(
}
Result TimeZoneService::SetDeviceLocationNameWithTimeZoneRule(
- LocationName& location_name, InBuffer<BufferAttr_HipcAutoSelect> binary) {
+ const LocationName& location_name, InBuffer<BufferAttr_HipcAutoSelect> binary) {
LOG_DEBUG(Service_Time, "called. location_name={}", location_name);
R_UNLESS(m_can_write_timezone_device_location, ResultPermissionDenied);
diff --git a/src/core/hle/service/psc/time/time_zone_service.h b/src/core/hle/service/psc/time/time_zone_service.h
index 6eb9ddc4b..79b6073e5 100644
--- a/src/core/hle/service/psc/time/time_zone_service.h
+++ b/src/core/hle/service/psc/time/time_zone_service.h
@@ -31,16 +31,16 @@ public:
~TimeZoneService() override = default;
Result GetDeviceLocationName(Out<LocationName> out_location_name);
- Result SetDeviceLocationName(LocationName& location_name);
+ Result SetDeviceLocationName(const LocationName& location_name);
Result GetTotalLocationNameCount(Out<u32> out_count);
Result LoadLocationNameList(Out<u32> out_count,
OutArray<LocationName, BufferAttr_HipcMapAlias> out_names,
u32 index);
- Result LoadTimeZoneRule(OutRule out_rule, LocationName& location_name);
+ Result LoadTimeZoneRule(OutRule out_rule, const LocationName& location_name);
Result GetTimeZoneRuleVersion(Out<RuleVersion> out_rule_version);
Result GetDeviceLocationNameAndUpdatedTime(Out<LocationName> location_name,
Out<SteadyClockTimePoint> out_time_point);
- Result SetDeviceLocationNameWithTimeZoneRule(LocationName& location_name,
+ Result SetDeviceLocationNameWithTimeZoneRule(const LocationName& location_name,
InBuffer<BufferAttr_HipcAutoSelect> binary);
Result ParseTimeZoneBinary(OutRule out_rule, InBuffer<BufferAttr_HipcAutoSelect> binary);
Result GetDeviceLocationNameOperationEventReadableHandle(
diff --git a/src/core/hle/service/ro/ro.cpp b/src/core/hle/service/ro/ro.cpp
index 51196170a..3d3ad2d62 100644
--- a/src/core/hle/service/ro/ro.cpp
+++ b/src/core/hle/service/ro/ro.cpp
@@ -549,13 +549,13 @@ public:
}
Result RegisterProcessHandle(ClientProcessId client_pid,
- InCopyHandle<Kernel::KProcess>& process) {
+ InCopyHandle<Kernel::KProcess> process) {
// Register the process.
R_RETURN(m_ro->RegisterProcess(std::addressof(m_context_id), process.Get(), *client_pid));
}
Result RegisterProcessModuleInfo(ClientProcessId client_pid, u64 nrr_address, u64 nrr_size,
- InCopyHandle<Kernel::KProcess>& process) {
+ InCopyHandle<Kernel::KProcess> process) {
// Validate the process.
R_TRY(m_ro->ValidateProcess(m_context_id, *client_pid));
diff --git a/src/core/hle/service/set/setting_formats/system_settings.h b/src/core/hle/service/set/setting_formats/system_settings.h
index ebc373da5..40230182a 100644
--- a/src/core/hle/service/set/setting_formats/system_settings.h
+++ b/src/core/hle/service/set/setting_formats/system_settings.h
@@ -12,6 +12,7 @@
#include "common/vector_math.h"
#include "core/hle/service/set/setting_formats/private_settings.h"
#include "core/hle/service/set/settings_types.h"
+#include "hid_core/resources/touch_screen/touch_types.h"
namespace Service::Set {
@@ -257,8 +258,7 @@ struct SystemSettings {
std::array<u8, 0x10> analog_stick_user_calibration_left;
std::array<u8, 0x10> analog_stick_user_calibration_right;
- // nn::settings::system::TouchScreenMode
- s32 touch_screen_mode;
+ TouchScreenMode touch_screen_mode;
INSERT_PADDING_BYTES(0x14); // Reserved
TvSettings tv_settings;
diff --git a/src/core/hle/service/set/system_settings_server.cpp b/src/core/hle/service/set/system_settings_server.cpp
index d3d0fb112..7ef4a0ded 100644
--- a/src/core/hle/service/set/system_settings_server.cpp
+++ b/src/core/hle/service/set/system_settings_server.cpp
@@ -275,8 +275,8 @@ ISystemSettingsServer::ISystemSettingsServer(Core::System& system_)
{184, nullptr, "SetPlatformRegion"},
{185, &ISystemSettingsServer::GetHomeMenuSchemeModel, "GetHomeMenuSchemeModel"},
{186, nullptr, "GetMemoryUsageRateFlag"},
- {187, nullptr, "GetTouchScreenMode"},
- {188, nullptr, "SetTouchScreenMode"},
+ {187, &ISystemSettingsServer::GetTouchScreenMode, "GetTouchScreenMode"},
+ {188, &ISystemSettingsServer::SetTouchScreenMode, "SetTouchScreenMode"},
{189, nullptr, "GetButtonConfigSettingsFull"},
{190, nullptr, "SetButtonConfigSettingsFull"},
{191, nullptr, "GetButtonConfigSettingsEmbedded"},
@@ -1395,6 +1395,28 @@ void ISystemSettingsServer::GetHomeMenuSchemeModel(HLERequestContext& ctx) {
rb.Push(0);
}
+void ISystemSettingsServer::GetTouchScreenMode(HLERequestContext& ctx) {
+ TouchScreenMode touch_screen_mode{};
+ auto res = GetTouchScreenMode(touch_screen_mode);
+
+ LOG_INFO(Service_SET, "called, touch_screen_mode={}", touch_screen_mode);
+
+ IPC::ResponseBuilder rb{ctx, 3};
+ rb.Push(res);
+ rb.PushEnum(touch_screen_mode);
+}
+
+void ISystemSettingsServer::SetTouchScreenMode(HLERequestContext& ctx) {
+ IPC::RequestParser rp{ctx};
+ const auto touch_screen_mode = rp.PopEnum<TouchScreenMode>();
+ auto res = SetTouchScreenMode(touch_screen_mode);
+
+ LOG_INFO(Service_SET, "called, touch_screen_mode={}", touch_screen_mode);
+
+ IPC::ResponseBuilder rb{ctx, 2};
+ rb.Push(res);
+}
+
void ISystemSettingsServer::GetFieldTestingFlag(HLERequestContext& ctx) {
LOG_INFO(Service_SET, "called, field_testing_flag={}", m_system_settings.field_testing_flag);
@@ -1670,4 +1692,15 @@ Result ISystemSettingsServer::SetUserSystemClockAutomaticCorrectionUpdatedTime(
R_SUCCEED();
}
+Result ISystemSettingsServer::GetTouchScreenMode(TouchScreenMode& touch_screen_mode) const {
+ touch_screen_mode = m_system_settings.touch_screen_mode;
+ R_SUCCEED();
+}
+
+Result ISystemSettingsServer::SetTouchScreenMode(TouchScreenMode touch_screen_mode) {
+ m_system_settings.touch_screen_mode = touch_screen_mode;
+ SetSaveNeeded();
+ R_SUCCEED();
+}
+
} // namespace Service::Set
diff --git a/src/core/hle/service/set/system_settings_server.h b/src/core/hle/service/set/system_settings_server.h
index 1982b9723..9a3b36f0c 100644
--- a/src/core/hle/service/set/system_settings_server.h
+++ b/src/core/hle/service/set/system_settings_server.h
@@ -74,6 +74,8 @@ public:
Service::PSC::Time::SteadyClockTimePoint& out_time_point) const;
Result SetUserSystemClockAutomaticCorrectionUpdatedTime(
const Service::PSC::Time::SteadyClockTimePoint& time_point);
+ Result GetTouchScreenMode(TouchScreenMode& touch_screen_mode) const;
+ Result SetTouchScreenMode(TouchScreenMode touch_screen_mode);
private:
void SetLanguageCode(HLERequestContext& ctx);
@@ -154,6 +156,8 @@ private:
void GetChineseTraditionalInputMethod(HLERequestContext& ctx);
void GetHomeMenuScheme(HLERequestContext& ctx);
void GetHomeMenuSchemeModel(HLERequestContext& ctx);
+ void GetTouchScreenMode(HLERequestContext& ctx);
+ void SetTouchScreenMode(HLERequestContext& ctx);
void GetFieldTestingFlag(HLERequestContext& ctx);
void GetPanelCrcMode(HLERequestContext& ctx);
void SetPanelCrcMode(HLERequestContext& ctx);
diff --git a/src/core/hle/service/vi/display/vi_display.cpp b/src/core/hle/service/vi/display/vi_display.cpp
index dab1905cc..7f2af9acc 100644
--- a/src/core/hle/service/vi/display/vi_display.cpp
+++ b/src/core/hle/service/vi/display/vi_display.cpp
@@ -16,6 +16,7 @@
#include "core/hle/service/nvnflinger/buffer_queue_consumer.h"
#include "core/hle/service/nvnflinger/buffer_queue_core.h"
#include "core/hle/service/nvnflinger/buffer_queue_producer.h"
+#include "core/hle/service/nvnflinger/hardware_composer.h"
#include "core/hle/service/nvnflinger/hos_binder_driver_server.h"
#include "core/hle/service/vi/display/vi_display.h"
#include "core/hle/service/vi/layer/vi_layer.h"
@@ -43,6 +44,7 @@ Display::Display(u64 id, std::string name_,
KernelHelpers::ServiceContext& service_context_, Core::System& system_)
: display_id{id}, name{std::move(name_)}, hos_binder_driver_server{hos_binder_driver_server_},
service_context{service_context_} {
+ hardware_composer = std::make_unique<Nvnflinger::HardwareComposer>();
vsync_event = service_context.CreateEvent(fmt::format("Display VSync Event {}", id));
}
@@ -81,8 +83,6 @@ void Display::SignalVSyncEvent() {
void Display::CreateLayer(u64 layer_id, u32 binder_id,
Service::Nvidia::NvCore::Container& nv_core) {
- ASSERT_MSG(layers.empty(), "Only one layer is supported per display at the moment");
-
auto [core, producer, consumer] = CreateBufferQueue(service_context, nv_core.GetNvMapFile());
auto buffer_item_consumer = std::make_shared<android::BufferItemConsumer>(std::move(consumer));
diff --git a/src/core/hle/service/vi/display/vi_display.h b/src/core/hle/service/vi/display/vi_display.h
index 8eb8a5155..220292cff 100644
--- a/src/core/hle/service/vi/display/vi_display.h
+++ b/src/core/hle/service/vi/display/vi_display.h
@@ -11,9 +11,14 @@
#include "common/common_types.h"
#include "core/hle/result.h"
+namespace Core {
+class System;
+}
+
namespace Kernel {
class KEvent;
-}
+class KReadableEvent;
+} // namespace Kernel
namespace Service::android {
class BufferQueueProducer;
@@ -24,8 +29,9 @@ class ServiceContext;
}
namespace Service::Nvnflinger {
+class HardwareComposer;
class HosBinderDriverServer;
-}
+} // namespace Service::Nvnflinger
namespace Service::Nvidia::NvCore {
class Container;
@@ -118,6 +124,10 @@ public:
///
const Layer* FindLayer(u64 layer_id) const;
+ Nvnflinger::HardwareComposer& GetComposer() const {
+ return *hardware_composer;
+ }
+
private:
u64 display_id;
std::string name;
@@ -125,6 +135,7 @@ private:
KernelHelpers::ServiceContext& service_context;
std::vector<std::unique_ptr<Layer>> layers;
+ std::unique_ptr<Nvnflinger::HardwareComposer> hardware_composer;
Kernel::KEvent* vsync_event{};
bool is_abandoned{};
};
diff --git a/src/core/hle/service/vi/vi.cpp b/src/core/hle/service/vi/vi.cpp
index 73058db9a..d508ed28c 100644
--- a/src/core/hle/service/vi/vi.cpp
+++ b/src/core/hle/service/vi/vi.cpp
@@ -195,8 +195,9 @@ private:
void GetSharedBufferMemoryHandleId(HLERequestContext& ctx) {
IPC::RequestParser rp{ctx};
const u64 buffer_id = rp.PopRaw<u64>();
+ const u64 aruid = ctx.GetPID();
- LOG_INFO(Service_VI, "called. buffer_id={:#x}", buffer_id);
+ LOG_INFO(Service_VI, "called. buffer_id={:#x}, aruid={:#x}", buffer_id, aruid);
struct OutputParameters {
s32 nvmap_handle;
@@ -206,7 +207,7 @@ private:
OutputParameters out{};
Nvnflinger::SharedMemoryPoolLayout layout{};
const auto result = nvnflinger.GetSystemBufferManager().GetSharedBufferMemoryHandleId(
- &out.size, &out.nvmap_handle, &layout, buffer_id, 0);
+ &out.size, &out.nvmap_handle, &layout, buffer_id, aruid);
ctx.WriteBuffer(&layout, sizeof(layout));
diff --git a/src/core/memory/cheat_engine.cpp b/src/core/memory/cheat_engine.cpp
index 96fa7fa3a..14d1a3840 100644
--- a/src/core/memory/cheat_engine.cpp
+++ b/src/core/memory/cheat_engine.cpp
@@ -9,6 +9,7 @@
#include "core/core_timing.h"
#include "core/hle/kernel/k_page_table.h"
#include "core/hle/kernel/k_process.h"
+#include "core/hle/kernel/k_process_page_table.h"
#include "core/hle/service/hid/hid_server.h"
#include "core/hle/service/sm/sm.h"
#include "core/memory.h"
@@ -46,12 +47,23 @@ StandardVmCallbacks::StandardVmCallbacks(System& system_, const CheatProcessMeta
StandardVmCallbacks::~StandardVmCallbacks() = default;
-void StandardVmCallbacks::MemoryRead(VAddr address, void* data, u64 size) {
- system.ApplicationMemory().ReadBlock(SanitizeAddress(address), data, size);
+void StandardVmCallbacks::MemoryReadUnsafe(VAddr address, void* data, u64 size) {
+ // Return zero on invalid address
+ if (!IsAddressInRange(address) || !system.ApplicationMemory().IsValidVirtualAddress(address)) {
+ std::memset(data, 0, size);
+ return;
+ }
+
+ system.ApplicationMemory().ReadBlock(address, data, size);
}
-void StandardVmCallbacks::MemoryWrite(VAddr address, const void* data, u64 size) {
- system.ApplicationMemory().WriteBlock(SanitizeAddress(address), data, size);
+void StandardVmCallbacks::MemoryWriteUnsafe(VAddr address, const void* data, u64 size) {
+ // Skip invalid memory write address
+ if (!IsAddressInRange(address) || !system.ApplicationMemory().IsValidVirtualAddress(address)) {
+ return;
+ }
+
+ system.ApplicationMemory().WriteBlock(address, data, size);
}
u64 StandardVmCallbacks::HidKeysDown() {
@@ -81,21 +93,25 @@ void StandardVmCallbacks::CommandLog(std::string_view data) {
data.back() == '\n' ? data.substr(0, data.size() - 1) : data);
}
-VAddr StandardVmCallbacks::SanitizeAddress(VAddr in) const {
+bool StandardVmCallbacks::IsAddressInRange(VAddr in) const {
if ((in < metadata.main_nso_extents.base ||
in >= metadata.main_nso_extents.base + metadata.main_nso_extents.size) &&
(in < metadata.heap_extents.base ||
- in >= metadata.heap_extents.base + metadata.heap_extents.size)) {
- LOG_ERROR(CheatEngine,
+ in >= metadata.heap_extents.base + metadata.heap_extents.size) &&
+ (in < metadata.alias_extents.base ||
+ in >= metadata.heap_extents.base + metadata.alias_extents.size) &&
+ (in < metadata.aslr_extents.base ||
+ in >= metadata.heap_extents.base + metadata.aslr_extents.size)) {
+ LOG_DEBUG(CheatEngine,
"Cheat attempting to access memory at invalid address={:016X}, if this "
"persists, "
"the cheat may be incorrect. However, this may be normal early in execution if "
"the game has not properly set up yet.",
in);
- return 0; ///< Invalid addresses will hard crash
+ return false; ///< Invalid addresses will hard crash
}
- return in;
+ return true;
}
CheatParser::~CheatParser() = default;
@@ -211,16 +227,14 @@ void CheatEngine::Initialize() {
.base = GetInteger(page_table.GetHeapRegionStart()),
.size = page_table.GetHeapRegionSize(),
};
-
- metadata.address_space_extents = {
- .base = GetInteger(page_table.GetAddressSpaceStart()),
- .size = page_table.GetAddressSpaceSize(),
- };
-
- metadata.alias_extents = {
+ metadata.aslr_extents = {
.base = GetInteger(page_table.GetAliasCodeRegionStart()),
.size = page_table.GetAliasCodeRegionSize(),
};
+ metadata.alias_extents = {
+ .base = GetInteger(page_table.GetAliasRegionStart()),
+ .size = page_table.GetAliasRegionSize(),
+ };
is_pending_reload.exchange(true);
}
diff --git a/src/core/memory/cheat_engine.h b/src/core/memory/cheat_engine.h
index ced2168d1..619cabaa2 100644
--- a/src/core/memory/cheat_engine.h
+++ b/src/core/memory/cheat_engine.h
@@ -27,17 +27,17 @@ public:
StandardVmCallbacks(System& system_, const CheatProcessMetadata& metadata_);
~StandardVmCallbacks() override;
- void MemoryRead(VAddr address, void* data, u64 size) override;
- void MemoryWrite(VAddr address, const void* data, u64 size) override;
+ void MemoryReadUnsafe(VAddr address, void* data, u64 size) override;
+ void MemoryWriteUnsafe(VAddr address, const void* data, u64 size) override;
u64 HidKeysDown() override;
void DebugLog(u8 id, u64 value) override;
void CommandLog(std::string_view data) override;
private:
- VAddr SanitizeAddress(VAddr address) const;
+ bool IsAddressInRange(VAddr address) const;
const CheatProcessMetadata& metadata;
- System& system;
+ Core::System& system;
};
// Intermediary class that parses a text file or other disk format for storing cheats into a
diff --git a/src/core/memory/dmnt_cheat_types.h b/src/core/memory/dmnt_cheat_types.h
index c6b40e505..64c072d3d 100644
--- a/src/core/memory/dmnt_cheat_types.h
+++ b/src/core/memory/dmnt_cheat_types.h
@@ -18,7 +18,7 @@ struct CheatProcessMetadata {
MemoryRegionExtents main_nso_extents{};
MemoryRegionExtents heap_extents{};
MemoryRegionExtents alias_extents{};
- MemoryRegionExtents address_space_extents{};
+ MemoryRegionExtents aslr_extents{};
std::array<u8, 0x20> main_nso_build_id{};
};
diff --git a/src/core/memory/dmnt_cheat_vm.cpp b/src/core/memory/dmnt_cheat_vm.cpp
index 31ffc4fbb..8bc81e72d 100644
--- a/src/core/memory/dmnt_cheat_vm.cpp
+++ b/src/core/memory/dmnt_cheat_vm.cpp
@@ -322,8 +322,9 @@ bool DmntCheatVm::DecodeNextOpcode(CheatVmOpcode& out) {
} break;
case CheatVmOpcodeType::EndConditionalBlock: {
// 20000000
- // There's actually nothing left to process here!
- opcode.opcode = EndConditionalOpcode{};
+ opcode.opcode = EndConditionalOpcode{
+ .is_else = ((first_dword >> 24) & 0xf) == 1,
+ };
} break;
case CheatVmOpcodeType::ControlLoop: {
// 300R0000 VVVVVVVV
@@ -555,6 +556,18 @@ bool DmntCheatVm::DecodeNextOpcode(CheatVmOpcode& out) {
.idx = first_dword & 0xF,
};
} break;
+ case CheatVmOpcodeType::PauseProcess: {
+ /* FF0????? */
+ /* FF0 = opcode 0xFF0 */
+ /* Pauses the current process. */
+ opcode.opcode = PauseProcessOpcode{};
+ } break;
+ case CheatVmOpcodeType::ResumeProcess: {
+ /* FF0????? */
+ /* FF0 = opcode 0xFF0 */
+ /* Pauses the current process. */
+ opcode.opcode = ResumeProcessOpcode{};
+ } break;
case CheatVmOpcodeType::DebugLog: {
// FFFTIX##
// FFFTI0Ma aaaaaaaa
@@ -621,7 +634,7 @@ bool DmntCheatVm::DecodeNextOpcode(CheatVmOpcode& out) {
return valid;
}
-void DmntCheatVm::SkipConditionalBlock() {
+void DmntCheatVm::SkipConditionalBlock(bool is_if) {
if (condition_depth > 0) {
// We want to continue until we're out of the current block.
const std::size_t desired_depth = condition_depth - 1;
@@ -637,8 +650,12 @@ void DmntCheatVm::SkipConditionalBlock() {
// We also support nesting of conditional blocks, and Gateway does not.
if (skip_opcode.begin_conditional_block) {
condition_depth++;
- } else if (std::holds_alternative<EndConditionalOpcode>(skip_opcode.opcode)) {
- condition_depth--;
+ } else if (auto end_cond = std::get_if<EndConditionalOpcode>(&skip_opcode.opcode)) {
+ if (!end_cond->is_else) {
+ condition_depth--;
+ } else if (is_if && condition_depth - 1 == desired_depth) {
+ break;
+ }
}
}
} else {
@@ -675,6 +692,10 @@ u64 DmntCheatVm::GetCheatProcessAddress(const CheatProcessMetadata& metadata,
return metadata.main_nso_extents.base + rel_address;
case MemoryAccessType::Heap:
return metadata.heap_extents.base + rel_address;
+ case MemoryAccessType::Alias:
+ return metadata.alias_extents.base + rel_address;
+ case MemoryAccessType::Aslr:
+ return metadata.aslr_extents.base + rel_address;
}
}
@@ -682,7 +703,6 @@ void DmntCheatVm::ResetState() {
registers.fill(0);
saved_values.fill(0);
loop_tops.fill(0);
- static_registers.fill(0);
instruction_ptr = 0;
condition_depth = 0;
decode_success = true;
@@ -753,7 +773,7 @@ void DmntCheatVm::Execute(const CheatProcessMetadata& metadata) {
case 2:
case 4:
case 8:
- callbacks->MemoryWrite(dst_address, &dst_value, store_static->bit_width);
+ callbacks->MemoryWriteUnsafe(dst_address, &dst_value, store_static->bit_width);
break;
}
} else if (auto begin_cond = std::get_if<BeginConditionalOpcode>(&cur_opcode.opcode)) {
@@ -766,7 +786,7 @@ void DmntCheatVm::Execute(const CheatProcessMetadata& metadata) {
case 2:
case 4:
case 8:
- callbacks->MemoryRead(src_address, &src_value, begin_cond->bit_width);
+ callbacks->MemoryReadUnsafe(src_address, &src_value, begin_cond->bit_width);
break;
}
// Check against condition.
@@ -794,13 +814,18 @@ void DmntCheatVm::Execute(const CheatProcessMetadata& metadata) {
}
// Skip conditional block if condition not met.
if (!cond_met) {
- SkipConditionalBlock();
+ SkipConditionalBlock(true);
}
- } else if (std::holds_alternative<EndConditionalOpcode>(cur_opcode.opcode)) {
- // Decrement the condition depth.
- // We will assume, graciously, that mismatched conditional block ends are a nop.
- if (condition_depth > 0) {
- condition_depth--;
+ } else if (auto end_cond = std::get_if<EndConditionalOpcode>(&cur_opcode.opcode)) {
+ if (end_cond->is_else) {
+ /* Skip to the end of the conditional block. */
+ this->SkipConditionalBlock(false);
+ } else {
+ /* Decrement the condition depth. */
+ /* We will assume, graciously, that mismatched conditional block ends are a nop. */
+ if (condition_depth > 0) {
+ condition_depth--;
+ }
}
} else if (auto ctrl_loop = std::get_if<ControlLoopOpcode>(&cur_opcode.opcode)) {
if (ctrl_loop->start_loop) {
@@ -832,8 +857,8 @@ void DmntCheatVm::Execute(const CheatProcessMetadata& metadata) {
case 2:
case 4:
case 8:
- callbacks->MemoryRead(src_address, &registers[ldr_memory->reg_index],
- ldr_memory->bit_width);
+ callbacks->MemoryReadUnsafe(src_address, &registers[ldr_memory->reg_index],
+ ldr_memory->bit_width);
break;
}
} else if (auto str_static = std::get_if<StoreStaticToAddressOpcode>(&cur_opcode.opcode)) {
@@ -849,7 +874,7 @@ void DmntCheatVm::Execute(const CheatProcessMetadata& metadata) {
case 2:
case 4:
case 8:
- callbacks->MemoryWrite(dst_address, &dst_value, str_static->bit_width);
+ callbacks->MemoryWriteUnsafe(dst_address, &dst_value, str_static->bit_width);
break;
}
// Increment register if relevant.
@@ -908,7 +933,7 @@ void DmntCheatVm::Execute(const CheatProcessMetadata& metadata) {
// Check for keypress.
if ((begin_keypress_cond->key_mask & kDown) != begin_keypress_cond->key_mask) {
// Keys not pressed. Skip conditional block.
- SkipConditionalBlock();
+ SkipConditionalBlock(true);
}
} else if (auto perform_math_reg =
std::get_if<PerformArithmeticRegisterOpcode>(&cur_opcode.opcode)) {
@@ -1007,7 +1032,7 @@ void DmntCheatVm::Execute(const CheatProcessMetadata& metadata) {
case 2:
case 4:
case 8:
- callbacks->MemoryWrite(dst_address, &dst_value, str_register->bit_width);
+ callbacks->MemoryWriteUnsafe(dst_address, &dst_value, str_register->bit_width);
break;
}
@@ -1086,7 +1111,8 @@ void DmntCheatVm::Execute(const CheatProcessMetadata& metadata) {
case 2:
case 4:
case 8:
- callbacks->MemoryRead(cond_address, &cond_value, begin_reg_cond->bit_width);
+ callbacks->MemoryReadUnsafe(cond_address, &cond_value,
+ begin_reg_cond->bit_width);
break;
}
}
@@ -1116,7 +1142,7 @@ void DmntCheatVm::Execute(const CheatProcessMetadata& metadata) {
// Skip conditional block if condition not met.
if (!cond_met) {
- SkipConditionalBlock();
+ SkipConditionalBlock(true);
}
} else if (auto save_restore_reg =
std::get_if<SaveRestoreRegisterOpcode>(&cur_opcode.opcode)) {
@@ -1178,6 +1204,10 @@ void DmntCheatVm::Execute(const CheatProcessMetadata& metadata) {
// Store a register to a static register.
static_registers[rw_static_reg->static_idx] = registers[rw_static_reg->idx];
}
+ } else if (std::holds_alternative<PauseProcessOpcode>(cur_opcode.opcode)) {
+ // TODO: Pause cheat process
+ } else if (std::holds_alternative<ResumeProcessOpcode>(cur_opcode.opcode)) {
+ // TODO: Resume cheat process
} else if (auto debug_log = std::get_if<DebugLogOpcode>(&cur_opcode.opcode)) {
// Read value from memory.
u64 log_value = 0;
@@ -1224,7 +1254,7 @@ void DmntCheatVm::Execute(const CheatProcessMetadata& metadata) {
case 2:
case 4:
case 8:
- callbacks->MemoryRead(val_address, &log_value, debug_log->bit_width);
+ callbacks->MemoryReadUnsafe(val_address, &log_value, debug_log->bit_width);
break;
}
}
diff --git a/src/core/memory/dmnt_cheat_vm.h b/src/core/memory/dmnt_cheat_vm.h
index 641cb09c4..fed6a24ad 100644
--- a/src/core/memory/dmnt_cheat_vm.h
+++ b/src/core/memory/dmnt_cheat_vm.h
@@ -42,12 +42,16 @@ enum class CheatVmOpcodeType : u32 {
DoubleExtendedWidth = 0xF0,
// Double-extended width opcodes.
+ PauseProcess = 0xFF0,
+ ResumeProcess = 0xFF1,
DebugLog = 0xFFF,
};
enum class MemoryAccessType : u32 {
MainNso = 0,
Heap = 1,
+ Alias = 2,
+ Aslr = 3,
};
enum class ConditionalComparisonType : u32 {
@@ -131,7 +135,9 @@ struct BeginConditionalOpcode {
VmInt value{};
};
-struct EndConditionalOpcode {};
+struct EndConditionalOpcode {
+ bool is_else;
+};
struct ControlLoopOpcode {
bool start_loop{};
@@ -222,6 +228,10 @@ struct ReadWriteStaticRegisterOpcode {
u32 idx{};
};
+struct PauseProcessOpcode {};
+
+struct ResumeProcessOpcode {};
+
struct DebugLogOpcode {
u32 bit_width{};
u32 log_id{};
@@ -244,8 +254,8 @@ struct CheatVmOpcode {
PerformArithmeticStaticOpcode, BeginKeypressConditionalOpcode,
PerformArithmeticRegisterOpcode, StoreRegisterToAddressOpcode,
BeginRegisterConditionalOpcode, SaveRestoreRegisterOpcode,
- SaveRestoreRegisterMaskOpcode, ReadWriteStaticRegisterOpcode, DebugLogOpcode,
- UnrecognizedInstruction>
+ SaveRestoreRegisterMaskOpcode, ReadWriteStaticRegisterOpcode, PauseProcessOpcode,
+ ResumeProcessOpcode, DebugLogOpcode, UnrecognizedInstruction>
opcode{};
};
@@ -256,8 +266,8 @@ public:
public:
virtual ~Callbacks();
- virtual void MemoryRead(VAddr address, void* data, u64 size) = 0;
- virtual void MemoryWrite(VAddr address, const void* data, u64 size) = 0;
+ virtual void MemoryReadUnsafe(VAddr address, void* data, u64 size) = 0;
+ virtual void MemoryWriteUnsafe(VAddr address, const void* data, u64 size) = 0;
virtual u64 HidKeysDown() = 0;
@@ -296,7 +306,7 @@ private:
std::array<std::size_t, NumRegisters> loop_tops{};
bool DecodeNextOpcode(CheatVmOpcode& out);
- void SkipConditionalBlock();
+ void SkipConditionalBlock(bool is_if);
void ResetState();
// For implementing the DebugLog opcode.