From 9349f06963759705f69bd3a23a4df5354bbf6951 Mon Sep 17 00:00:00 2001 From: ameerj <52414509+ameerj@users.noreply.github.com> Date: Sun, 25 Dec 2022 13:20:59 -0500 Subject: hle_ipc: Add ReadBufferSpan function Returns a std::span to the buffer address, rather than create a copy of the memory into a std::vector --- src/core/hle/kernel/hle_ipc.cpp | 19 +++++++++++++++++++ src/core/hle/kernel/hle_ipc.h | 3 +++ 2 files changed, 22 insertions(+) (limited to 'src/core/hle/kernel') diff --git a/src/core/hle/kernel/hle_ipc.cpp b/src/core/hle/kernel/hle_ipc.cpp index 738b6d0f1..549fd8aea 100644 --- a/src/core/hle/kernel/hle_ipc.cpp +++ b/src/core/hle/kernel/hle_ipc.cpp @@ -345,6 +345,25 @@ std::vector HLERequestContext::ReadBuffer(std::size_t buffer_index) const { } } +std::span HLERequestContext::ReadBufferSpan(std::size_t buffer_index) const { + LOG_CRITICAL(Debug, "called"); + const bool is_buffer_a{BufferDescriptorA().size() > buffer_index && + BufferDescriptorA()[buffer_index].Size()}; + if (is_buffer_a) { + ASSERT_OR_EXECUTE_MSG( + BufferDescriptorA().size() > buffer_index, { return {}; }, + "BufferDescriptorA invalid buffer_index {}", buffer_index); + const u8* const mem_ptr = memory.GetPointer(BufferDescriptorA()[buffer_index].Address()); + return std::span(mem_ptr, BufferDescriptorA()[buffer_index].Size()); + } else { + ASSERT_OR_EXECUTE_MSG( + BufferDescriptorX().size() > buffer_index, { return {}; }, + "BufferDescriptorX invalid buffer_index {}", buffer_index); + const u8* const mem_ptr = memory.GetPointer(BufferDescriptorX()[buffer_index].Address()); + return std::span(mem_ptr, BufferDescriptorX()[buffer_index].Size()); + } +} + std::size_t HLERequestContext::WriteBuffer(const void* buffer, std::size_t size, std::size_t buffer_index) const { if (size == 0) { diff --git a/src/core/hle/kernel/hle_ipc.h b/src/core/hle/kernel/hle_ipc.h index e252b5f4b..2242ff922 100644 --- a/src/core/hle/kernel/hle_ipc.h +++ b/src/core/hle/kernel/hle_ipc.h @@ -7,6 +7,7 @@ #include #include #include +#include #include #include #include @@ -273,6 +274,8 @@ public: /// Helper function to read a buffer using the appropriate buffer descriptor [[nodiscard]] std::vector ReadBuffer(std::size_t buffer_index = 0) const; + [[nodiscard]] std::span ReadBufferSpan(std::size_t buffer_index = 0) const; + /// Helper function to write a buffer using the appropriate buffer descriptor std::size_t WriteBuffer(const void* buffer, std::size_t size, std::size_t buffer_index = 0) const; -- cgit v1.2.3 From 7ffd62424804eceb73f01b1c4e8dc216134c8295 Mon Sep 17 00:00:00 2001 From: ameerj <52414509+ameerj@users.noreply.github.com> Date: Sun, 25 Dec 2022 13:42:32 -0500 Subject: service: Use ReadBufferSpan where it is trivial to do so --- src/core/hle/kernel/hle_ipc.cpp | 1 - src/core/hle/service/acc/acc.cpp | 6 +++--- src/core/hle/service/am/am.cpp | 2 +- src/core/hle/service/aoc/aoc_u.cpp | 4 ++-- src/core/hle/service/audio/audin_u.cpp | 6 +++--- src/core/hle/service/audio/audout_u.cpp | 4 ++-- src/core/hle/service/audio/audren_u.cpp | 6 +++--- src/core/hle/service/audio/hwopus.cpp | 6 +++--- src/core/hle/service/bcat/bcat_module.cpp | 2 +- src/core/hle/service/es/es.cpp | 4 ++-- src/core/hle/service/fatal/fatal.cpp | 2 +- src/core/hle/service/glue/notif.cpp | 4 ++-- src/core/hle/service/hid/controllers/npad.cpp | 2 +- src/core/hle/service/hid/controllers/npad.h | 2 +- src/core/hle/service/hid/hid.cpp | 8 ++++---- src/core/hle/service/jit/jit.cpp | 6 +++--- src/core/hle/service/ldn/ldn.cpp | 4 ++-- src/core/hle/service/lm/lm.cpp | 2 +- src/core/hle/service/nfc/mifare_user.cpp | 4 ++-- src/core/hle/service/nfc/nfc_user.cpp | 2 +- src/core/hle/service/nfp/nfp_user.cpp | 6 +++--- src/core/hle/service/ngct/ngct.cpp | 4 ++-- src/core/hle/service/nifm/nifm.cpp | 2 +- src/core/hle/service/prepo/prepo.cpp | 24 ++++++++++++------------ src/core/hle/service/set/set_sys.cpp | 8 ++++---- src/core/hle/service/sockets/sfdnsres.cpp | 6 +++--- src/core/hle/service/ssl/ssl.cpp | 10 +++++----- src/core/hle/service/time/time.cpp | 8 ++++---- src/core/hle/service/time/time_zone_service.cpp | 4 ++-- src/core/reporter.cpp | 2 +- src/core/reporter.h | 4 +++- 31 files changed, 78 insertions(+), 77 deletions(-) (limited to 'src/core/hle/kernel') diff --git a/src/core/hle/kernel/hle_ipc.cpp b/src/core/hle/kernel/hle_ipc.cpp index 549fd8aea..9bc72da02 100644 --- a/src/core/hle/kernel/hle_ipc.cpp +++ b/src/core/hle/kernel/hle_ipc.cpp @@ -346,7 +346,6 @@ std::vector HLERequestContext::ReadBuffer(std::size_t buffer_index) const { } std::span HLERequestContext::ReadBufferSpan(std::size_t buffer_index) const { - LOG_CRITICAL(Debug, "called"); const bool is_buffer_a{BufferDescriptorA().size() > buffer_index && BufferDescriptorA()[buffer_index].Size()}; if (is_buffer_a) { diff --git a/src/core/hle/service/acc/acc.cpp b/src/core/hle/service/acc/acc.cpp index 6d1084fd1..398bbc793 100644 --- a/src/core/hle/service/acc/acc.cpp +++ b/src/core/hle/service/acc/acc.cpp @@ -367,7 +367,7 @@ protected: IPC::RequestParser rp{ctx}; const auto base = rp.PopRaw(); - const auto user_data = ctx.ReadBuffer(); + const auto user_data = ctx.ReadBufferSpan(); LOG_DEBUG(Service_ACC, "called, username='{}', timestamp={:016X}, uuid=0x{}", Common::StringFromFixedZeroTerminatedBuffer( @@ -399,8 +399,8 @@ protected: IPC::RequestParser rp{ctx}; const auto base = rp.PopRaw(); - const auto user_data = ctx.ReadBuffer(); - const auto image_data = ctx.ReadBuffer(1); + const auto user_data = ctx.ReadBufferSpan(); + const auto image_data = ctx.ReadBufferSpan(1); LOG_DEBUG(Service_ACC, "called, username='{}', timestamp={:016X}, uuid=0x{}", Common::StringFromFixedZeroTerminatedBuffer( diff --git a/src/core/hle/service/am/am.cpp b/src/core/hle/service/am/am.cpp index 22999c942..958e40648 100644 --- a/src/core/hle/service/am/am.cpp +++ b/src/core/hle/service/am/am.cpp @@ -1124,7 +1124,7 @@ void IStorageAccessor::Write(Kernel::HLERequestContext& ctx) { IPC::RequestParser rp{ctx}; const u64 offset{rp.Pop()}; - const std::vector data{ctx.ReadBuffer()}; + const auto data{ctx.ReadBufferSpan()}; const std::size_t size{std::min(data.size(), backing.GetSize() - offset)}; LOG_DEBUG(Service_AM, "called, offset={}, size={}", offset, size); diff --git a/src/core/hle/service/aoc/aoc_u.cpp b/src/core/hle/service/aoc/aoc_u.cpp index 368ccd52f..cc976b155 100644 --- a/src/core/hle/service/aoc/aoc_u.cpp +++ b/src/core/hle/service/aoc/aoc_u.cpp @@ -72,7 +72,7 @@ private: IPC::RequestParser rp{ctx}; const auto unknown_1 = rp.Pop(); - [[maybe_unused]] const auto unknown_2 = ctx.ReadBuffer(); + [[maybe_unused]] const auto unknown_2 = ctx.ReadBufferSpan(); LOG_WARNING(Service_AOC, "(STUBBED) called, unknown_1={}", unknown_1); @@ -84,7 +84,7 @@ private: IPC::RequestParser rp{ctx}; const auto unknown_1 = rp.Pop(); - [[maybe_unused]] const auto unknown_2 = ctx.ReadBuffer(); + [[maybe_unused]] const auto unknown_2 = ctx.ReadBufferSpan(); LOG_WARNING(Service_AOC, "(STUBBED) called, unknown_1={}", unknown_1); diff --git a/src/core/hle/service/audio/audin_u.cpp b/src/core/hle/service/audio/audin_u.cpp index 053e8f9dd..f3dd8397d 100644 --- a/src/core/hle/service/audio/audin_u.cpp +++ b/src/core/hle/service/audio/audin_u.cpp @@ -98,7 +98,7 @@ private: LOG_ERROR(Service_Audio, "Input buffer is too small for an AudioInBuffer!"); } - const auto& in_buffer = ctx.ReadBuffer(); + const auto& in_buffer = ctx.ReadBufferSpan(); AudioInBuffer buffer{}; std::memcpy(&buffer, in_buffer.data(), sizeof(AudioInBuffer)); @@ -266,7 +266,7 @@ void AudInU::OpenAudioIn(Kernel::HLERequestContext& ctx) { IPC::RequestParser rp{ctx}; auto in_params{rp.PopRaw()}; auto applet_resource_user_id{rp.PopRaw()}; - const auto device_name_data{ctx.ReadBuffer()}; + const auto device_name_data{ctx.ReadBufferSpan()}; auto device_name = Common::StringFromBuffer(device_name_data); auto handle{ctx.GetCopyHandle(0)}; @@ -317,7 +317,7 @@ void AudInU::OpenAudioInProtocolSpecified(Kernel::HLERequestContext& ctx) { auto protocol_specified{rp.PopRaw()}; auto in_params{rp.PopRaw()}; auto applet_resource_user_id{rp.PopRaw()}; - const auto device_name_data{ctx.ReadBuffer()}; + const auto device_name_data{ctx.ReadBufferSpan()}; auto device_name = Common::StringFromBuffer(device_name_data); auto handle{ctx.GetCopyHandle(0)}; diff --git a/src/core/hle/service/audio/audout_u.cpp b/src/core/hle/service/audio/audout_u.cpp index 29751f075..4bf388055 100644 --- a/src/core/hle/service/audio/audout_u.cpp +++ b/src/core/hle/service/audio/audout_u.cpp @@ -105,7 +105,7 @@ private: LOG_ERROR(Service_Audio, "Input buffer is too small for an AudioOutBuffer!"); } - const auto& in_buffer = ctx.ReadBuffer(); + const auto& in_buffer = ctx.ReadBufferSpan(); AudioOutBuffer buffer{}; std::memcpy(&buffer, in_buffer.data(), sizeof(AudioOutBuffer)); @@ -264,7 +264,7 @@ void AudOutU::OpenAudioOut(Kernel::HLERequestContext& ctx) { IPC::RequestParser rp{ctx}; auto in_params{rp.PopRaw()}; auto applet_resource_user_id{rp.PopRaw()}; - const auto device_name_data{ctx.ReadBuffer()}; + const auto device_name_data{ctx.ReadBufferSpan()}; auto device_name = Common::StringFromBuffer(device_name_data); auto handle{ctx.GetCopyHandle(0)}; diff --git a/src/core/hle/service/audio/audren_u.cpp b/src/core/hle/service/audio/audren_u.cpp index 3a1c231b6..1a48c155e 100644 --- a/src/core/hle/service/audio/audren_u.cpp +++ b/src/core/hle/service/audio/audren_u.cpp @@ -112,7 +112,7 @@ private: void RequestUpdate(Kernel::HLERequestContext& ctx) { LOG_TRACE(Service_Audio, "called"); - std::vector input{ctx.ReadBuffer(0)}; + const auto input{ctx.ReadBufferSpan(0)}; // These buffers are written manually to avoid an issue with WriteBuffer throwing errors for // checking size 0. Performance size is 0 for most games. @@ -306,7 +306,7 @@ private: IPC::RequestParser rp{ctx}; const f32 volume = rp.Pop(); - const auto device_name_buffer = ctx.ReadBuffer(); + const auto device_name_buffer = ctx.ReadBufferSpan(); const std::string name = Common::StringFromBuffer(device_name_buffer); LOG_DEBUG(Service_Audio, "called. name={}, volume={}", name, volume); @@ -320,7 +320,7 @@ private: } void GetAudioDeviceOutputVolume(Kernel::HLERequestContext& ctx) { - const auto device_name_buffer = ctx.ReadBuffer(); + const auto device_name_buffer = ctx.ReadBufferSpan(); const std::string name = Common::StringFromBuffer(device_name_buffer); LOG_DEBUG(Service_Audio, "called. Name={}", name); diff --git a/src/core/hle/service/audio/hwopus.cpp b/src/core/hle/service/audio/hwopus.cpp index 825fb8bcc..7c3f25c67 100644 --- a/src/core/hle/service/audio/hwopus.cpp +++ b/src/core/hle/service/audio/hwopus.cpp @@ -74,7 +74,7 @@ private: ResetDecoderContext(); } - if (!DecodeOpusData(consumed, sample_count, ctx.ReadBuffer(), samples, performance)) { + if (!DecodeOpusData(consumed, sample_count, ctx.ReadBufferSpan(), samples, performance)) { LOG_ERROR(Audio, "Failed to decode opus data"); IPC::ResponseBuilder rb{ctx, 2}; // TODO(ogniK): Use correct error code @@ -93,7 +93,7 @@ private: ctx.WriteBuffer(samples); } - bool DecodeOpusData(u32& consumed, u32& sample_count, const std::vector& input, + bool DecodeOpusData(u32& consumed, u32& sample_count, std::span input, std::vector& output, u64* out_performance_time) const { const auto start_time = std::chrono::steady_clock::now(); const std::size_t raw_output_sz = output.size() * sizeof(opus_int16); @@ -257,7 +257,7 @@ void HwOpus::GetWorkBufferSizeEx(Kernel::HLERequestContext& ctx) { void HwOpus::GetWorkBufferSizeForMultiStreamEx(Kernel::HLERequestContext& ctx) { OpusMultiStreamParametersEx param; - std::memcpy(¶m, ctx.ReadBuffer().data(), ctx.GetReadBufferSize()); + std::memcpy(¶m, ctx.ReadBufferSpan().data(), ctx.GetReadBufferSize()); const auto sample_rate = param.sample_rate; const auto channel_count = param.channel_count; diff --git a/src/core/hle/service/bcat/bcat_module.cpp b/src/core/hle/service/bcat/bcat_module.cpp index cbe690a5d..c1a012739 100644 --- a/src/core/hle/service/bcat/bcat_module.cpp +++ b/src/core/hle/service/bcat/bcat_module.cpp @@ -206,7 +206,7 @@ private: IPC::RequestParser rp{ctx}; const auto title_id = rp.PopRaw(); - const auto passphrase_raw = ctx.ReadBuffer(); + const auto passphrase_raw = ctx.ReadBufferSpan(); LOG_DEBUG(Service_BCAT, "called, title_id={:016X}, passphrase={}", title_id, Common::HexToString(passphrase_raw)); diff --git a/src/core/hle/service/es/es.cpp b/src/core/hle/service/es/es.cpp index d183e5829..5ea61c430 100644 --- a/src/core/hle/service/es/es.cpp +++ b/src/core/hle/service/es/es.cpp @@ -121,8 +121,8 @@ private: } void ImportTicket(Kernel::HLERequestContext& ctx) { - const auto ticket = ctx.ReadBuffer(); - const auto cert = ctx.ReadBuffer(1); + const auto ticket = ctx.ReadBufferSpan(); + [[maybe_unused]] const auto cert = ctx.ReadBufferSpan(1); if (ticket.size() < sizeof(Core::Crypto::Ticket)) { LOG_ERROR(Service_ETicket, "The input buffer is not large enough!"); diff --git a/src/core/hle/service/fatal/fatal.cpp b/src/core/hle/service/fatal/fatal.cpp index 27675615b..ff896ea10 100644 --- a/src/core/hle/service/fatal/fatal.cpp +++ b/src/core/hle/service/fatal/fatal.cpp @@ -152,7 +152,7 @@ void Module::Interface::ThrowFatalWithCpuContext(Kernel::HLERequestContext& ctx) IPC::RequestParser rp(ctx); const auto error_code = rp.Pop(); const auto fatal_type = rp.PopEnum(); - const auto fatal_info = ctx.ReadBuffer(); + const auto fatal_info = ctx.ReadBufferSpan(); FatalInfo info{}; ASSERT_MSG(fatal_info.size() == sizeof(FatalInfo), "Invalid fatal info buffer size!"); diff --git a/src/core/hle/service/glue/notif.cpp b/src/core/hle/service/glue/notif.cpp index 3ace2dabd..ee5c6d3a4 100644 --- a/src/core/hle/service/glue/notif.cpp +++ b/src/core/hle/service/glue/notif.cpp @@ -38,7 +38,7 @@ void NOTIF_A::RegisterAlarmSetting(Kernel::HLERequestContext& ctx) { "application_parameter_size is bigger than 0x400 bytes"); AlarmSetting new_alarm{}; - memcpy(&new_alarm, ctx.ReadBuffer(0).data(), sizeof(AlarmSetting)); + memcpy(&new_alarm, ctx.ReadBufferSpan(0).data(), sizeof(AlarmSetting)); // TODO: Count alarms per game id if (alarms.size() >= max_alarms) { @@ -73,7 +73,7 @@ void NOTIF_A::UpdateAlarmSetting(Kernel::HLERequestContext& ctx) { "application_parameter_size is bigger than 0x400 bytes"); AlarmSetting alarm_setting{}; - memcpy(&alarm_setting, ctx.ReadBuffer(0).data(), sizeof(AlarmSetting)); + memcpy(&alarm_setting, ctx.ReadBufferSpan(0).data(), sizeof(AlarmSetting)); const auto alarm_it = GetAlarmFromId(alarm_setting.alarm_setting_id); if (alarm_it != alarms.end()) { diff --git a/src/core/hle/service/hid/controllers/npad.cpp b/src/core/hle/service/hid/controllers/npad.cpp index 2f871de31..df63083a8 100644 --- a/src/core/hle/service/hid/controllers/npad.cpp +++ b/src/core/hle/service/hid/controllers/npad.cpp @@ -737,7 +737,7 @@ Core::HID::NpadStyleTag Controller_NPad::GetSupportedStyleSet() const { return hid_core.GetSupportedStyleTag(); } -void Controller_NPad::SetSupportedNpadIdTypes(u8* data, std::size_t length) { +void Controller_NPad::SetSupportedNpadIdTypes(const u8* const data, std::size_t length) { ASSERT(length > 0 && (length % sizeof(u32)) == 0); supported_npad_id_types.clear(); supported_npad_id_types.resize(length / sizeof(u32)); diff --git a/src/core/hle/service/hid/controllers/npad.h b/src/core/hle/service/hid/controllers/npad.h index 1a589cca2..988ac8ec4 100644 --- a/src/core/hle/service/hid/controllers/npad.h +++ b/src/core/hle/service/hid/controllers/npad.h @@ -95,7 +95,7 @@ public: void SetSupportedStyleSet(Core::HID::NpadStyleTag style_set); Core::HID::NpadStyleTag GetSupportedStyleSet() const; - void SetSupportedNpadIdTypes(u8* data, std::size_t length); + void SetSupportedNpadIdTypes(const u8* const data, std::size_t length); void GetSupportedNpadIdTypes(u32* data, std::size_t max_length); std::size_t GetSupportedNpadIdTypesSize() const; diff --git a/src/core/hle/service/hid/hid.cpp b/src/core/hle/service/hid/hid.cpp index bf28440c6..80db6af06 100644 --- a/src/core/hle/service/hid/hid.cpp +++ b/src/core/hle/service/hid/hid.cpp @@ -1026,7 +1026,7 @@ void Hid::SetSupportedNpadIdType(Kernel::HLERequestContext& ctx) { const auto applet_resource_user_id{rp.Pop()}; applet_resource->GetController(HidController::NPad) - .SetSupportedNpadIdTypes(ctx.ReadBuffer().data(), ctx.GetReadBufferSize()); + .SetSupportedNpadIdTypes(ctx.ReadBufferSpan().data(), ctx.GetReadBufferSize()); LOG_DEBUG(Service_HID, "called, applet_resource_user_id={}", applet_resource_user_id); @@ -1564,8 +1564,8 @@ void Hid::SendVibrationValues(Kernel::HLERequestContext& ctx) { IPC::RequestParser rp{ctx}; const auto applet_resource_user_id{rp.Pop()}; - const auto handles = ctx.ReadBuffer(0); - const auto vibrations = ctx.ReadBuffer(1); + const auto handles = ctx.ReadBufferSpan(0); + const auto vibrations = ctx.ReadBufferSpan(1); std::vector vibration_device_handles( handles.size() / sizeof(Core::HID::VibrationDeviceHandle)); @@ -2104,7 +2104,7 @@ void Hid::WritePalmaRgbLedPatternEntry(Kernel::HLERequestContext& ctx) { const auto connection_handle{rp.PopRaw()}; const auto unknown{rp.Pop()}; - const auto buffer = ctx.ReadBuffer(); + [[maybe_unused]] const auto buffer = ctx.ReadBufferSpan(); LOG_WARNING(Service_HID, "(STUBBED) called, connection_handle={}, unknown={}", connection_handle.npad_id, unknown); diff --git a/src/core/hle/service/jit/jit.cpp b/src/core/hle/service/jit/jit.cpp index 8f2920c51..534639ff9 100644 --- a/src/core/hle/service/jit/jit.cpp +++ b/src/core/hle/service/jit/jit.cpp @@ -62,7 +62,7 @@ public: const auto parameters{rp.PopRaw()}; // Optional input/output buffers - std::vector input_buffer{ctx.CanReadBuffer() ? ctx.ReadBuffer() : std::vector()}; + const auto input_buffer{ctx.CanReadBuffer() ? ctx.ReadBufferSpan() : std::span()}; std::vector output_buffer(ctx.CanWriteBuffer() ? ctx.GetWriteBufferSize() : 0); // Function call prototype: @@ -132,7 +132,7 @@ public: const auto command{rp.PopRaw()}; // Optional input/output buffers - std::vector input_buffer{ctx.CanReadBuffer() ? ctx.ReadBuffer() : std::vector()}; + const auto input_buffer{ctx.CanReadBuffer() ? ctx.ReadBufferSpan() : std::span()}; std::vector output_buffer(ctx.CanWriteBuffer() ? ctx.GetWriteBufferSize() : 0); // Function call prototype: @@ -176,7 +176,7 @@ public: IPC::RequestParser rp{ctx}; const auto tmem_size{rp.PopRaw()}; const auto tmem_handle{ctx.GetCopyHandle(0)}; - const auto nro_plugin{ctx.ReadBuffer(1)}; + const auto nro_plugin{ctx.ReadBufferSpan(1)}; if (tmem_size == 0) { LOG_ERROR(Service_JIT, "attempted to load plugin with empty transfer memory"); diff --git a/src/core/hle/service/ldn/ldn.cpp b/src/core/hle/service/ldn/ldn.cpp index c49c61cff..ad097a6ef 100644 --- a/src/core/hle/service/ldn/ldn.cpp +++ b/src/core/hle/service/ldn/ldn.cpp @@ -412,7 +412,7 @@ public: } void SetAdvertiseData(Kernel::HLERequestContext& ctx) { - std::vector read_buffer = ctx.ReadBuffer(); + const auto read_buffer = ctx.ReadBufferSpan(); IPC::ResponseBuilder rb{ctx, 2}; rb.Push(lan_discovery.SetAdvertiseData(read_buffer)); @@ -464,7 +464,7 @@ public: parameters.security_config.passphrase_size, parameters.security_config.security_mode, parameters.local_communication_version); - const std::vector read_buffer = ctx.ReadBuffer(); + const auto read_buffer = ctx.ReadBufferSpan(); if (read_buffer.size() != sizeof(NetworkInfo)) { LOG_ERROR(Frontend, "NetworkInfo doesn't match read_buffer size!"); IPC::ResponseBuilder rb{ctx, 2}; diff --git a/src/core/hle/service/lm/lm.cpp b/src/core/hle/service/lm/lm.cpp index ef4b54046..0da461e6c 100644 --- a/src/core/hle/service/lm/lm.cpp +++ b/src/core/hle/service/lm/lm.cpp @@ -94,7 +94,7 @@ public: private: void Log(Kernel::HLERequestContext& ctx) { std::size_t offset{}; - const auto data = ctx.ReadBuffer(); + const auto data = ctx.ReadBufferSpan(); // This function only succeeds - Get that out of the way IPC::ResponseBuilder rb{ctx, 2}; diff --git a/src/core/hle/service/nfc/mifare_user.cpp b/src/core/hle/service/nfc/mifare_user.cpp index 51523a3ae..7d391c936 100644 --- a/src/core/hle/service/nfc/mifare_user.cpp +++ b/src/core/hle/service/nfc/mifare_user.cpp @@ -168,7 +168,7 @@ void MFIUser::StopDetection(Kernel::HLERequestContext& ctx) { void MFIUser::Read(Kernel::HLERequestContext& ctx) { IPC::RequestParser rp{ctx}; const auto device_handle{rp.Pop()}; - const auto buffer{ctx.ReadBuffer()}; + const auto buffer{ctx.ReadBufferSpan()}; const auto number_of_commands{ctx.GetReadBufferNumElements()}; std::vector read_commands(number_of_commands); @@ -209,7 +209,7 @@ void MFIUser::Read(Kernel::HLERequestContext& ctx) { void MFIUser::Write(Kernel::HLERequestContext& ctx) { IPC::RequestParser rp{ctx}; const auto device_handle{rp.Pop()}; - const auto buffer{ctx.ReadBuffer()}; + const auto buffer{ctx.ReadBufferSpan()}; const auto number_of_commands{ctx.GetReadBufferNumElements()}; std::vector write_commands(number_of_commands); diff --git a/src/core/hle/service/nfc/nfc_user.cpp b/src/core/hle/service/nfc/nfc_user.cpp index 89aa6b3f5..5dcf8a423 100644 --- a/src/core/hle/service/nfc/nfc_user.cpp +++ b/src/core/hle/service/nfc/nfc_user.cpp @@ -325,7 +325,7 @@ void IUser::SendCommandByPassThrough(Kernel::HLERequestContext& ctx) { IPC::RequestParser rp{ctx}; const auto device_handle{rp.Pop()}; const auto timeout{rp.PopRaw()}; - const auto command_data{ctx.ReadBuffer()}; + const auto command_data{ctx.ReadBufferSpan()}; LOG_INFO(Service_NFC, "(STUBBED) called, device_handle={}, timeout={}, data_size={}", device_handle, timeout.ToSeconds(), command_data.size()); diff --git a/src/core/hle/service/nfp/nfp_user.cpp b/src/core/hle/service/nfp/nfp_user.cpp index a4d3d1bc7..0a5606756 100644 --- a/src/core/hle/service/nfp/nfp_user.cpp +++ b/src/core/hle/service/nfp/nfp_user.cpp @@ -290,7 +290,7 @@ void IUser::GetApplicationArea(Kernel::HLERequestContext& ctx) { void IUser::SetApplicationArea(Kernel::HLERequestContext& ctx) { IPC::RequestParser rp{ctx}; const auto device_handle{rp.Pop()}; - const auto data{ctx.ReadBuffer()}; + const auto data{ctx.ReadBufferSpan()}; LOG_INFO(Service_NFP, "called, device_handle={}, data_size={}", device_handle, data.size()); if (state == State::NonInitialized) { @@ -370,7 +370,7 @@ void IUser::CreateApplicationArea(Kernel::HLERequestContext& ctx) { IPC::RequestParser rp{ctx}; const auto device_handle{rp.Pop()}; const auto access_id{rp.Pop()}; - const auto data{ctx.ReadBuffer()}; + const auto data{ctx.ReadBufferSpan()}; LOG_INFO(Service_NFP, "called, device_handle={}, data_size={}, access_id={}", device_handle, access_id, data.size()); @@ -637,7 +637,7 @@ void IUser::RecreateApplicationArea(Kernel::HLERequestContext& ctx) { IPC::RequestParser rp{ctx}; const auto device_handle{rp.Pop()}; const auto access_id{rp.Pop()}; - const auto data{ctx.ReadBuffer()}; + const auto data{ctx.ReadBufferSpan()}; LOG_INFO(Service_NFP, "called, device_handle={}, data_size={}, access_id={}", device_handle, access_id, data.size()); diff --git a/src/core/hle/service/ngct/ngct.cpp b/src/core/hle/service/ngct/ngct.cpp index 8af8a835d..bee62b054 100644 --- a/src/core/hle/service/ngct/ngct.cpp +++ b/src/core/hle/service/ngct/ngct.cpp @@ -24,7 +24,7 @@ public: private: void Match(Kernel::HLERequestContext& ctx) { - const auto buffer = ctx.ReadBuffer(); + const auto buffer = ctx.ReadBufferSpan(); const auto text = Common::StringFromFixedZeroTerminatedBuffer( reinterpret_cast(buffer.data()), buffer.size()); @@ -37,7 +37,7 @@ private: } void Filter(Kernel::HLERequestContext& ctx) { - const auto buffer = ctx.ReadBuffer(); + const auto buffer = ctx.ReadBufferSpan(); const auto text = Common::StringFromFixedZeroTerminatedBuffer( reinterpret_cast(buffer.data()), buffer.size()); diff --git a/src/core/hle/service/nifm/nifm.cpp b/src/core/hle/service/nifm/nifm.cpp index 4fa9f51a6..a6446fdcc 100644 --- a/src/core/hle/service/nifm/nifm.cpp +++ b/src/core/hle/service/nifm/nifm.cpp @@ -414,7 +414,7 @@ void IGeneralService::CreateTemporaryNetworkProfile(Kernel::HLERequestContext& c ASSERT_MSG(ctx.GetReadBufferSize() == 0x17c, "SfNetworkProfileData is not the correct size"); u128 uuid{}; - auto buffer = ctx.ReadBuffer(); + auto buffer = ctx.ReadBufferSpan(); std::memcpy(&uuid, buffer.data() + 8, sizeof(u128)); IPC::ResponseBuilder rb{ctx, 6, 0, 1}; diff --git a/src/core/hle/service/prepo/prepo.cpp b/src/core/hle/service/prepo/prepo.cpp index 78f897d3e..f6a141b2e 100644 --- a/src/core/hle/service/prepo/prepo.cpp +++ b/src/core/hle/service/prepo/prepo.cpp @@ -57,13 +57,13 @@ private: IPC::RequestParser rp{ctx}; const auto process_id = rp.PopRaw(); - const auto data1 = ctx.ReadBuffer(0); + const auto data1 = ctx.ReadBufferSpan(0); const auto data2 = [&ctx] { if (ctx.CanReadBuffer(1)) { - return ctx.ReadBuffer(1); + return ctx.ReadBufferSpan(1); } - return std::vector{}; + return std::span{}; }(); LOG_DEBUG(Service_PREPO, @@ -84,13 +84,13 @@ private: const auto user_id = rp.PopRaw(); const auto process_id = rp.PopRaw(); - const auto data1 = ctx.ReadBuffer(0); + const auto data1 = ctx.ReadBufferSpan(0); const auto data2 = [&ctx] { if (ctx.CanReadBuffer(1)) { - return ctx.ReadBuffer(1); + return ctx.ReadBufferSpan(1); } - return std::vector{}; + return std::span{}; }(); LOG_DEBUG(Service_PREPO, @@ -136,13 +136,13 @@ private: IPC::RequestParser rp{ctx}; const auto title_id = rp.PopRaw(); - const auto data1 = ctx.ReadBuffer(0); + const auto data1 = ctx.ReadBufferSpan(0); const auto data2 = [&ctx] { if (ctx.CanReadBuffer(1)) { - return ctx.ReadBuffer(1); + return ctx.ReadBufferSpan(1); } - return std::vector{}; + return std::span{}; }(); LOG_DEBUG(Service_PREPO, "called, title_id={:016X}, data1_size={:016X}, data2_size={:016X}", @@ -160,13 +160,13 @@ private: const auto user_id = rp.PopRaw(); const auto title_id = rp.PopRaw(); - const auto data1 = ctx.ReadBuffer(0); + const auto data1 = ctx.ReadBufferSpan(0); const auto data2 = [&ctx] { if (ctx.CanReadBuffer(1)) { - return ctx.ReadBuffer(1); + return ctx.ReadBufferSpan(1); } - return std::vector{}; + return std::span{}; }(); LOG_DEBUG(Service_PREPO, diff --git a/src/core/hle/service/set/set_sys.cpp b/src/core/hle/service/set/set_sys.cpp index 94c20edda..f1ace8184 100644 --- a/src/core/hle/service/set/set_sys.cpp +++ b/src/core/hle/service/set/set_sys.cpp @@ -131,12 +131,12 @@ void SET_SYS::GetSettingsItemValueSize(Kernel::HLERequestContext& ctx) { // The category of the setting. This corresponds to the top-level keys of // system_settings.ini. - const auto setting_category_buf{ctx.ReadBuffer(0)}; + const auto setting_category_buf{ctx.ReadBufferSpan(0)}; const std::string setting_category{setting_category_buf.begin(), setting_category_buf.end()}; // The name of the setting. This corresponds to the second-level keys of // system_settings.ini. - const auto setting_name_buf{ctx.ReadBuffer(1)}; + const auto setting_name_buf{ctx.ReadBufferSpan(1)}; const std::string setting_name{setting_name_buf.begin(), setting_name_buf.end()}; auto settings{GetSettings()}; @@ -156,12 +156,12 @@ void SET_SYS::GetSettingsItemValue(Kernel::HLERequestContext& ctx) { // The category of the setting. This corresponds to the top-level keys of // system_settings.ini. - const auto setting_category_buf{ctx.ReadBuffer(0)}; + const auto setting_category_buf{ctx.ReadBufferSpan(0)}; const std::string setting_category{setting_category_buf.begin(), setting_category_buf.end()}; // The name of the setting. This corresponds to the second-level keys of // system_settings.ini. - const auto setting_name_buf{ctx.ReadBuffer(1)}; + const auto setting_name_buf{ctx.ReadBufferSpan(1)}; const std::string setting_name{setting_name_buf.begin(), setting_name_buf.end()}; auto settings{GetSettings()}; diff --git a/src/core/hle/service/sockets/sfdnsres.cpp b/src/core/hle/service/sockets/sfdnsres.cpp index 097c37d7a..6d0e1dd6c 100644 --- a/src/core/hle/service/sockets/sfdnsres.cpp +++ b/src/core/hle/service/sockets/sfdnsres.cpp @@ -199,10 +199,10 @@ static std::pair GetAddrInfoRequestImpl(Kernel::HLERequestContext& ctx "called with ignored parameters: use_nsd_resolve={}, unknown={}, process_id={}", parameters.use_nsd_resolve, parameters.unknown, parameters.process_id); - const auto host_buffer = ctx.ReadBuffer(0); + const auto host_buffer = ctx.ReadBufferSpan(0); const std::string host = Common::StringFromBuffer(host_buffer); - const auto service_buffer = ctx.ReadBuffer(1); + const auto service_buffer = ctx.ReadBufferSpan(1); const std::string service = Common::StringFromBuffer(service_buffer); addrinfo* addrinfo; @@ -243,4 +243,4 @@ void SFDNSRES::GetAddrInfoRequestWithOptions(Kernel::HLERequestContext& ctx) { rb.Push(0); } -} // namespace Service::Sockets \ No newline at end of file +} // namespace Service::Sockets diff --git a/src/core/hle/service/ssl/ssl.cpp b/src/core/hle/service/ssl/ssl.cpp index 3735e0452..10851f08f 100644 --- a/src/core/hle/service/ssl/ssl.cpp +++ b/src/core/hle/service/ssl/ssl.cpp @@ -101,7 +101,7 @@ private: void ImportServerPki(Kernel::HLERequestContext& ctx) { IPC::RequestParser rp{ctx}; const auto certificate_format = rp.PopEnum(); - const auto pkcs_12_certificates = ctx.ReadBuffer(0); + [[maybe_unused]] const auto pkcs_12_certificates = ctx.ReadBufferSpan(0); constexpr u64 server_id = 0; @@ -113,13 +113,13 @@ private: } void ImportClientPki(Kernel::HLERequestContext& ctx) { - const auto pkcs_12_certificate = ctx.ReadBuffer(0); - const auto ascii_password = [&ctx] { + [[maybe_unused]] const auto pkcs_12_certificate = ctx.ReadBufferSpan(0); + [[maybe_unused]] const auto ascii_password = [&ctx] { if (ctx.CanReadBuffer(1)) { - return ctx.ReadBuffer(1); + return ctx.ReadBufferSpan(1); } - return std::vector{}; + return std::span{}; }(); constexpr u64 client_id = 0; diff --git a/src/core/hle/service/time/time.cpp b/src/core/hle/service/time/time.cpp index f77cdbb43..9376e0902 100644 --- a/src/core/hle/service/time/time.cpp +++ b/src/core/hle/service/time/time.cpp @@ -328,8 +328,8 @@ void Module::Interface::CalculateStandardUserSystemClockDifferenceByUser( Clock::ClockSnapshot snapshot_a; Clock::ClockSnapshot snapshot_b; - const auto snapshot_a_data = ctx.ReadBuffer(0); - const auto snapshot_b_data = ctx.ReadBuffer(1); + const auto snapshot_a_data = ctx.ReadBufferSpan(0); + const auto snapshot_b_data = ctx.ReadBufferSpan(1); std::memcpy(&snapshot_a, snapshot_a_data.data(), sizeof(Clock::ClockSnapshot)); std::memcpy(&snapshot_b, snapshot_b_data.data(), sizeof(Clock::ClockSnapshot)); @@ -355,8 +355,8 @@ void Module::Interface::CalculateSpanBetween(Kernel::HLERequestContext& ctx) { Clock::ClockSnapshot snapshot_a; Clock::ClockSnapshot snapshot_b; - const auto snapshot_a_data = ctx.ReadBuffer(0); - const auto snapshot_b_data = ctx.ReadBuffer(1); + const auto snapshot_a_data = ctx.ReadBufferSpan(0); + const auto snapshot_b_data = ctx.ReadBufferSpan(1); std::memcpy(&snapshot_a, snapshot_a_data.data(), sizeof(Clock::ClockSnapshot)); std::memcpy(&snapshot_b, snapshot_b_data.data(), sizeof(Clock::ClockSnapshot)); diff --git a/src/core/hle/service/time/time_zone_service.cpp b/src/core/hle/service/time/time_zone_service.cpp index 961040bfc..6d05a66f1 100644 --- a/src/core/hle/service/time/time_zone_service.cpp +++ b/src/core/hle/service/time/time_zone_service.cpp @@ -84,7 +84,7 @@ void ITimeZoneService::ToCalendarTime(Kernel::HLERequestContext& ctx) { LOG_DEBUG(Service_Time, "called, posix_time=0x{:016X}", posix_time); TimeZone::TimeZoneRule time_zone_rule{}; - const auto buffer{ctx.ReadBuffer()}; + const auto buffer{ctx.ReadBufferSpan()}; std::memcpy(&time_zone_rule, buffer.data(), buffer.size()); TimeZone::CalendarInfo calendar_info{}; @@ -128,7 +128,7 @@ void ITimeZoneService::ToPosixTime(Kernel::HLERequestContext& ctx) { IPC::RequestParser rp{ctx}; const auto calendar_time{rp.PopRaw()}; TimeZone::TimeZoneRule time_zone_rule{}; - std::memcpy(&time_zone_rule, ctx.ReadBuffer().data(), sizeof(TimeZone::TimeZoneRule)); + std::memcpy(&time_zone_rule, ctx.ReadBufferSpan().data(), sizeof(TimeZone::TimeZoneRule)); s64 posix_time{}; if (const Result result{time_zone_content_manager.GetTimeZoneManager().ToPosixTime( diff --git a/src/core/reporter.cpp b/src/core/reporter.cpp index 77821e047..59dfb8767 100644 --- a/src/core/reporter.cpp +++ b/src/core/reporter.cpp @@ -312,7 +312,7 @@ void Reporter::SaveUnimplementedAppletReport( } void Reporter::SavePlayReport(PlayReportType type, u64 title_id, - const std::vector>& data, + const std::vector>& data, std::optional process_id, std::optional user_id) const { if (!IsReportingEnabled()) { return; diff --git a/src/core/reporter.h b/src/core/reporter.h index 9fdb9d6c1..bb11f8e7c 100644 --- a/src/core/reporter.h +++ b/src/core/reporter.h @@ -5,6 +5,7 @@ #include #include +#include #include #include #include "common/common_types.h" @@ -56,7 +57,8 @@ public: System, }; - void SavePlayReport(PlayReportType type, u64 title_id, const std::vector>& data, + void SavePlayReport(PlayReportType type, u64 title_id, + const std::vector>& data, std::optional process_id = {}, std::optional user_id = {}) const; // Used by error applet -- cgit v1.2.3 From 59c0f85407d1d5d80fb88e5a6b0bab8d1abf438f Mon Sep 17 00:00:00 2001 From: ameerj <52414509+ameerj@users.noreply.github.com> Date: Sun, 25 Dec 2022 14:30:21 -0500 Subject: hle_ipc: Rename ReadBuffer to ReadBufferCopy Indicates explicitly that a copy is occurring --- src/core/hle/kernel/hle_ipc.cpp | 2 +- src/core/hle/kernel/hle_ipc.h | 5 +++-- src/core/hle/service/glue/arp.cpp | 3 ++- 3 files changed, 6 insertions(+), 4 deletions(-) (limited to 'src/core/hle/kernel') diff --git a/src/core/hle/kernel/hle_ipc.cpp b/src/core/hle/kernel/hle_ipc.cpp index 9bc72da02..36cf750de 100644 --- a/src/core/hle/kernel/hle_ipc.cpp +++ b/src/core/hle/kernel/hle_ipc.cpp @@ -325,7 +325,7 @@ Result HLERequestContext::WriteToOutgoingCommandBuffer(KThread& requesting_threa return ResultSuccess; } -std::vector HLERequestContext::ReadBuffer(std::size_t buffer_index) const { +std::vector HLERequestContext::ReadBufferCopy(std::size_t buffer_index) const { const bool is_buffer_a{BufferDescriptorA().size() > buffer_index && BufferDescriptorA()[buffer_index].Size()}; if (is_buffer_a) { diff --git a/src/core/hle/kernel/hle_ipc.h b/src/core/hle/kernel/hle_ipc.h index 2242ff922..27f9628c7 100644 --- a/src/core/hle/kernel/hle_ipc.h +++ b/src/core/hle/kernel/hle_ipc.h @@ -271,9 +271,10 @@ public: return domain_message_header.has_value(); } - /// Helper function to read a buffer using the appropriate buffer descriptor - [[nodiscard]] std::vector ReadBuffer(std::size_t buffer_index = 0) const; + /// Helper function to read a copy of a buffer using the appropriate buffer descriptor + [[nodiscard]] std::vector ReadBufferCopy(std::size_t buffer_index = 0) const; + /// Helper function to get a span of a buffer using the appropriate buffer descriptor [[nodiscard]] std::span ReadBufferSpan(std::size_t buffer_index = 0) const; /// Helper function to write a buffer using the appropriate buffer descriptor diff --git a/src/core/hle/service/glue/arp.cpp b/src/core/hle/service/glue/arp.cpp index 49b6d45fe..ce21b69e3 100644 --- a/src/core/hle/service/glue/arp.cpp +++ b/src/core/hle/service/glue/arp.cpp @@ -228,7 +228,8 @@ private: return; } - control = ctx.ReadBuffer(); + // TODO: Can this be a span? + control = ctx.ReadBufferCopy(); IPC::ResponseBuilder rb{ctx, 2}; rb.Push(ResultSuccess); -- cgit v1.2.3 From a1490d77ace26ec01a60541239d9a8524b88fcec Mon Sep 17 00:00:00 2001 From: ameerj <52414509+ameerj@users.noreply.github.com> Date: Sun, 25 Dec 2022 14:31:53 -0500 Subject: hle_ipc: Rename ReadBufferSpan to ReadBuffer --- src/core/hle/kernel/hle_ipc.cpp | 2 +- src/core/hle/kernel/hle_ipc.h | 6 ++--- src/core/hle/service/acc/acc.cpp | 6 ++--- src/core/hle/service/am/am.cpp | 2 +- src/core/hle/service/aoc/aoc_u.cpp | 4 ++-- src/core/hle/service/audio/audin_u.cpp | 6 ++--- src/core/hle/service/audio/audout_u.cpp | 4 ++-- src/core/hle/service/audio/audren_u.cpp | 6 ++--- src/core/hle/service/audio/hwopus.cpp | 4 ++-- src/core/hle/service/bcat/bcat_module.cpp | 2 +- src/core/hle/service/es/es.cpp | 4 ++-- src/core/hle/service/fatal/fatal.cpp | 2 +- src/core/hle/service/filesystem/fsp_srv.cpp | 28 +++++++++++----------- src/core/hle/service/glue/notif.cpp | 4 ++-- src/core/hle/service/hid/hid.cpp | 8 +++---- src/core/hle/service/hid/hidbus.cpp | 2 +- src/core/hle/service/jit/jit.cpp | 6 ++--- src/core/hle/service/ldn/ldn.cpp | 4 ++-- src/core/hle/service/lm/lm.cpp | 2 +- src/core/hle/service/nfc/mifare_user.cpp | 4 ++-- src/core/hle/service/nfc/nfc_user.cpp | 2 +- src/core/hle/service/nfp/nfp_user.cpp | 6 ++--- src/core/hle/service/ngct/ngct.cpp | 4 ++-- src/core/hle/service/nifm/nifm.cpp | 2 +- src/core/hle/service/nvdrv/nvdrv_interface.cpp | 10 ++++---- .../service/nvflinger/buffer_queue_producer.cpp | 2 +- src/core/hle/service/prepo/prepo.cpp | 16 ++++++------- src/core/hle/service/set/set_sys.cpp | 8 +++---- src/core/hle/service/sockets/bsd.cpp | 16 ++++++------- src/core/hle/service/sockets/sfdnsres.cpp | 4 ++-- src/core/hle/service/ssl/ssl.cpp | 6 ++--- src/core/hle/service/time/time.cpp | 8 +++---- src/core/hle/service/time/time_zone_service.cpp | 4 ++-- 33 files changed, 97 insertions(+), 97 deletions(-) (limited to 'src/core/hle/kernel') diff --git a/src/core/hle/kernel/hle_ipc.cpp b/src/core/hle/kernel/hle_ipc.cpp index 36cf750de..f6654f56c 100644 --- a/src/core/hle/kernel/hle_ipc.cpp +++ b/src/core/hle/kernel/hle_ipc.cpp @@ -345,7 +345,7 @@ std::vector HLERequestContext::ReadBufferCopy(std::size_t buffer_index) cons } } -std::span HLERequestContext::ReadBufferSpan(std::size_t buffer_index) const { +std::span HLERequestContext::ReadBuffer(std::size_t buffer_index) const { const bool is_buffer_a{BufferDescriptorA().size() > buffer_index && BufferDescriptorA()[buffer_index].Size()}; if (is_buffer_a) { diff --git a/src/core/hle/kernel/hle_ipc.h b/src/core/hle/kernel/hle_ipc.h index 27f9628c7..5bf4f171b 100644 --- a/src/core/hle/kernel/hle_ipc.h +++ b/src/core/hle/kernel/hle_ipc.h @@ -271,12 +271,12 @@ public: return domain_message_header.has_value(); } + /// Helper function to get a span of a buffer using the appropriate buffer descriptor + [[nodiscard]] std::span ReadBuffer(std::size_t buffer_index = 0) const; + /// Helper function to read a copy of a buffer using the appropriate buffer descriptor [[nodiscard]] std::vector ReadBufferCopy(std::size_t buffer_index = 0) const; - /// Helper function to get a span of a buffer using the appropriate buffer descriptor - [[nodiscard]] std::span ReadBufferSpan(std::size_t buffer_index = 0) const; - /// Helper function to write a buffer using the appropriate buffer descriptor std::size_t WriteBuffer(const void* buffer, std::size_t size, std::size_t buffer_index = 0) const; diff --git a/src/core/hle/service/acc/acc.cpp b/src/core/hle/service/acc/acc.cpp index 398bbc793..6d1084fd1 100644 --- a/src/core/hle/service/acc/acc.cpp +++ b/src/core/hle/service/acc/acc.cpp @@ -367,7 +367,7 @@ protected: IPC::RequestParser rp{ctx}; const auto base = rp.PopRaw(); - const auto user_data = ctx.ReadBufferSpan(); + const auto user_data = ctx.ReadBuffer(); LOG_DEBUG(Service_ACC, "called, username='{}', timestamp={:016X}, uuid=0x{}", Common::StringFromFixedZeroTerminatedBuffer( @@ -399,8 +399,8 @@ protected: IPC::RequestParser rp{ctx}; const auto base = rp.PopRaw(); - const auto user_data = ctx.ReadBufferSpan(); - const auto image_data = ctx.ReadBufferSpan(1); + const auto user_data = ctx.ReadBuffer(); + const auto image_data = ctx.ReadBuffer(1); LOG_DEBUG(Service_ACC, "called, username='{}', timestamp={:016X}, uuid=0x{}", Common::StringFromFixedZeroTerminatedBuffer( diff --git a/src/core/hle/service/am/am.cpp b/src/core/hle/service/am/am.cpp index 958e40648..ebcf6e164 100644 --- a/src/core/hle/service/am/am.cpp +++ b/src/core/hle/service/am/am.cpp @@ -1124,7 +1124,7 @@ void IStorageAccessor::Write(Kernel::HLERequestContext& ctx) { IPC::RequestParser rp{ctx}; const u64 offset{rp.Pop()}; - const auto data{ctx.ReadBufferSpan()}; + const auto data{ctx.ReadBuffer()}; const std::size_t size{std::min(data.size(), backing.GetSize() - offset)}; LOG_DEBUG(Service_AM, "called, offset={}, size={}", offset, size); diff --git a/src/core/hle/service/aoc/aoc_u.cpp b/src/core/hle/service/aoc/aoc_u.cpp index cc976b155..368ccd52f 100644 --- a/src/core/hle/service/aoc/aoc_u.cpp +++ b/src/core/hle/service/aoc/aoc_u.cpp @@ -72,7 +72,7 @@ private: IPC::RequestParser rp{ctx}; const auto unknown_1 = rp.Pop(); - [[maybe_unused]] const auto unknown_2 = ctx.ReadBufferSpan(); + [[maybe_unused]] const auto unknown_2 = ctx.ReadBuffer(); LOG_WARNING(Service_AOC, "(STUBBED) called, unknown_1={}", unknown_1); @@ -84,7 +84,7 @@ private: IPC::RequestParser rp{ctx}; const auto unknown_1 = rp.Pop(); - [[maybe_unused]] const auto unknown_2 = ctx.ReadBufferSpan(); + [[maybe_unused]] const auto unknown_2 = ctx.ReadBuffer(); LOG_WARNING(Service_AOC, "(STUBBED) called, unknown_1={}", unknown_1); diff --git a/src/core/hle/service/audio/audin_u.cpp b/src/core/hle/service/audio/audin_u.cpp index f3dd8397d..053e8f9dd 100644 --- a/src/core/hle/service/audio/audin_u.cpp +++ b/src/core/hle/service/audio/audin_u.cpp @@ -98,7 +98,7 @@ private: LOG_ERROR(Service_Audio, "Input buffer is too small for an AudioInBuffer!"); } - const auto& in_buffer = ctx.ReadBufferSpan(); + const auto& in_buffer = ctx.ReadBuffer(); AudioInBuffer buffer{}; std::memcpy(&buffer, in_buffer.data(), sizeof(AudioInBuffer)); @@ -266,7 +266,7 @@ void AudInU::OpenAudioIn(Kernel::HLERequestContext& ctx) { IPC::RequestParser rp{ctx}; auto in_params{rp.PopRaw()}; auto applet_resource_user_id{rp.PopRaw()}; - const auto device_name_data{ctx.ReadBufferSpan()}; + const auto device_name_data{ctx.ReadBuffer()}; auto device_name = Common::StringFromBuffer(device_name_data); auto handle{ctx.GetCopyHandle(0)}; @@ -317,7 +317,7 @@ void AudInU::OpenAudioInProtocolSpecified(Kernel::HLERequestContext& ctx) { auto protocol_specified{rp.PopRaw()}; auto in_params{rp.PopRaw()}; auto applet_resource_user_id{rp.PopRaw()}; - const auto device_name_data{ctx.ReadBufferSpan()}; + const auto device_name_data{ctx.ReadBuffer()}; auto device_name = Common::StringFromBuffer(device_name_data); auto handle{ctx.GetCopyHandle(0)}; diff --git a/src/core/hle/service/audio/audout_u.cpp b/src/core/hle/service/audio/audout_u.cpp index 4bf388055..29751f075 100644 --- a/src/core/hle/service/audio/audout_u.cpp +++ b/src/core/hle/service/audio/audout_u.cpp @@ -105,7 +105,7 @@ private: LOG_ERROR(Service_Audio, "Input buffer is too small for an AudioOutBuffer!"); } - const auto& in_buffer = ctx.ReadBufferSpan(); + const auto& in_buffer = ctx.ReadBuffer(); AudioOutBuffer buffer{}; std::memcpy(&buffer, in_buffer.data(), sizeof(AudioOutBuffer)); @@ -264,7 +264,7 @@ void AudOutU::OpenAudioOut(Kernel::HLERequestContext& ctx) { IPC::RequestParser rp{ctx}; auto in_params{rp.PopRaw()}; auto applet_resource_user_id{rp.PopRaw()}; - const auto device_name_data{ctx.ReadBufferSpan()}; + const auto device_name_data{ctx.ReadBuffer()}; auto device_name = Common::StringFromBuffer(device_name_data); auto handle{ctx.GetCopyHandle(0)}; diff --git a/src/core/hle/service/audio/audren_u.cpp b/src/core/hle/service/audio/audren_u.cpp index 1a48c155e..0ee28752c 100644 --- a/src/core/hle/service/audio/audren_u.cpp +++ b/src/core/hle/service/audio/audren_u.cpp @@ -112,7 +112,7 @@ private: void RequestUpdate(Kernel::HLERequestContext& ctx) { LOG_TRACE(Service_Audio, "called"); - const auto input{ctx.ReadBufferSpan(0)}; + const auto input{ctx.ReadBuffer(0)}; // These buffers are written manually to avoid an issue with WriteBuffer throwing errors for // checking size 0. Performance size is 0 for most games. @@ -306,7 +306,7 @@ private: IPC::RequestParser rp{ctx}; const f32 volume = rp.Pop(); - const auto device_name_buffer = ctx.ReadBufferSpan(); + const auto device_name_buffer = ctx.ReadBuffer(); const std::string name = Common::StringFromBuffer(device_name_buffer); LOG_DEBUG(Service_Audio, "called. name={}, volume={}", name, volume); @@ -320,7 +320,7 @@ private: } void GetAudioDeviceOutputVolume(Kernel::HLERequestContext& ctx) { - const auto device_name_buffer = ctx.ReadBufferSpan(); + const auto device_name_buffer = ctx.ReadBuffer(); const std::string name = Common::StringFromBuffer(device_name_buffer); LOG_DEBUG(Service_Audio, "called. Name={}", name); diff --git a/src/core/hle/service/audio/hwopus.cpp b/src/core/hle/service/audio/hwopus.cpp index 7c3f25c67..e01f87356 100644 --- a/src/core/hle/service/audio/hwopus.cpp +++ b/src/core/hle/service/audio/hwopus.cpp @@ -74,7 +74,7 @@ private: ResetDecoderContext(); } - if (!DecodeOpusData(consumed, sample_count, ctx.ReadBufferSpan(), samples, performance)) { + if (!DecodeOpusData(consumed, sample_count, ctx.ReadBuffer(), samples, performance)) { LOG_ERROR(Audio, "Failed to decode opus data"); IPC::ResponseBuilder rb{ctx, 2}; // TODO(ogniK): Use correct error code @@ -257,7 +257,7 @@ void HwOpus::GetWorkBufferSizeEx(Kernel::HLERequestContext& ctx) { void HwOpus::GetWorkBufferSizeForMultiStreamEx(Kernel::HLERequestContext& ctx) { OpusMultiStreamParametersEx param; - std::memcpy(¶m, ctx.ReadBufferSpan().data(), ctx.GetReadBufferSize()); + std::memcpy(¶m, ctx.ReadBuffer().data(), ctx.GetReadBufferSize()); const auto sample_rate = param.sample_rate; const auto channel_count = param.channel_count; diff --git a/src/core/hle/service/bcat/bcat_module.cpp b/src/core/hle/service/bcat/bcat_module.cpp index c1a012739..cbe690a5d 100644 --- a/src/core/hle/service/bcat/bcat_module.cpp +++ b/src/core/hle/service/bcat/bcat_module.cpp @@ -206,7 +206,7 @@ private: IPC::RequestParser rp{ctx}; const auto title_id = rp.PopRaw(); - const auto passphrase_raw = ctx.ReadBufferSpan(); + const auto passphrase_raw = ctx.ReadBuffer(); LOG_DEBUG(Service_BCAT, "called, title_id={:016X}, passphrase={}", title_id, Common::HexToString(passphrase_raw)); diff --git a/src/core/hle/service/es/es.cpp b/src/core/hle/service/es/es.cpp index 5ea61c430..fb8686859 100644 --- a/src/core/hle/service/es/es.cpp +++ b/src/core/hle/service/es/es.cpp @@ -121,8 +121,8 @@ private: } void ImportTicket(Kernel::HLERequestContext& ctx) { - const auto ticket = ctx.ReadBufferSpan(); - [[maybe_unused]] const auto cert = ctx.ReadBufferSpan(1); + const auto ticket = ctx.ReadBuffer(); + [[maybe_unused]] const auto cert = ctx.ReadBuffer(1); if (ticket.size() < sizeof(Core::Crypto::Ticket)) { LOG_ERROR(Service_ETicket, "The input buffer is not large enough!"); diff --git a/src/core/hle/service/fatal/fatal.cpp b/src/core/hle/service/fatal/fatal.cpp index ff896ea10..27675615b 100644 --- a/src/core/hle/service/fatal/fatal.cpp +++ b/src/core/hle/service/fatal/fatal.cpp @@ -152,7 +152,7 @@ void Module::Interface::ThrowFatalWithCpuContext(Kernel::HLERequestContext& ctx) IPC::RequestParser rp(ctx); const auto error_code = rp.Pop(); const auto fatal_type = rp.PopEnum(); - const auto fatal_info = ctx.ReadBufferSpan(); + const auto fatal_info = ctx.ReadBuffer(); FatalInfo info{}; ASSERT_MSG(fatal_info.size() == sizeof(FatalInfo), "Invalid fatal info buffer size!"); diff --git a/src/core/hle/service/filesystem/fsp_srv.cpp b/src/core/hle/service/filesystem/fsp_srv.cpp index efebb0ccc..cab44bf9c 100644 --- a/src/core/hle/service/filesystem/fsp_srv.cpp +++ b/src/core/hle/service/filesystem/fsp_srv.cpp @@ -190,7 +190,7 @@ private: return; } - const auto data = ctx.ReadBufferSpan(); + const auto data = ctx.ReadBuffer(); ASSERT_MSG( static_cast(data.size()) <= length, @@ -337,7 +337,7 @@ public: void CreateFile(Kernel::HLERequestContext& ctx) { IPC::RequestParser rp{ctx}; - const auto file_buffer = ctx.ReadBufferSpan(); + const auto file_buffer = ctx.ReadBuffer(); const std::string name = Common::StringFromBuffer(file_buffer); const u64 file_mode = rp.Pop(); @@ -351,7 +351,7 @@ public: } void DeleteFile(Kernel::HLERequestContext& ctx) { - const auto file_buffer = ctx.ReadBufferSpan(); + const auto file_buffer = ctx.ReadBuffer(); const std::string name = Common::StringFromBuffer(file_buffer); LOG_DEBUG(Service_FS, "called. file={}", name); @@ -361,7 +361,7 @@ public: } void CreateDirectory(Kernel::HLERequestContext& ctx) { - const auto file_buffer = ctx.ReadBufferSpan(); + const auto file_buffer = ctx.ReadBuffer(); const std::string name = Common::StringFromBuffer(file_buffer); LOG_DEBUG(Service_FS, "called. directory={}", name); @@ -371,7 +371,7 @@ public: } void DeleteDirectory(Kernel::HLERequestContext& ctx) { - const auto file_buffer = ctx.ReadBufferSpan(); + const auto file_buffer = ctx.ReadBuffer(); const std::string name = Common::StringFromBuffer(file_buffer); LOG_DEBUG(Service_FS, "called. directory={}", name); @@ -381,7 +381,7 @@ public: } void DeleteDirectoryRecursively(Kernel::HLERequestContext& ctx) { - const auto file_buffer = ctx.ReadBufferSpan(); + const auto file_buffer = ctx.ReadBuffer(); const std::string name = Common::StringFromBuffer(file_buffer); LOG_DEBUG(Service_FS, "called. directory={}", name); @@ -391,7 +391,7 @@ public: } void CleanDirectoryRecursively(Kernel::HLERequestContext& ctx) { - const auto file_buffer = ctx.ReadBufferSpan(); + const auto file_buffer = ctx.ReadBuffer(); const std::string name = Common::StringFromBuffer(file_buffer); LOG_DEBUG(Service_FS, "called. Directory: {}", name); @@ -401,8 +401,8 @@ public: } void RenameFile(Kernel::HLERequestContext& ctx) { - const std::string src_name = Common::StringFromBuffer(ctx.ReadBufferSpan(0)); - const std::string dst_name = Common::StringFromBuffer(ctx.ReadBufferSpan(1)); + const std::string src_name = Common::StringFromBuffer(ctx.ReadBuffer(0)); + const std::string dst_name = Common::StringFromBuffer(ctx.ReadBuffer(1)); LOG_DEBUG(Service_FS, "called. file '{}' to file '{}'", src_name, dst_name); @@ -413,7 +413,7 @@ public: void OpenFile(Kernel::HLERequestContext& ctx) { IPC::RequestParser rp{ctx}; - const auto file_buffer = ctx.ReadBufferSpan(); + const auto file_buffer = ctx.ReadBuffer(); const std::string name = Common::StringFromBuffer(file_buffer); const auto mode = static_cast(rp.Pop()); @@ -437,7 +437,7 @@ public: void OpenDirectory(Kernel::HLERequestContext& ctx) { IPC::RequestParser rp{ctx}; - const auto file_buffer = ctx.ReadBufferSpan(); + const auto file_buffer = ctx.ReadBuffer(); const std::string name = Common::StringFromBuffer(file_buffer); // TODO(Subv): Implement this filter. @@ -460,7 +460,7 @@ public: } void GetEntryType(Kernel::HLERequestContext& ctx) { - const auto file_buffer = ctx.ReadBufferSpan(); + const auto file_buffer = ctx.ReadBuffer(); const std::string name = Common::StringFromBuffer(file_buffer); LOG_DEBUG(Service_FS, "called. file={}", name); @@ -501,7 +501,7 @@ public: } void GetFileTimeStampRaw(Kernel::HLERequestContext& ctx) { - const auto file_buffer = ctx.ReadBufferSpan(); + const auto file_buffer = ctx.ReadBuffer(); const std::string name = Common::StringFromBuffer(file_buffer); LOG_WARNING(Service_FS, "(Partial Implementation) called. file={}", name); @@ -1083,7 +1083,7 @@ void FSP_SRV::GetGlobalAccessLogMode(Kernel::HLERequestContext& ctx) { } void FSP_SRV::OutputAccessLogToSdCard(Kernel::HLERequestContext& ctx) { - const auto raw = ctx.ReadBufferSpan(); + const auto raw = ctx.ReadBuffer(); auto log = Common::StringFromFixedZeroTerminatedBuffer( reinterpret_cast(raw.data()), raw.size()); diff --git a/src/core/hle/service/glue/notif.cpp b/src/core/hle/service/glue/notif.cpp index ee5c6d3a4..3ace2dabd 100644 --- a/src/core/hle/service/glue/notif.cpp +++ b/src/core/hle/service/glue/notif.cpp @@ -38,7 +38,7 @@ void NOTIF_A::RegisterAlarmSetting(Kernel::HLERequestContext& ctx) { "application_parameter_size is bigger than 0x400 bytes"); AlarmSetting new_alarm{}; - memcpy(&new_alarm, ctx.ReadBufferSpan(0).data(), sizeof(AlarmSetting)); + memcpy(&new_alarm, ctx.ReadBuffer(0).data(), sizeof(AlarmSetting)); // TODO: Count alarms per game id if (alarms.size() >= max_alarms) { @@ -73,7 +73,7 @@ void NOTIF_A::UpdateAlarmSetting(Kernel::HLERequestContext& ctx) { "application_parameter_size is bigger than 0x400 bytes"); AlarmSetting alarm_setting{}; - memcpy(&alarm_setting, ctx.ReadBufferSpan(0).data(), sizeof(AlarmSetting)); + memcpy(&alarm_setting, ctx.ReadBuffer(0).data(), sizeof(AlarmSetting)); const auto alarm_it = GetAlarmFromId(alarm_setting.alarm_setting_id); if (alarm_it != alarms.end()) { diff --git a/src/core/hle/service/hid/hid.cpp b/src/core/hle/service/hid/hid.cpp index 294fe927b..f15f1a6bb 100644 --- a/src/core/hle/service/hid/hid.cpp +++ b/src/core/hle/service/hid/hid.cpp @@ -1026,7 +1026,7 @@ void Hid::SetSupportedNpadIdType(Kernel::HLERequestContext& ctx) { const auto applet_resource_user_id{rp.Pop()}; applet_resource->GetController(HidController::NPad) - .SetSupportedNpadIdTypes(ctx.ReadBufferSpan()); + .SetSupportedNpadIdTypes(ctx.ReadBuffer()); LOG_DEBUG(Service_HID, "called, applet_resource_user_id={}", applet_resource_user_id); @@ -1564,8 +1564,8 @@ void Hid::SendVibrationValues(Kernel::HLERequestContext& ctx) { IPC::RequestParser rp{ctx}; const auto applet_resource_user_id{rp.Pop()}; - const auto handles = ctx.ReadBufferSpan(0); - const auto vibrations = ctx.ReadBufferSpan(1); + const auto handles = ctx.ReadBuffer(0); + const auto vibrations = ctx.ReadBuffer(1); std::vector vibration_device_handles( handles.size() / sizeof(Core::HID::VibrationDeviceHandle)); @@ -2104,7 +2104,7 @@ void Hid::WritePalmaRgbLedPatternEntry(Kernel::HLERequestContext& ctx) { const auto connection_handle{rp.PopRaw()}; const auto unknown{rp.Pop()}; - [[maybe_unused]] const auto buffer = ctx.ReadBufferSpan(); + [[maybe_unused]] const auto buffer = ctx.ReadBuffer(); LOG_WARNING(Service_HID, "(STUBBED) called, connection_handle={}, unknown={}", connection_handle.npad_id, unknown); diff --git a/src/core/hle/service/hid/hidbus.cpp b/src/core/hle/service/hid/hidbus.cpp index abc15c34e..e5e50845f 100644 --- a/src/core/hle/service/hid/hidbus.cpp +++ b/src/core/hle/service/hid/hidbus.cpp @@ -351,7 +351,7 @@ void HidBus::GetExternalDeviceId(Kernel::HLERequestContext& ctx) { void HidBus::SendCommandAsync(Kernel::HLERequestContext& ctx) { IPC::RequestParser rp{ctx}; - const auto data = ctx.ReadBufferSpan(); + const auto data = ctx.ReadBuffer(); const auto bus_handle_{rp.PopRaw()}; LOG_DEBUG(Service_HID, diff --git a/src/core/hle/service/jit/jit.cpp b/src/core/hle/service/jit/jit.cpp index 534639ff9..1295a44c7 100644 --- a/src/core/hle/service/jit/jit.cpp +++ b/src/core/hle/service/jit/jit.cpp @@ -62,7 +62,7 @@ public: const auto parameters{rp.PopRaw()}; // Optional input/output buffers - const auto input_buffer{ctx.CanReadBuffer() ? ctx.ReadBufferSpan() : std::span()}; + const auto input_buffer{ctx.CanReadBuffer() ? ctx.ReadBuffer() : std::span()}; std::vector output_buffer(ctx.CanWriteBuffer() ? ctx.GetWriteBufferSize() : 0); // Function call prototype: @@ -132,7 +132,7 @@ public: const auto command{rp.PopRaw()}; // Optional input/output buffers - const auto input_buffer{ctx.CanReadBuffer() ? ctx.ReadBufferSpan() : std::span()}; + const auto input_buffer{ctx.CanReadBuffer() ? ctx.ReadBuffer() : std::span()}; std::vector output_buffer(ctx.CanWriteBuffer() ? ctx.GetWriteBufferSize() : 0); // Function call prototype: @@ -176,7 +176,7 @@ public: IPC::RequestParser rp{ctx}; const auto tmem_size{rp.PopRaw()}; const auto tmem_handle{ctx.GetCopyHandle(0)}; - const auto nro_plugin{ctx.ReadBufferSpan(1)}; + const auto nro_plugin{ctx.ReadBuffer(1)}; if (tmem_size == 0) { LOG_ERROR(Service_JIT, "attempted to load plugin with empty transfer memory"); diff --git a/src/core/hle/service/ldn/ldn.cpp b/src/core/hle/service/ldn/ldn.cpp index ad097a6ef..e5099d61f 100644 --- a/src/core/hle/service/ldn/ldn.cpp +++ b/src/core/hle/service/ldn/ldn.cpp @@ -412,7 +412,7 @@ public: } void SetAdvertiseData(Kernel::HLERequestContext& ctx) { - const auto read_buffer = ctx.ReadBufferSpan(); + const auto read_buffer = ctx.ReadBuffer(); IPC::ResponseBuilder rb{ctx, 2}; rb.Push(lan_discovery.SetAdvertiseData(read_buffer)); @@ -464,7 +464,7 @@ public: parameters.security_config.passphrase_size, parameters.security_config.security_mode, parameters.local_communication_version); - const auto read_buffer = ctx.ReadBufferSpan(); + const auto read_buffer = ctx.ReadBuffer(); if (read_buffer.size() != sizeof(NetworkInfo)) { LOG_ERROR(Frontend, "NetworkInfo doesn't match read_buffer size!"); IPC::ResponseBuilder rb{ctx, 2}; diff --git a/src/core/hle/service/lm/lm.cpp b/src/core/hle/service/lm/lm.cpp index 0da461e6c..ef4b54046 100644 --- a/src/core/hle/service/lm/lm.cpp +++ b/src/core/hle/service/lm/lm.cpp @@ -94,7 +94,7 @@ public: private: void Log(Kernel::HLERequestContext& ctx) { std::size_t offset{}; - const auto data = ctx.ReadBufferSpan(); + const auto data = ctx.ReadBuffer(); // This function only succeeds - Get that out of the way IPC::ResponseBuilder rb{ctx, 2}; diff --git a/src/core/hle/service/nfc/mifare_user.cpp b/src/core/hle/service/nfc/mifare_user.cpp index 7d391c936..51523a3ae 100644 --- a/src/core/hle/service/nfc/mifare_user.cpp +++ b/src/core/hle/service/nfc/mifare_user.cpp @@ -168,7 +168,7 @@ void MFIUser::StopDetection(Kernel::HLERequestContext& ctx) { void MFIUser::Read(Kernel::HLERequestContext& ctx) { IPC::RequestParser rp{ctx}; const auto device_handle{rp.Pop()}; - const auto buffer{ctx.ReadBufferSpan()}; + const auto buffer{ctx.ReadBuffer()}; const auto number_of_commands{ctx.GetReadBufferNumElements()}; std::vector read_commands(number_of_commands); @@ -209,7 +209,7 @@ void MFIUser::Read(Kernel::HLERequestContext& ctx) { void MFIUser::Write(Kernel::HLERequestContext& ctx) { IPC::RequestParser rp{ctx}; const auto device_handle{rp.Pop()}; - const auto buffer{ctx.ReadBufferSpan()}; + const auto buffer{ctx.ReadBuffer()}; const auto number_of_commands{ctx.GetReadBufferNumElements()}; std::vector write_commands(number_of_commands); diff --git a/src/core/hle/service/nfc/nfc_user.cpp b/src/core/hle/service/nfc/nfc_user.cpp index 5dcf8a423..89aa6b3f5 100644 --- a/src/core/hle/service/nfc/nfc_user.cpp +++ b/src/core/hle/service/nfc/nfc_user.cpp @@ -325,7 +325,7 @@ void IUser::SendCommandByPassThrough(Kernel::HLERequestContext& ctx) { IPC::RequestParser rp{ctx}; const auto device_handle{rp.Pop()}; const auto timeout{rp.PopRaw()}; - const auto command_data{ctx.ReadBufferSpan()}; + const auto command_data{ctx.ReadBuffer()}; LOG_INFO(Service_NFC, "(STUBBED) called, device_handle={}, timeout={}, data_size={}", device_handle, timeout.ToSeconds(), command_data.size()); diff --git a/src/core/hle/service/nfp/nfp_user.cpp b/src/core/hle/service/nfp/nfp_user.cpp index 0a5606756..a4d3d1bc7 100644 --- a/src/core/hle/service/nfp/nfp_user.cpp +++ b/src/core/hle/service/nfp/nfp_user.cpp @@ -290,7 +290,7 @@ void IUser::GetApplicationArea(Kernel::HLERequestContext& ctx) { void IUser::SetApplicationArea(Kernel::HLERequestContext& ctx) { IPC::RequestParser rp{ctx}; const auto device_handle{rp.Pop()}; - const auto data{ctx.ReadBufferSpan()}; + const auto data{ctx.ReadBuffer()}; LOG_INFO(Service_NFP, "called, device_handle={}, data_size={}", device_handle, data.size()); if (state == State::NonInitialized) { @@ -370,7 +370,7 @@ void IUser::CreateApplicationArea(Kernel::HLERequestContext& ctx) { IPC::RequestParser rp{ctx}; const auto device_handle{rp.Pop()}; const auto access_id{rp.Pop()}; - const auto data{ctx.ReadBufferSpan()}; + const auto data{ctx.ReadBuffer()}; LOG_INFO(Service_NFP, "called, device_handle={}, data_size={}, access_id={}", device_handle, access_id, data.size()); @@ -637,7 +637,7 @@ void IUser::RecreateApplicationArea(Kernel::HLERequestContext& ctx) { IPC::RequestParser rp{ctx}; const auto device_handle{rp.Pop()}; const auto access_id{rp.Pop()}; - const auto data{ctx.ReadBufferSpan()}; + const auto data{ctx.ReadBuffer()}; LOG_INFO(Service_NFP, "called, device_handle={}, data_size={}, access_id={}", device_handle, access_id, data.size()); diff --git a/src/core/hle/service/ngct/ngct.cpp b/src/core/hle/service/ngct/ngct.cpp index bee62b054..8af8a835d 100644 --- a/src/core/hle/service/ngct/ngct.cpp +++ b/src/core/hle/service/ngct/ngct.cpp @@ -24,7 +24,7 @@ public: private: void Match(Kernel::HLERequestContext& ctx) { - const auto buffer = ctx.ReadBufferSpan(); + const auto buffer = ctx.ReadBuffer(); const auto text = Common::StringFromFixedZeroTerminatedBuffer( reinterpret_cast(buffer.data()), buffer.size()); @@ -37,7 +37,7 @@ private: } void Filter(Kernel::HLERequestContext& ctx) { - const auto buffer = ctx.ReadBufferSpan(); + const auto buffer = ctx.ReadBuffer(); const auto text = Common::StringFromFixedZeroTerminatedBuffer( reinterpret_cast(buffer.data()), buffer.size()); diff --git a/src/core/hle/service/nifm/nifm.cpp b/src/core/hle/service/nifm/nifm.cpp index a6446fdcc..4fa9f51a6 100644 --- a/src/core/hle/service/nifm/nifm.cpp +++ b/src/core/hle/service/nifm/nifm.cpp @@ -414,7 +414,7 @@ void IGeneralService::CreateTemporaryNetworkProfile(Kernel::HLERequestContext& c ASSERT_MSG(ctx.GetReadBufferSize() == 0x17c, "SfNetworkProfileData is not the correct size"); u128 uuid{}; - auto buffer = ctx.ReadBufferSpan(); + auto buffer = ctx.ReadBuffer(); std::memcpy(&uuid, buffer.data() + 8, sizeof(u128)); IPC::ResponseBuilder rb{ctx, 6, 0, 1}; diff --git a/src/core/hle/service/nvdrv/nvdrv_interface.cpp b/src/core/hle/service/nvdrv/nvdrv_interface.cpp index 39a4443a0..edbdfee43 100644 --- a/src/core/hle/service/nvdrv/nvdrv_interface.cpp +++ b/src/core/hle/service/nvdrv/nvdrv_interface.cpp @@ -27,7 +27,7 @@ void NVDRV::Open(Kernel::HLERequestContext& ctx) { return; } - const auto& buffer = ctx.ReadBufferSpan(); + const auto& buffer = ctx.ReadBuffer(); const std::string device_name(buffer.begin(), buffer.end()); if (device_name == "/dev/nvhost-prof-gpu") { @@ -64,7 +64,7 @@ void NVDRV::Ioctl1(Kernel::HLERequestContext& ctx) { // Check device std::vector output_buffer(ctx.GetWriteBufferSize(0)); - const auto input_buffer = ctx.ReadBufferSpan(0); + const auto input_buffer = ctx.ReadBuffer(0); const auto nv_result = nvdrv->Ioctl1(fd, command, input_buffer, output_buffer); if (command.is_out != 0) { @@ -88,8 +88,8 @@ void NVDRV::Ioctl2(Kernel::HLERequestContext& ctx) { return; } - const auto input_buffer = ctx.ReadBufferSpan(0); - const auto input_inlined_buffer = ctx.ReadBufferSpan(1); + const auto input_buffer = ctx.ReadBuffer(0); + const auto input_inlined_buffer = ctx.ReadBuffer(1); std::vector output_buffer(ctx.GetWriteBufferSize(0)); const auto nv_result = @@ -115,7 +115,7 @@ void NVDRV::Ioctl3(Kernel::HLERequestContext& ctx) { return; } - const auto input_buffer = ctx.ReadBufferSpan(0); + const auto input_buffer = ctx.ReadBuffer(0); std::vector output_buffer(ctx.GetWriteBufferSize(0)); std::vector output_buffer_inline(ctx.GetWriteBufferSize(1)); diff --git a/src/core/hle/service/nvflinger/buffer_queue_producer.cpp b/src/core/hle/service/nvflinger/buffer_queue_producer.cpp index abed92d06..bcbe05b0d 100644 --- a/src/core/hle/service/nvflinger/buffer_queue_producer.cpp +++ b/src/core/hle/service/nvflinger/buffer_queue_producer.cpp @@ -815,7 +815,7 @@ Status BufferQueueProducer::SetPreallocatedBuffer(s32 slot, void BufferQueueProducer::Transact(Kernel::HLERequestContext& ctx, TransactionId code, u32 flags) { Status status{Status::NoError}; - InputParcel parcel_in{ctx.ReadBufferSpan()}; + InputParcel parcel_in{ctx.ReadBuffer()}; OutputParcel parcel_out{}; switch (code) { diff --git a/src/core/hle/service/prepo/prepo.cpp b/src/core/hle/service/prepo/prepo.cpp index f6a141b2e..01040b32a 100644 --- a/src/core/hle/service/prepo/prepo.cpp +++ b/src/core/hle/service/prepo/prepo.cpp @@ -57,10 +57,10 @@ private: IPC::RequestParser rp{ctx}; const auto process_id = rp.PopRaw(); - const auto data1 = ctx.ReadBufferSpan(0); + const auto data1 = ctx.ReadBuffer(0); const auto data2 = [&ctx] { if (ctx.CanReadBuffer(1)) { - return ctx.ReadBufferSpan(1); + return ctx.ReadBuffer(1); } return std::span{}; @@ -84,10 +84,10 @@ private: const auto user_id = rp.PopRaw(); const auto process_id = rp.PopRaw(); - const auto data1 = ctx.ReadBufferSpan(0); + const auto data1 = ctx.ReadBuffer(0); const auto data2 = [&ctx] { if (ctx.CanReadBuffer(1)) { - return ctx.ReadBufferSpan(1); + return ctx.ReadBuffer(1); } return std::span{}; @@ -136,10 +136,10 @@ private: IPC::RequestParser rp{ctx}; const auto title_id = rp.PopRaw(); - const auto data1 = ctx.ReadBufferSpan(0); + const auto data1 = ctx.ReadBuffer(0); const auto data2 = [&ctx] { if (ctx.CanReadBuffer(1)) { - return ctx.ReadBufferSpan(1); + return ctx.ReadBuffer(1); } return std::span{}; @@ -160,10 +160,10 @@ private: const auto user_id = rp.PopRaw(); const auto title_id = rp.PopRaw(); - const auto data1 = ctx.ReadBufferSpan(0); + const auto data1 = ctx.ReadBuffer(0); const auto data2 = [&ctx] { if (ctx.CanReadBuffer(1)) { - return ctx.ReadBufferSpan(1); + return ctx.ReadBuffer(1); } return std::span{}; diff --git a/src/core/hle/service/set/set_sys.cpp b/src/core/hle/service/set/set_sys.cpp index f1ace8184..94c20edda 100644 --- a/src/core/hle/service/set/set_sys.cpp +++ b/src/core/hle/service/set/set_sys.cpp @@ -131,12 +131,12 @@ void SET_SYS::GetSettingsItemValueSize(Kernel::HLERequestContext& ctx) { // The category of the setting. This corresponds to the top-level keys of // system_settings.ini. - const auto setting_category_buf{ctx.ReadBufferSpan(0)}; + const auto setting_category_buf{ctx.ReadBuffer(0)}; const std::string setting_category{setting_category_buf.begin(), setting_category_buf.end()}; // The name of the setting. This corresponds to the second-level keys of // system_settings.ini. - const auto setting_name_buf{ctx.ReadBufferSpan(1)}; + const auto setting_name_buf{ctx.ReadBuffer(1)}; const std::string setting_name{setting_name_buf.begin(), setting_name_buf.end()}; auto settings{GetSettings()}; @@ -156,12 +156,12 @@ void SET_SYS::GetSettingsItemValue(Kernel::HLERequestContext& ctx) { // The category of the setting. This corresponds to the top-level keys of // system_settings.ini. - const auto setting_category_buf{ctx.ReadBufferSpan(0)}; + const auto setting_category_buf{ctx.ReadBuffer(0)}; const std::string setting_category{setting_category_buf.begin(), setting_category_buf.end()}; // The name of the setting. This corresponds to the second-level keys of // system_settings.ini. - const auto setting_name_buf{ctx.ReadBufferSpan(1)}; + const auto setting_name_buf{ctx.ReadBuffer(1)}; const std::string setting_name{setting_name_buf.begin(), setting_name_buf.end()}; auto settings{GetSettings()}; diff --git a/src/core/hle/service/sockets/bsd.cpp b/src/core/hle/service/sockets/bsd.cpp index 119d6ba5b..bdb499268 100644 --- a/src/core/hle/service/sockets/bsd.cpp +++ b/src/core/hle/service/sockets/bsd.cpp @@ -186,7 +186,7 @@ void BSD::Poll(Kernel::HLERequestContext& ctx) { ExecuteWork(ctx, PollWork{ .nfds = nfds, .timeout = timeout, - .read_buffer = ctx.ReadBufferSpan(), + .read_buffer = ctx.ReadBuffer(), .write_buffer = std::vector(ctx.GetWriteBufferSize()), }); } @@ -208,7 +208,7 @@ void BSD::Bind(Kernel::HLERequestContext& ctx) { const s32 fd = rp.Pop(); LOG_DEBUG(Service, "called. fd={} addrlen={}", fd, ctx.GetReadBufferSize()); - BuildErrnoResponse(ctx, BindImpl(fd, ctx.ReadBufferSpan())); + BuildErrnoResponse(ctx, BindImpl(fd, ctx.ReadBuffer())); } void BSD::Connect(Kernel::HLERequestContext& ctx) { @@ -219,7 +219,7 @@ void BSD::Connect(Kernel::HLERequestContext& ctx) { ExecuteWork(ctx, ConnectWork{ .fd = fd, - .addr = ctx.ReadBufferSpan(), + .addr = ctx.ReadBuffer(), }); } @@ -311,7 +311,7 @@ void BSD::SetSockOpt(Kernel::HLERequestContext& ctx) { const u32 level = rp.Pop(); const OptName optname = static_cast(rp.Pop()); - const auto buffer = ctx.ReadBufferSpan(); + const auto buffer = ctx.ReadBuffer(); const u8* optval = buffer.empty() ? nullptr : buffer.data(); size_t optlen = buffer.size(); @@ -382,7 +382,7 @@ void BSD::Send(Kernel::HLERequestContext& ctx) { ExecuteWork(ctx, SendWork{ .fd = fd, .flags = flags, - .message = ctx.ReadBufferSpan(), + .message = ctx.ReadBuffer(), }); } @@ -397,8 +397,8 @@ void BSD::SendTo(Kernel::HLERequestContext& ctx) { ExecuteWork(ctx, SendToWork{ .fd = fd, .flags = flags, - .message = ctx.ReadBufferSpan(0), - .addr = ctx.ReadBufferSpan(1), + .message = ctx.ReadBuffer(0), + .addr = ctx.ReadBuffer(1), }); } @@ -411,7 +411,7 @@ void BSD::Write(Kernel::HLERequestContext& ctx) { ExecuteWork(ctx, SendWork{ .fd = fd, .flags = 0, - .message = ctx.ReadBufferSpan(), + .message = ctx.ReadBuffer(), }); } diff --git a/src/core/hle/service/sockets/sfdnsres.cpp b/src/core/hle/service/sockets/sfdnsres.cpp index 6d0e1dd6c..e96eda7f3 100644 --- a/src/core/hle/service/sockets/sfdnsres.cpp +++ b/src/core/hle/service/sockets/sfdnsres.cpp @@ -199,10 +199,10 @@ static std::pair GetAddrInfoRequestImpl(Kernel::HLERequestContext& ctx "called with ignored parameters: use_nsd_resolve={}, unknown={}, process_id={}", parameters.use_nsd_resolve, parameters.unknown, parameters.process_id); - const auto host_buffer = ctx.ReadBufferSpan(0); + const auto host_buffer = ctx.ReadBuffer(0); const std::string host = Common::StringFromBuffer(host_buffer); - const auto service_buffer = ctx.ReadBufferSpan(1); + const auto service_buffer = ctx.ReadBuffer(1); const std::string service = Common::StringFromBuffer(service_buffer); addrinfo* addrinfo; diff --git a/src/core/hle/service/ssl/ssl.cpp b/src/core/hle/service/ssl/ssl.cpp index 10851f08f..dcf47083f 100644 --- a/src/core/hle/service/ssl/ssl.cpp +++ b/src/core/hle/service/ssl/ssl.cpp @@ -101,7 +101,7 @@ private: void ImportServerPki(Kernel::HLERequestContext& ctx) { IPC::RequestParser rp{ctx}; const auto certificate_format = rp.PopEnum(); - [[maybe_unused]] const auto pkcs_12_certificates = ctx.ReadBufferSpan(0); + [[maybe_unused]] const auto pkcs_12_certificates = ctx.ReadBuffer(0); constexpr u64 server_id = 0; @@ -113,10 +113,10 @@ private: } void ImportClientPki(Kernel::HLERequestContext& ctx) { - [[maybe_unused]] const auto pkcs_12_certificate = ctx.ReadBufferSpan(0); + [[maybe_unused]] const auto pkcs_12_certificate = ctx.ReadBuffer(0); [[maybe_unused]] const auto ascii_password = [&ctx] { if (ctx.CanReadBuffer(1)) { - return ctx.ReadBufferSpan(1); + return ctx.ReadBuffer(1); } return std::span{}; diff --git a/src/core/hle/service/time/time.cpp b/src/core/hle/service/time/time.cpp index 9376e0902..f77cdbb43 100644 --- a/src/core/hle/service/time/time.cpp +++ b/src/core/hle/service/time/time.cpp @@ -328,8 +328,8 @@ void Module::Interface::CalculateStandardUserSystemClockDifferenceByUser( Clock::ClockSnapshot snapshot_a; Clock::ClockSnapshot snapshot_b; - const auto snapshot_a_data = ctx.ReadBufferSpan(0); - const auto snapshot_b_data = ctx.ReadBufferSpan(1); + const auto snapshot_a_data = ctx.ReadBuffer(0); + const auto snapshot_b_data = ctx.ReadBuffer(1); std::memcpy(&snapshot_a, snapshot_a_data.data(), sizeof(Clock::ClockSnapshot)); std::memcpy(&snapshot_b, snapshot_b_data.data(), sizeof(Clock::ClockSnapshot)); @@ -355,8 +355,8 @@ void Module::Interface::CalculateSpanBetween(Kernel::HLERequestContext& ctx) { Clock::ClockSnapshot snapshot_a; Clock::ClockSnapshot snapshot_b; - const auto snapshot_a_data = ctx.ReadBufferSpan(0); - const auto snapshot_b_data = ctx.ReadBufferSpan(1); + const auto snapshot_a_data = ctx.ReadBuffer(0); + const auto snapshot_b_data = ctx.ReadBuffer(1); std::memcpy(&snapshot_a, snapshot_a_data.data(), sizeof(Clock::ClockSnapshot)); std::memcpy(&snapshot_b, snapshot_b_data.data(), sizeof(Clock::ClockSnapshot)); diff --git a/src/core/hle/service/time/time_zone_service.cpp b/src/core/hle/service/time/time_zone_service.cpp index 6d05a66f1..961040bfc 100644 --- a/src/core/hle/service/time/time_zone_service.cpp +++ b/src/core/hle/service/time/time_zone_service.cpp @@ -84,7 +84,7 @@ void ITimeZoneService::ToCalendarTime(Kernel::HLERequestContext& ctx) { LOG_DEBUG(Service_Time, "called, posix_time=0x{:016X}", posix_time); TimeZone::TimeZoneRule time_zone_rule{}; - const auto buffer{ctx.ReadBufferSpan()}; + const auto buffer{ctx.ReadBuffer()}; std::memcpy(&time_zone_rule, buffer.data(), buffer.size()); TimeZone::CalendarInfo calendar_info{}; @@ -128,7 +128,7 @@ void ITimeZoneService::ToPosixTime(Kernel::HLERequestContext& ctx) { IPC::RequestParser rp{ctx}; const auto calendar_time{rp.PopRaw()}; TimeZone::TimeZoneRule time_zone_rule{}; - std::memcpy(&time_zone_rule, ctx.ReadBufferSpan().data(), sizeof(TimeZone::TimeZoneRule)); + std::memcpy(&time_zone_rule, ctx.ReadBuffer().data(), sizeof(TimeZone::TimeZoneRule)); s64 posix_time{}; if (const Result result{time_zone_content_manager.GetTimeZoneManager().ToPosixTime( -- cgit v1.2.3 From b0722591c9b8c1aed5b8bfc5e67e7e957b08f209 Mon Sep 17 00:00:00 2001 From: ameerj <52414509+ameerj@users.noreply.github.com> Date: Wed, 28 Dec 2022 18:24:57 -0500 Subject: hle_ipc: Use thread_local ReadBuffer --- src/core/hle/kernel/hle_ipc.cpp | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) (limited to 'src/core/hle/kernel') diff --git a/src/core/hle/kernel/hle_ipc.cpp b/src/core/hle/kernel/hle_ipc.cpp index f6654f56c..494151eef 100644 --- a/src/core/hle/kernel/hle_ipc.cpp +++ b/src/core/hle/kernel/hle_ipc.cpp @@ -11,6 +11,7 @@ #include "common/common_funcs.h" #include "common/common_types.h" #include "common/logging/log.h" +#include "common/scratch_buffer.h" #include "core/hle/ipc_helpers.h" #include "core/hle/kernel/hle_ipc.h" #include "core/hle/kernel/k_auto_object.h" @@ -346,20 +347,29 @@ std::vector HLERequestContext::ReadBufferCopy(std::size_t buffer_index) cons } std::span HLERequestContext::ReadBuffer(std::size_t buffer_index) const { + static thread_local std::array, 2> read_buffer_a; + static thread_local std::array, 2> read_buffer_x; + const bool is_buffer_a{BufferDescriptorA().size() > buffer_index && BufferDescriptorA()[buffer_index].Size()}; if (is_buffer_a) { ASSERT_OR_EXECUTE_MSG( BufferDescriptorA().size() > buffer_index, { return {}; }, "BufferDescriptorA invalid buffer_index {}", buffer_index); - const u8* const mem_ptr = memory.GetPointer(BufferDescriptorA()[buffer_index].Address()); - return std::span(mem_ptr, BufferDescriptorA()[buffer_index].Size()); + auto& read_buffer = read_buffer_a[buffer_index]; + read_buffer.resize_destructive(BufferDescriptorA()[buffer_index].Size()); + memory.ReadBlock(BufferDescriptorA()[buffer_index].Address(), read_buffer.data(), + read_buffer.size()); + return read_buffer; } else { ASSERT_OR_EXECUTE_MSG( BufferDescriptorX().size() > buffer_index, { return {}; }, "BufferDescriptorX invalid buffer_index {}", buffer_index); - const u8* const mem_ptr = memory.GetPointer(BufferDescriptorX()[buffer_index].Address()); - return std::span(mem_ptr, BufferDescriptorX()[buffer_index].Size()); + auto& read_buffer = read_buffer_x[buffer_index]; + read_buffer.resize_destructive(BufferDescriptorX()[buffer_index].Size()); + memory.ReadBlock(BufferDescriptorX()[buffer_index].Address(), read_buffer.data(), + read_buffer.size()); + return read_buffer; } } -- cgit v1.2.3