diff options
Diffstat (limited to 'src/core/hle/service')
53 files changed, 418 insertions, 255 deletions
diff --git a/src/core/hle/service/am/am.cpp b/src/core/hle/service/am/am.cpp index 408e441dc..234173297 100644 --- a/src/core/hle/service/am/am.cpp +++ b/src/core/hle/service/am/am.cpp @@ -833,7 +833,7 @@ IStorageImpl::~IStorageImpl() = default; class StorageDataImpl final : public IStorageImpl { public: - explicit StorageDataImpl(std::vector<u8>&& buffer) : buffer{std::move(buffer)} {} + explicit StorageDataImpl(std::vector<u8>&& buffer_) : buffer{std::move(buffer_)} {} std::vector<u8>& GetData() override { return buffer; @@ -1513,9 +1513,9 @@ void IApplicationFunctions::GetDisplayVersion(Kernel::HLERequestContext& ctx) { const FileSys::PatchManager pm{title_id, system.GetFileSystemController(), system.GetContentProvider()}; - auto res = pm.GetControlMetadata(); - if (res.first != nullptr) { - return res; + auto metadata = pm.GetControlMetadata(); + if (metadata.first != nullptr) { + return metadata; } const FileSys::PatchManager pm_update{FileSys::GetUpdateTitleID(title_id), @@ -1550,9 +1550,9 @@ void IApplicationFunctions::GetDesiredLanguage(Kernel::HLERequestContext& ctx) { const FileSys::PatchManager pm{title_id, system.GetFileSystemController(), system.GetContentProvider()}; - auto res = pm.GetControlMetadata(); - if (res.first != nullptr) { - return res; + auto metadata = pm.GetControlMetadata(); + if (metadata.first != nullptr) { + return metadata; } const FileSys::PatchManager pm_update{FileSys::GetUpdateTitleID(title_id), diff --git a/src/core/hle/service/apm/controller.cpp b/src/core/hle/service/apm/controller.cpp index 00c174bb0..8bfa7c0e4 100644 --- a/src/core/hle/service/apm/controller.cpp +++ b/src/core/hle/service/apm/controller.cpp @@ -15,11 +15,11 @@ namespace Service::APM { constexpr auto DEFAULT_PERFORMANCE_CONFIGURATION = PerformanceConfiguration::Config7; -Controller::Controller(Core::Timing::CoreTiming& core_timing) - : core_timing{core_timing}, configs{ - {PerformanceMode::Handheld, DEFAULT_PERFORMANCE_CONFIGURATION}, - {PerformanceMode::Docked, DEFAULT_PERFORMANCE_CONFIGURATION}, - } {} +Controller::Controller(Core::Timing::CoreTiming& core_timing_) + : core_timing{core_timing_}, configs{ + {PerformanceMode::Handheld, DEFAULT_PERFORMANCE_CONFIGURATION}, + {PerformanceMode::Docked, DEFAULT_PERFORMANCE_CONFIGURATION}, + } {} Controller::~Controller() = default; diff --git a/src/core/hle/service/apm/controller.h b/src/core/hle/service/apm/controller.h index af0c4cd34..8d48e0104 100644 --- a/src/core/hle/service/apm/controller.h +++ b/src/core/hle/service/apm/controller.h @@ -50,7 +50,7 @@ enum class PerformanceMode : u8 { // system during times of high load -- this simply maps to different PerformanceConfigs to use. class Controller { public: - explicit Controller(Core::Timing::CoreTiming& core_timing); + explicit Controller(Core::Timing::CoreTiming& core_timing_); ~Controller(); void SetPerformanceConfiguration(PerformanceMode mode, PerformanceConfiguration config); diff --git a/src/core/hle/service/audio/audren_u.cpp b/src/core/hle/service/audio/audren_u.cpp index 513bd3730..ae4284adf 100644 --- a/src/core/hle/service/audio/audren_u.cpp +++ b/src/core/hle/service/audio/audren_u.cpp @@ -169,10 +169,9 @@ private: class IAudioDevice final : public ServiceFramework<IAudioDevice> { public: - explicit IAudioDevice(Core::System& system_, u32_le revision_num) - : ServiceFramework{system_, "IAudioDevice"}, revision{revision_num}, - buffer_event{system.Kernel()}, audio_input_device_switch_event{system.Kernel()}, - audio_output_device_switch_event{system.Kernel()} { + explicit IAudioDevice(Core::System& system_, Kernel::KEvent& buffer_event_, u32_le revision_) + : ServiceFramework{system_, "IAudioDevice"}, buffer_event{buffer_event_}, revision{ + revision_} { static const FunctionInfo functions[] = { {0, &IAudioDevice::ListAudioDeviceName, "ListAudioDeviceName"}, {1, &IAudioDevice::SetAudioDeviceOutputVolume, "SetAudioDeviceOutputVolume"}, @@ -189,18 +188,6 @@ public: {13, nullptr, "GetAudioSystemMasterVolumeSetting"}, }; RegisterHandlers(functions); - - Kernel::KAutoObject::Create(std::addressof(buffer_event)); - buffer_event.Initialize("IAudioOutBufferReleasedEvent"); - - // Should be similar to audio_output_device_switch_event - Kernel::KAutoObject::Create(std::addressof(audio_input_device_switch_event)); - audio_input_device_switch_event.Initialize("IAudioDevice:AudioInputDeviceSwitchedEvent"); - - // Should only be signalled when an audio output device has been changed, example: speaker - // to headset - Kernel::KAutoObject::Create(std::addressof(audio_output_device_switch_event)); - audio_output_device_switch_event.Initialize("IAudioDevice:AudioOutputDeviceSwitchedEvent"); } private: @@ -310,7 +297,7 @@ private: IPC::ResponseBuilder rb{ctx, 2, 1}; rb.Push(RESULT_SUCCESS); - rb.PushCopyObjects(audio_input_device_switch_event.GetReadableEvent()); + rb.PushCopyObjects(buffer_event.GetReadableEvent()); } void QueryAudioDeviceOutputEvent(Kernel::HLERequestContext& ctx) { @@ -318,17 +305,16 @@ private: IPC::ResponseBuilder rb{ctx, 2, 1}; rb.Push(RESULT_SUCCESS); - rb.PushCopyObjects(audio_output_device_switch_event.GetReadableEvent()); + rb.PushCopyObjects(buffer_event.GetReadableEvent()); } + Kernel::KEvent& buffer_event; u32_le revision = 0; - Kernel::KEvent buffer_event; - Kernel::KEvent audio_input_device_switch_event; - Kernel::KEvent audio_output_device_switch_event; +}; -}; // namespace Audio +AudRenU::AudRenU(Core::System& system_) + : ServiceFramework{system_, "audren:u"}, buffer_event{system.Kernel()} { -AudRenU::AudRenU(Core::System& system_) : ServiceFramework{system_, "audren:u"} { // clang-format off static const FunctionInfo functions[] = { {0, &AudRenU::OpenAudioRenderer, "OpenAudioRenderer"}, @@ -340,6 +326,9 @@ AudRenU::AudRenU(Core::System& system_) : ServiceFramework{system_, "audren:u"} // clang-format on RegisterHandlers(functions); + + Kernel::KAutoObject::Create(std::addressof(buffer_event)); + buffer_event.Initialize("IAudioOutBufferReleasedEvent"); } AudRenU::~AudRenU() = default; @@ -373,7 +362,7 @@ void AudRenU::GetAudioRendererWorkBufferSize(Kernel::HLERequestContext& ctx) { static constexpr u64 max_perf_detail_entries = 100; // Size of the data structure representing the bulk of the voice-related state. - static constexpr u64 voice_state_size = 0x100; + static constexpr u64 voice_state_size_bytes = 0x100; // Size of the upsampler manager data structure constexpr u64 upsampler_manager_size = 0x48; @@ -460,7 +449,8 @@ void AudRenU::GetAudioRendererWorkBufferSize(Kernel::HLERequestContext& ctx) { size += Common::AlignUp(voice_info_size * params.voice_count, info_field_alignment_size); size += Common::AlignUp(voice_resource_size * params.voice_count, info_field_alignment_size); - size += Common::AlignUp(voice_state_size * params.voice_count, info_field_alignment_size); + size += + Common::AlignUp(voice_state_size_bytes * params.voice_count, info_field_alignment_size); return size; }; @@ -662,7 +652,7 @@ void AudRenU::GetAudioDeviceService(Kernel::HLERequestContext& ctx) { // always assumes the initial release revision (REV1). IPC::ResponseBuilder rb{ctx, 2, 0, 1}; rb.Push(RESULT_SUCCESS); - rb.PushIpcInterface<IAudioDevice>(system, Common::MakeMagic('R', 'E', 'V', '1')); + rb.PushIpcInterface<IAudioDevice>(system, buffer_event, Common::MakeMagic('R', 'E', 'V', '1')); } void AudRenU::OpenAudioRendererForManualExecution(Kernel::HLERequestContext& ctx) { @@ -684,7 +674,7 @@ void AudRenU::GetAudioDeviceServiceWithRevisionInfo(Kernel::HLERequestContext& c IPC::ResponseBuilder rb{ctx, 2, 0, 1}; rb.Push(RESULT_SUCCESS); - rb.PushIpcInterface<IAudioDevice>(system, revision); + rb.PushIpcInterface<IAudioDevice>(system, buffer_event, revision); } void AudRenU::OpenAudioRendererImpl(Kernel::HLERequestContext& ctx) { diff --git a/src/core/hle/service/audio/audren_u.h b/src/core/hle/service/audio/audren_u.h index 37e8b4716..0ee6f9542 100644 --- a/src/core/hle/service/audio/audren_u.h +++ b/src/core/hle/service/audio/audren_u.h @@ -4,6 +4,7 @@ #pragma once +#include "core/hle/kernel/k_event.h" #include "core/hle/service/service.h" namespace Core { @@ -31,6 +32,7 @@ private: void OpenAudioRendererImpl(Kernel::HLERequestContext& ctx); std::size_t audren_instance_count = 0; + Kernel::KEvent buffer_event; }; // Describes a particular audio feature that may be supported in a particular revision. diff --git a/src/core/hle/service/audio/hwopus.cpp b/src/core/hle/service/audio/hwopus.cpp index 19c578b3a..ee5ec8cd6 100644 --- a/src/core/hle/service/audio/hwopus.cpp +++ b/src/core/hle/service/audio/hwopus.cpp @@ -50,8 +50,8 @@ public: Enabled, }; - explicit OpusDecoderState(OpusDecoderPtr decoder, u32 sample_rate, u32 channel_count) - : decoder{std::move(decoder)}, sample_rate{sample_rate}, channel_count{channel_count} {} + explicit OpusDecoderState(OpusDecoderPtr decoder_, u32 sample_rate_, u32 channel_count_) + : decoder{std::move(decoder_)}, sample_rate{sample_rate_}, channel_count{channel_count_} {} // Decodes interleaved Opus packets. Optionally allows reporting time taken to // perform the decoding, as well as any relevant extra behavior. @@ -160,9 +160,9 @@ private: class IHardwareOpusDecoderManager final : public ServiceFramework<IHardwareOpusDecoderManager> { public: - explicit IHardwareOpusDecoderManager(Core::System& system_, OpusDecoderState decoder_state) + explicit IHardwareOpusDecoderManager(Core::System& system_, OpusDecoderState decoder_state_) : ServiceFramework{system_, "IHardwareOpusDecoderManager"}, decoder_state{ - std::move(decoder_state)} { + std::move(decoder_state_)} { // clang-format off static const FunctionInfo functions[] = { {0, &IHardwareOpusDecoderManager::DecodeInterleavedOld, "DecodeInterleavedOld"}, diff --git a/src/core/hle/service/bcat/backend/boxcat.cpp b/src/core/hle/service/bcat/backend/boxcat.cpp index cee1774d1..d6d2f52e5 100644 --- a/src/core/hle/service/bcat/backend/boxcat.cpp +++ b/src/core/hle/service/bcat/backend/boxcat.cpp @@ -3,9 +3,18 @@ // Refer to the license.txt file included. #include <fmt/ostream.h> + +#ifdef __GNUC__ +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wshadow" +#endif #include <httplib.h> #include <mbedtls/sha256.h> #include <nlohmann/json.hpp> +#ifdef __GNUC__ +#pragma GCC diagnostic pop +#endif + #include "common/hex_util.h" #include "common/logging/backend.h" #include "common/logging/log.h" @@ -178,8 +187,8 @@ bool VfsRawCopyDProgress(FileSys::VirtualDir src, FileSys::VirtualDir dest, class Boxcat::Client { public: - Client(std::string path, u64 title_id, u64 build_id) - : path(std::move(path)), title_id(title_id), build_id(build_id) {} + Client(std::string path_, u64 title_id_, u64 build_id_) + : path(std::move(path_)), title_id(title_id_), build_id(build_id_) {} DownloadResult DownloadDataZip() { return DownloadInternal(fmt::format(BOXCAT_PATHNAME_DATA, title_id), TIMEOUT_SECONDS, diff --git a/src/core/hle/service/hid/controllers/controller_base.cpp b/src/core/hle/service/hid/controllers/controller_base.cpp index 8091db9d7..9d1e6db6a 100644 --- a/src/core/hle/service/hid/controllers/controller_base.cpp +++ b/src/core/hle/service/hid/controllers/controller_base.cpp @@ -6,7 +6,7 @@ namespace Service::HID { -ControllerBase::ControllerBase(Core::System& system) : system(system) {} +ControllerBase::ControllerBase(Core::System& system_) : system(system_) {} ControllerBase::~ControllerBase() = default; void ControllerBase::ActivateController() { diff --git a/src/core/hle/service/hid/controllers/controller_base.h b/src/core/hle/service/hid/controllers/controller_base.h index f47a9e61c..1556fb08e 100644 --- a/src/core/hle/service/hid/controllers/controller_base.h +++ b/src/core/hle/service/hid/controllers/controller_base.h @@ -18,7 +18,7 @@ class System; namespace Service::HID { class ControllerBase { public: - explicit ControllerBase(Core::System& system); + explicit ControllerBase(Core::System& system_); virtual ~ControllerBase(); // Called when the controller is initialized diff --git a/src/core/hle/service/hid/controllers/gesture.cpp b/src/core/hle/service/hid/controllers/gesture.cpp index 9e5df3bb7..d311f754b 100644 --- a/src/core/hle/service/hid/controllers/gesture.cpp +++ b/src/core/hle/service/hid/controllers/gesture.cpp @@ -23,7 +23,7 @@ constexpr f32 Square(s32 num) { return static_cast<f32>(num * num); } -Controller_Gesture::Controller_Gesture(Core::System& system) : ControllerBase(system) {} +Controller_Gesture::Controller_Gesture(Core::System& system_) : ControllerBase(system_) {} Controller_Gesture::~Controller_Gesture() = default; void Controller_Gesture::OnInit() { @@ -211,15 +211,16 @@ void Controller_Gesture::UpdateExistingGesture(GestureProperties& gesture, Touch } } -void Controller_Gesture::EndGesture(GestureProperties& gesture, GestureProperties& last_gesture, - TouchType& type, Attribute& attributes, f32 time_difference) { +void Controller_Gesture::EndGesture(GestureProperties& gesture, + GestureProperties& last_gesture_props, TouchType& type, + Attribute& attributes, f32 time_difference) { const auto& last_entry = shared_memory.gesture_states[(shared_memory.header.last_entry_index + 16) % 17]; - if (last_gesture.active_points != 0) { + if (last_gesture_props.active_points != 0) { switch (last_entry.type) { case TouchType::Touch: if (enable_press_and_tap) { - SetTapEvent(gesture, last_gesture, type, attributes); + SetTapEvent(gesture, last_gesture_props, type, attributes); return; } type = TouchType::Cancel; @@ -234,7 +235,7 @@ void Controller_Gesture::EndGesture(GestureProperties& gesture, GesturePropertie force_update = true; break; case TouchType::Pan: - EndPanEvent(gesture, last_gesture, type, time_difference); + EndPanEvent(gesture, last_gesture_props, type, time_difference); break; default: break; @@ -246,10 +247,11 @@ void Controller_Gesture::EndGesture(GestureProperties& gesture, GesturePropertie } } -void Controller_Gesture::SetTapEvent(GestureProperties& gesture, GestureProperties& last_gesture, - TouchType& type, Attribute& attributes) { +void Controller_Gesture::SetTapEvent(GestureProperties& gesture, + GestureProperties& last_gesture_props, TouchType& type, + Attribute& attributes) { type = TouchType::Tap; - gesture = last_gesture; + gesture = last_gesture_props; force_update = true; f32 tap_time_difference = static_cast<f32>(last_update_timestamp - last_tap_timestamp) / (1000 * 1000 * 1000); @@ -259,8 +261,9 @@ void Controller_Gesture::SetTapEvent(GestureProperties& gesture, GestureProperti } } -void Controller_Gesture::UpdatePanEvent(GestureProperties& gesture, GestureProperties& last_gesture, - TouchType& type, f32 time_difference) { +void Controller_Gesture::UpdatePanEvent(GestureProperties& gesture, + GestureProperties& last_gesture_props, TouchType& type, + f32 time_difference) { auto& cur_entry = shared_memory.gesture_states[shared_memory.header.last_entry_index]; const auto& last_entry = shared_memory.gesture_states[(shared_memory.header.last_entry_index + 16) % 17]; @@ -272,13 +275,14 @@ void Controller_Gesture::UpdatePanEvent(GestureProperties& gesture, GesturePrope last_pan_time_difference = time_difference; // Promote to pinch type - if (std::abs(gesture.average_distance - last_gesture.average_distance) > pinch_threshold) { + if (std::abs(gesture.average_distance - last_gesture_props.average_distance) > + pinch_threshold) { type = TouchType::Pinch; - cur_entry.scale = gesture.average_distance / last_gesture.average_distance; + cur_entry.scale = gesture.average_distance / last_gesture_props.average_distance; } - const f32 angle_between_two_lines = std::atan((gesture.angle - last_gesture.angle) / - (1 + (gesture.angle * last_gesture.angle))); + const f32 angle_between_two_lines = std::atan((gesture.angle - last_gesture_props.angle) / + (1 + (gesture.angle * last_gesture_props.angle))); // Promote to rotate type if (std::abs(angle_between_two_lines) > angle_threshold) { type = TouchType::Rotate; @@ -287,8 +291,9 @@ void Controller_Gesture::UpdatePanEvent(GestureProperties& gesture, GesturePrope } } -void Controller_Gesture::EndPanEvent(GestureProperties& gesture, GestureProperties& last_gesture, - TouchType& type, f32 time_difference) { +void Controller_Gesture::EndPanEvent(GestureProperties& gesture, + GestureProperties& last_gesture_props, TouchType& type, + f32 time_difference) { auto& cur_entry = shared_memory.gesture_states[shared_memory.header.last_entry_index]; const auto& last_entry = shared_memory.gesture_states[(shared_memory.header.last_entry_index + 16) % 17]; @@ -301,7 +306,7 @@ void Controller_Gesture::EndPanEvent(GestureProperties& gesture, GestureProperti // Set swipe event with parameters if (curr_vel > swipe_threshold) { - SetSwipeEvent(gesture, last_gesture, type); + SetSwipeEvent(gesture, last_gesture_props, type); return; } @@ -312,13 +317,13 @@ void Controller_Gesture::EndPanEvent(GestureProperties& gesture, GestureProperti force_update = true; } -void Controller_Gesture::SetSwipeEvent(GestureProperties& gesture, GestureProperties& last_gesture, - TouchType& type) { +void Controller_Gesture::SetSwipeEvent(GestureProperties& gesture, + GestureProperties& last_gesture_props, TouchType& type) { auto& cur_entry = shared_memory.gesture_states[shared_memory.header.last_entry_index]; const auto& last_entry = shared_memory.gesture_states[(shared_memory.header.last_entry_index + 16) % 17]; type = TouchType::Swipe; - gesture = last_gesture; + gesture = last_gesture_props; force_update = true; cur_entry.delta_x = last_entry.delta_x; cur_entry.delta_y = last_entry.delta_y; diff --git a/src/core/hle/service/hid/controllers/gesture.h b/src/core/hle/service/hid/controllers/gesture.h index 18110a6ad..f46e29411 100644 --- a/src/core/hle/service/hid/controllers/gesture.h +++ b/src/core/hle/service/hid/controllers/gesture.h @@ -128,32 +128,34 @@ private: void UpdateExistingGesture(GestureProperties& gesture, TouchType& type, f32 time_difference); // Terminates exiting gesture - void EndGesture(GestureProperties& gesture, GestureProperties& last_gesture, TouchType& type, - Attribute& attributes, f32 time_difference); + void EndGesture(GestureProperties& gesture, GestureProperties& last_gesture_props, + TouchType& type, Attribute& attributes, f32 time_difference); // Set current event to a tap event - void SetTapEvent(GestureProperties& gesture, GestureProperties& last_gesture, TouchType& type, - Attribute& attributes); + void SetTapEvent(GestureProperties& gesture, GestureProperties& last_gesture_props, + TouchType& type, Attribute& attributes); // Calculates and set the extra parameters related to a pan event - void UpdatePanEvent(GestureProperties& gesture, GestureProperties& last_gesture, + void UpdatePanEvent(GestureProperties& gesture, GestureProperties& last_gesture_props, TouchType& type, f32 time_difference); // Terminates the pan event - void EndPanEvent(GestureProperties& gesture, GestureProperties& last_gesture, TouchType& type, - f32 time_difference); + void EndPanEvent(GestureProperties& gesture, GestureProperties& last_gesture_props, + TouchType& type, f32 time_difference); // Set current event to a swipe event - void SetSwipeEvent(GestureProperties& gesture, GestureProperties& last_gesture, + void SetSwipeEvent(GestureProperties& gesture, GestureProperties& last_gesture_props, TouchType& type); - // Returns an unused finger id, if there is no fingers avaliable MAX_FINGERS will be returned + // Returns an unused finger id, if there is no fingers available std::nullopt is returned. std::optional<size_t> GetUnusedFingerID() const; - /** If the touch is new it tries to assing a new finger id, if there is no fingers avaliable no + /** + * If the touch is new it tries to assign a new finger id, if there is no fingers available no * changes will be made. Updates the coordinates if the finger id it's already set. If the touch * ends delays the output by one frame to set the end_touch flag before finally freeing the - * finger id */ + * finger id + */ size_t UpdateTouchInputEvent(const std::tuple<float, float, bool>& touch_input, size_t finger_id); diff --git a/src/core/hle/service/mii/manager.h b/src/core/hle/service/mii/manager.h index 2106a528a..ec7efa5f7 100644 --- a/src/core/hle/service/mii/manager.h +++ b/src/core/hle/service/mii/manager.h @@ -89,7 +89,7 @@ static_assert(std::has_unique_object_representations_v<MiiInfo>, #pragma pack(push, 4) struct MiiInfoElement { - MiiInfoElement(const MiiInfo& info, Source source) : info{info}, source{source} {} + MiiInfoElement(const MiiInfo& info_, Source source_) : info{info_}, source{source_} {} MiiInfo info{}; Source source{}; diff --git a/src/core/hle/service/mii/mii.cpp b/src/core/hle/service/mii/mii.cpp index 26be9e45b..81f150a88 100644 --- a/src/core/hle/service/mii/mii.cpp +++ b/src/core/hle/service/mii/mii.cpp @@ -253,8 +253,8 @@ private: class MiiDBModule final : public ServiceFramework<MiiDBModule> { public: - explicit MiiDBModule(Core::System& system_, const char* name) - : ServiceFramework{system_, name} { + explicit MiiDBModule(Core::System& system_, const char* name_) + : ServiceFramework{system_, name_} { // clang-format off static const FunctionInfo functions[] = { {0, &MiiDBModule::GetDatabaseService, "GetDatabaseService"}, diff --git a/src/core/hle/service/nifm/nifm.cpp b/src/core/hle/service/nifm/nifm.cpp index 94ef3983a..76e3832df 100644 --- a/src/core/hle/service/nifm/nifm.cpp +++ b/src/core/hle/service/nifm/nifm.cpp @@ -368,7 +368,7 @@ private: }, }; - IPC::ResponseBuilder rb{ctx, 2 + sizeof(IpConfigInfo) / sizeof(u32)}; + IPC::ResponseBuilder rb{ctx, 2 + (sizeof(IpConfigInfo) + 3) / sizeof(u32)}; rb.Push(RESULT_SUCCESS); rb.PushRaw<IpConfigInfo>(ip_config_info); } diff --git a/src/core/hle/service/nvdrv/devices/nvdevice.h b/src/core/hle/service/nvdrv/devices/nvdevice.h index b37f023df..5b73a5a34 100644 --- a/src/core/hle/service/nvdrv/devices/nvdevice.h +++ b/src/core/hle/service/nvdrv/devices/nvdevice.h @@ -21,7 +21,7 @@ namespace Service::Nvidia::Devices { /// implement the ioctl interface. class nvdevice { public: - explicit nvdevice(Core::System& system) : system{system} {} + explicit nvdevice(Core::System& system_) : system{system_} {} virtual ~nvdevice() = default; /** diff --git a/src/core/hle/service/nvdrv/devices/nvdisp_disp0.cpp b/src/core/hle/service/nvdrv/devices/nvdisp_disp0.cpp index bbef04a29..2cc0da124 100644 --- a/src/core/hle/service/nvdrv/devices/nvdisp_disp0.cpp +++ b/src/core/hle/service/nvdrv/devices/nvdisp_disp0.cpp @@ -52,7 +52,6 @@ void nvdisp_disp0::flip(u32 buffer_handle, u32 offset, u32 format, u32 width, u3 addr, offset, width, height, stride, static_cast<PixelFormat>(format), transform, crop_rect}; - system.GetPerfStats().EndGameFrame(); system.GetPerfStats().EndSystemFrame(); system.GPU().SwapBuffers(&framebuffer); system.FrameLimiter().DoFrameLimiting(system.CoreTiming().GetGlobalTimeUs()); diff --git a/src/core/hle/service/nvdrv/devices/nvhost_as_gpu.h b/src/core/hle/service/nvdrv/devices/nvhost_as_gpu.h index 229bf6350..24e3151cb 100644 --- a/src/core/hle/service/nvdrv/devices/nvhost_as_gpu.h +++ b/src/core/hle/service/nvdrv/devices/nvhost_as_gpu.h @@ -48,13 +48,13 @@ private: public: constexpr BufferMap() = default; - constexpr BufferMap(GPUVAddr start_addr, std::size_t size) - : start_addr{start_addr}, end_addr{start_addr + size} {} + constexpr BufferMap(GPUVAddr start_addr_, std::size_t size_) + : start_addr{start_addr_}, end_addr{start_addr_ + size_} {} - constexpr BufferMap(GPUVAddr start_addr, std::size_t size, VAddr cpu_addr, - bool is_allocated) - : start_addr{start_addr}, end_addr{start_addr + size}, cpu_addr{cpu_addr}, - is_allocated{is_allocated} {} + constexpr BufferMap(GPUVAddr start_addr_, std::size_t size_, VAddr cpu_addr_, + bool is_allocated_) + : start_addr{start_addr_}, end_addr{start_addr_ + size_}, cpu_addr{cpu_addr_}, + is_allocated{is_allocated_} {} constexpr VAddr StartAddr() const { return start_addr; diff --git a/src/core/hle/service/nvdrv/devices/nvhost_nvdec_common.h b/src/core/hle/service/nvdrv/devices/nvhost_nvdec_common.h index 14d0d210a..da10f5f41 100644 --- a/src/core/hle/service/nvdrv/devices/nvhost_nvdec_common.h +++ b/src/core/hle/service/nvdrv/devices/nvhost_nvdec_common.h @@ -27,13 +27,13 @@ protected: public: constexpr BufferMap() = default; - constexpr BufferMap(GPUVAddr start_addr, std::size_t size) - : start_addr{start_addr}, end_addr{start_addr + size} {} + constexpr BufferMap(GPUVAddr start_addr_, std::size_t size_) + : start_addr{start_addr_}, end_addr{start_addr_ + size_} {} - constexpr BufferMap(GPUVAddr start_addr, std::size_t size, VAddr cpu_addr, - bool is_allocated) - : start_addr{start_addr}, end_addr{start_addr + size}, cpu_addr{cpu_addr}, - is_allocated{is_allocated} {} + constexpr BufferMap(GPUVAddr start_addr_, std::size_t size_, VAddr cpu_addr_, + bool is_allocated_) + : start_addr{start_addr_}, end_addr{start_addr_ + size_}, cpu_addr{cpu_addr_}, + is_allocated{is_allocated_} {} constexpr VAddr StartAddr() const { return start_addr; diff --git a/src/core/hle/service/nvdrv/syncpoint_manager.cpp b/src/core/hle/service/nvdrv/syncpoint_manager.cpp index 0151a03b7..3b6f55526 100644 --- a/src/core/hle/service/nvdrv/syncpoint_manager.cpp +++ b/src/core/hle/service/nvdrv/syncpoint_manager.cpp @@ -8,7 +8,7 @@ namespace Service::Nvidia { -SyncpointManager::SyncpointManager(Tegra::GPU& gpu) : gpu{gpu} {} +SyncpointManager::SyncpointManager(Tegra::GPU& gpu_) : gpu{gpu_} {} SyncpointManager::~SyncpointManager() = default; diff --git a/src/core/hle/service/nvdrv/syncpoint_manager.h b/src/core/hle/service/nvdrv/syncpoint_manager.h index d395c5d0b..99f286474 100644 --- a/src/core/hle/service/nvdrv/syncpoint_manager.h +++ b/src/core/hle/service/nvdrv/syncpoint_manager.h @@ -18,7 +18,7 @@ namespace Service::Nvidia { class SyncpointManager final { public: - explicit SyncpointManager(Tegra::GPU& gpu); + explicit SyncpointManager(Tegra::GPU& gpu_); ~SyncpointManager(); /** diff --git a/src/core/hle/service/nvflinger/buffer_queue.cpp b/src/core/hle/service/nvflinger/buffer_queue.cpp index 0b6e7430b..59ddf6298 100644 --- a/src/core/hle/service/nvflinger/buffer_queue.cpp +++ b/src/core/hle/service/nvflinger/buffer_queue.cpp @@ -13,8 +13,8 @@ namespace Service::NVFlinger { -BufferQueue::BufferQueue(Kernel::KernelCore& kernel, u32 id, u64 layer_id) - : id(id), layer_id(layer_id), buffer_wait_event{kernel} { +BufferQueue::BufferQueue(Kernel::KernelCore& kernel, u32 id_, u64 layer_id_) + : id(id_), layer_id(layer_id_), buffer_wait_event{kernel} { Kernel::KAutoObject::Create(std::addressof(buffer_wait_event)); buffer_wait_event.Initialize("BufferQueue:WaitEvent"); } diff --git a/src/core/hle/service/nvflinger/buffer_queue.h b/src/core/hle/service/nvflinger/buffer_queue.h index 4ec0b1506..61e337ac5 100644 --- a/src/core/hle/service/nvflinger/buffer_queue.h +++ b/src/core/hle/service/nvflinger/buffer_queue.h @@ -54,7 +54,7 @@ public: NativeWindowFormat = 2, }; - explicit BufferQueue(Kernel::KernelCore& kernel, u32 id, u64 layer_id); + explicit BufferQueue(Kernel::KernelCore& kernel, u32 id_, u64 layer_id_); ~BufferQueue(); enum class BufferTransformFlags : u32 { diff --git a/src/core/hle/service/nvflinger/nvflinger.cpp b/src/core/hle/service/nvflinger/nvflinger.cpp index 7fb9133c7..d1dbc659b 100644 --- a/src/core/hle/service/nvflinger/nvflinger.cpp +++ b/src/core/hle/service/nvflinger/nvflinger.cpp @@ -61,7 +61,7 @@ void NVFlinger::SplitVSync() { } } -NVFlinger::NVFlinger(Core::System& system) : system(system) { +NVFlinger::NVFlinger(Core::System& system_) : system(system_) { displays.emplace_back(0, "Default", system); displays.emplace_back(1, "External", system); displays.emplace_back(2, "Edid", system); @@ -139,11 +139,15 @@ std::optional<u64> NVFlinger::CreateLayer(u64 display_id) { } const u64 layer_id = next_layer_id++; + CreateLayerAtId(*display, layer_id); + return layer_id; +} + +void NVFlinger::CreateLayerAtId(VI::Display& display, u64 layer_id) { const u32 buffer_queue_id = next_buffer_queue_id++; buffer_queues.emplace_back( std::make_unique<BufferQueue>(system.Kernel(), buffer_queue_id, layer_id)); - display->CreateLayer(layer_id, *buffer_queues.back()); - return layer_id; + display.CreateLayer(layer_id, *buffer_queues.back()); } void NVFlinger::CloseLayer(u64 layer_id) { @@ -154,9 +158,9 @@ void NVFlinger::CloseLayer(u64 layer_id) { } } -std::optional<u32> NVFlinger::FindBufferQueueId(u64 display_id, u64 layer_id) const { +std::optional<u32> NVFlinger::FindBufferQueueId(u64 display_id, u64 layer_id) { const auto lock_guard = Lock(); - const auto* const layer = FindLayer(display_id, layer_id); + const auto* const layer = FindOrCreateLayer(display_id, layer_id); if (layer == nullptr) { return std::nullopt; @@ -232,6 +236,24 @@ const VI::Layer* NVFlinger::FindLayer(u64 display_id, u64 layer_id) const { return display->FindLayer(layer_id); } +VI::Layer* NVFlinger::FindOrCreateLayer(u64 display_id, u64 layer_id) { + auto* const display = FindDisplay(display_id); + + if (display == nullptr) { + return nullptr; + } + + auto* layer = display->FindLayer(layer_id); + + if (layer == nullptr) { + LOG_DEBUG(Service, "Layer at id {} not found. Trying to create it.", layer_id); + CreateLayerAtId(*display, layer_id); + return display->FindLayer(layer_id); + } + + return layer; +} + void NVFlinger::Compose() { for (auto& display : displays) { // Trigger vsync for this display at the end of drawing diff --git a/src/core/hle/service/nvflinger/nvflinger.h b/src/core/hle/service/nvflinger/nvflinger.h index b0febdaec..d80fd07ef 100644 --- a/src/core/hle/service/nvflinger/nvflinger.h +++ b/src/core/hle/service/nvflinger/nvflinger.h @@ -45,7 +45,7 @@ class BufferQueue; class NVFlinger final { public: - explicit NVFlinger(Core::System& system); + explicit NVFlinger(Core::System& system_); ~NVFlinger(); /// Sets the NVDrv module instance to use to send buffers to the GPU. @@ -67,7 +67,7 @@ public: /// Finds the buffer queue ID of the specified layer in the specified display. /// /// If an invalid display ID or layer ID is provided, then an empty optional is returned. - [[nodiscard]] std::optional<u32> FindBufferQueueId(u64 display_id, u64 layer_id) const; + [[nodiscard]] std::optional<u32> FindBufferQueueId(u64 display_id, u64 layer_id); /// Gets the vsync event for the specified display. /// @@ -100,6 +100,14 @@ private: /// Finds the layer identified by the specified ID in the desired display. [[nodiscard]] const VI::Layer* FindLayer(u64 display_id, u64 layer_id) const; + /// Finds the layer identified by the specified ID in the desired display, + /// or creates the layer if it is not found. + /// To be used when the system expects the specified ID to already exist. + [[nodiscard]] VI::Layer* FindOrCreateLayer(u64 display_id, u64 layer_id); + + /// Creates a layer with the specified layer ID in the desired display. + void CreateLayerAtId(VI::Display& display, u64 layer_id); + static void VSyncThread(NVFlinger& nv_flinger); void SplitVSync(); diff --git a/src/core/hle/service/pctl/pctl.cpp b/src/core/hle/service/pctl/pctl.cpp index e4d155c86..908e0a1e3 100644 --- a/src/core/hle/service/pctl/pctl.cpp +++ b/src/core/hle/service/pctl/pctl.cpp @@ -7,8 +7,8 @@ namespace Service::PCTL { PCTL::PCTL(Core::System& system_, std::shared_ptr<Module> module_, const char* name, - Capability capability) - : Interface{system_, std::move(module_), name, capability} { + Capability capability_) + : Interface{system_, std::move(module_), name, capability_} { static const FunctionInfo functions[] = { {0, &PCTL::CreateService, "CreateService"}, {1, &PCTL::CreateServiceWithoutInitialize, "CreateServiceWithoutInitialize"}, diff --git a/src/core/hle/service/pctl/pctl.h b/src/core/hle/service/pctl/pctl.h index fd0a1e486..ea3b97823 100644 --- a/src/core/hle/service/pctl/pctl.h +++ b/src/core/hle/service/pctl/pctl.h @@ -15,7 +15,7 @@ namespace Service::PCTL { class PCTL final : public Module::Interface { public: explicit PCTL(Core::System& system_, std::shared_ptr<Module> module_, const char* name, - Capability capability); + Capability capability_); ~PCTL() override; }; diff --git a/src/core/hle/service/pm/pm.cpp b/src/core/hle/service/pm/pm.cpp index f4715935d..a43185c44 100644 --- a/src/core/hle/service/pm/pm.cpp +++ b/src/core/hle/service/pm/pm.cpp @@ -31,8 +31,8 @@ std::optional<Kernel::KProcess*> SearchProcessList( void GetApplicationPidGeneric(Kernel::HLERequestContext& ctx, const std::vector<Kernel::KProcess*>& process_list) { - const auto process = SearchProcessList(process_list, [](const auto& process) { - return process->GetProcessID() == Kernel::KProcess::ProcessIDMin; + const auto process = SearchProcessList(process_list, [](const auto& proc) { + return proc->GetProcessID() == Kernel::KProcess::ProcessIDMin; }); IPC::ResponseBuilder rb{ctx, 4}; @@ -100,8 +100,8 @@ private: LOG_DEBUG(Service_PM, "called, title_id={:016X}", title_id); const auto process = - SearchProcessList(kernel.GetProcessList(), [title_id](const auto& process) { - return process->GetTitleID() == title_id; + SearchProcessList(kernel.GetProcessList(), [title_id](const auto& proc) { + return proc->GetTitleID() == title_id; }); if (!process.has_value()) { @@ -140,8 +140,8 @@ private: LOG_DEBUG(Service_PM, "called, process_id={:016X}", process_id); - const auto process = SearchProcessList(process_list, [process_id](const auto& process) { - return process->GetProcessID() == process_id; + const auto process = SearchProcessList(process_list, [process_id](const auto& proc) { + return proc->GetProcessID() == process_id; }); if (!process.has_value()) { diff --git a/src/core/hle/service/service.cpp b/src/core/hle/service/service.cpp index 00e683c2f..fa61a5c7b 100644 --- a/src/core/hle/service/service.cpp +++ b/src/core/hle/service/service.cpp @@ -107,21 +107,22 @@ void ServiceFrameworkBase::InstallAsService(SM::ServiceManager& service_manager) ASSERT(!port_installed); auto port = service_manager.RegisterService(service_name, max_sessions).Unwrap(); - port->SetHleHandler(shared_from_this()); + port->SetSessionHandler(shared_from_this()); port_installed = true; } -void ServiceFrameworkBase::InstallAsNamedPort(Kernel::KernelCore& kernel) { +Kernel::KClientPort& ServiceFrameworkBase::CreatePort(Kernel::KernelCore& kernel) { const auto guard = LockService(); ASSERT(!port_installed); auto* port = Kernel::KPort::Create(kernel); port->Initialize(max_sessions, false, service_name); - port->GetServerPort().SetHleHandler(shared_from_this()); - kernel.AddNamedPort(service_name, &port->GetClientPort()); + port->GetServerPort().SetSessionHandler(shared_from_this()); port_installed = true; + + return port->GetClientPort(); } void ServiceFrameworkBase::RegisterHandlersBase(const FunctionInfoBase* functions, std::size_t n) { @@ -132,6 +133,16 @@ void ServiceFrameworkBase::RegisterHandlersBase(const FunctionInfoBase* function } } +void ServiceFrameworkBase::RegisterHandlersBaseTipc(const FunctionInfoBase* functions, + std::size_t n) { + handlers_tipc.reserve(handlers_tipc.size() + n); + for (std::size_t i = 0; i < n; ++i) { + // Usually this array is sorted by id already, so hint to insert at the end + handlers_tipc.emplace_hint(handlers_tipc.cend(), functions[i].expected_header, + functions[i]); + } +} + void ServiceFrameworkBase::ReportUnimplementedFunction(Kernel::HLERequestContext& ctx, const FunctionInfoBase* info) { auto cmd_buf = ctx.CommandBuffer(); @@ -166,33 +177,55 @@ void ServiceFrameworkBase::InvokeRequest(Kernel::HLERequestContext& ctx) { handler_invoker(this, info->handler_callback, ctx); } -ResultCode ServiceFrameworkBase::HandleSyncRequest(Kernel::HLERequestContext& context) { +void ServiceFrameworkBase::InvokeRequestTipc(Kernel::HLERequestContext& ctx) { + boost::container::flat_map<u32, FunctionInfoBase>::iterator itr; + + itr = handlers_tipc.find(ctx.GetCommand()); + + const FunctionInfoBase* info = itr == handlers_tipc.end() ? nullptr : &itr->second; + if (info == nullptr || info->handler_callback == nullptr) { + return ReportUnimplementedFunction(ctx, info); + } + + LOG_TRACE(Service, "{}", MakeFunctionString(info->name, GetServiceName(), ctx.CommandBuffer())); + handler_invoker(this, info->handler_callback, ctx); +} + +ResultCode ServiceFrameworkBase::HandleSyncRequest(Kernel::KServerSession& session, + Kernel::HLERequestContext& ctx) { const auto guard = LockService(); - switch (context.GetCommandType()) { - case IPC::CommandType::Close: { - IPC::ResponseBuilder rb{context, 2}; + switch (ctx.GetCommandType()) { + case IPC::CommandType::Close: + case IPC::CommandType::TIPC_Close: { + session.Close(); + IPC::ResponseBuilder rb{ctx, 2}; rb.Push(RESULT_SUCCESS); return IPC::ERR_REMOTE_PROCESS_DEAD; } case IPC::CommandType::ControlWithContext: case IPC::CommandType::Control: { - system.ServiceManager().InvokeControlRequest(context); + system.ServiceManager().InvokeControlRequest(ctx); break; } case IPC::CommandType::RequestWithContext: case IPC::CommandType::Request: { - InvokeRequest(context); + InvokeRequest(ctx); break; } default: - UNIMPLEMENTED_MSG("command_type={}", context.GetCommandType()); + if (ctx.IsTipc()) { + InvokeRequestTipc(ctx); + break; + } + + UNIMPLEMENTED_MSG("command_type={}", ctx.GetCommandType()); } // If emulation was shutdown, we are closing service threads, do not write the response back to // memory that may be shutting down as well. if (system.IsPoweredOn()) { - context.WriteToOutgoingCommandBuffer(context.GetThread()); + ctx.WriteToOutgoingCommandBuffer(ctx.GetThread()); } return RESULT_SUCCESS; @@ -207,7 +240,7 @@ Services::Services(std::shared_ptr<SM::ServiceManager>& sm, Core::System& system system.GetFileSystemController().CreateFactories(*system.GetFilesystem(), false); - SM::ServiceManager::InstallInterfaces(sm, system); + system.Kernel().RegisterNamedService("sm:", SM::ServiceManager::InterfaceFactory); Account::InstallInterfaces(system); AM::InstallInterfaces(*sm, *nv_flinger, system); diff --git a/src/core/hle/service/service.h b/src/core/hle/service/service.h index 884951428..4c048173b 100644 --- a/src/core/hle/service/service.h +++ b/src/core/hle/service/service.h @@ -21,7 +21,9 @@ class System; namespace Kernel { class HLERequestContext; -} +class KClientPort; +class KServerSession; +} // namespace Kernel namespace Service { @@ -64,12 +66,19 @@ public: /// Creates a port pair and registers this service with the given ServiceManager. void InstallAsService(SM::ServiceManager& service_manager); - /// Creates a port pair and registers it on the kernel's global port registry. - void InstallAsNamedPort(Kernel::KernelCore& kernel); - /// Invokes a service request routine. + + /// Invokes a service request routine using the HIPC protocol. void InvokeRequest(Kernel::HLERequestContext& ctx); + + /// Invokes a service request routine using the HIPC protocol. + void InvokeRequestTipc(Kernel::HLERequestContext& ctx); + + /// Creates a port pair and registers it on the kernel's global port registry. + Kernel::KClientPort& CreatePort(Kernel::KernelCore& kernel); + /// Handles a synchronization request for the service. - ResultCode HandleSyncRequest(Kernel::HLERequestContext& context) override; + ResultCode HandleSyncRequest(Kernel::KServerSession& session, + Kernel::HLERequestContext& context) override; protected: /// Member-function pointer type of SyncRequest handlers. @@ -102,6 +111,7 @@ private: ~ServiceFrameworkBase() override; void RegisterHandlersBase(const FunctionInfoBase* functions, std::size_t n); + void RegisterHandlersBaseTipc(const FunctionInfoBase* functions, std::size_t n); void ReportUnimplementedFunction(Kernel::HLERequestContext& ctx, const FunctionInfoBase* info); /// Identifier string used to connect to the service. @@ -116,6 +126,7 @@ private: /// Function used to safely up-cast pointers to the derived class before invoking a handler. InvokerFn* handler_invoker; boost::container::flat_map<u32, FunctionInfoBase> handlers; + boost::container::flat_map<u32, FunctionInfoBase> handlers_tipc; /// Used to gain exclusive access to the service members, e.g. from CoreTiming thread. Common::SpinLock lock_service; @@ -144,17 +155,17 @@ protected: /** * Constructs a FunctionInfo for a function. * - * @param expected_header request header in the command buffer which will trigger dispatch + * @param expected_header_ request header in the command buffer which will trigger dispatch * to this handler - * @param handler_callback member function in this service which will be called to handle + * @param handler_callback_ member function in this service which will be called to handle * the request - * @param name human-friendly name for the request. Used mostly for logging purposes. + * @param name_ human-friendly name for the request. Used mostly for logging purposes. */ - FunctionInfo(u32 expected_header, HandlerFnP<Self> handler_callback, const char* name) + FunctionInfo(u32 expected_header_, HandlerFnP<Self> handler_callback_, const char* name_) : FunctionInfoBase{ - expected_header, + expected_header_, // Type-erase member function pointer by casting it down to the base class. - static_cast<HandlerFnP<ServiceFrameworkBase>>(handler_callback), name} {} + static_cast<HandlerFnP<ServiceFrameworkBase>>(handler_callback_), name_} {} }; /** @@ -183,6 +194,20 @@ protected: RegisterHandlersBase(functions, n); } + /// Registers handlers in the service. + template <std::size_t N> + void RegisterHandlersTipc(const FunctionInfo (&functions)[N]) { + RegisterHandlersTipc(functions, N); + } + + /** + * Registers handlers in the service. Usually prefer using the other RegisterHandlers + * overload in order to avoid needing to specify the array size. + */ + void RegisterHandlersTipc(const FunctionInfo* functions, std::size_t n) { + RegisterHandlersBaseTipc(functions, n); + } + private: /** * This function is used to allow invocation of pointers to handlers stored in the base class diff --git a/src/core/hle/service/sm/controller.cpp b/src/core/hle/service/sm/controller.cpp index ee026e22f..147f12147 100644 --- a/src/core/hle/service/sm/controller.cpp +++ b/src/core/hle/service/sm/controller.cpp @@ -4,8 +4,13 @@ #include "common/assert.h" #include "common/logging/log.h" +#include "core/core.h" #include "core/hle/ipc_helpers.h" +#include "core/hle/kernel/k_client_port.h" #include "core/hle/kernel/k_client_session.h" +#include "core/hle/kernel/k_port.h" +#include "core/hle/kernel/k_scoped_resource_reservation.h" +#include "core/hle/kernel/k_server_port.h" #include "core/hle/kernel/k_server_session.h" #include "core/hle/kernel/k_session.h" #include "core/hle/service/sm/controller.h" @@ -13,7 +18,7 @@ namespace Service::SM { void Controller::ConvertCurrentObjectToDomain(Kernel::HLERequestContext& ctx) { - ASSERT_MSG(ctx.Session()->IsSession(), "Session is already a domain"); + ASSERT_MSG(!ctx.Session()->IsDomain(), "Session is already a domain"); LOG_DEBUG(Service, "called, server_session={}", ctx.Session()->GetId()); ctx.Session()->ConvertToDomain(); @@ -26,15 +31,43 @@ void Controller::CloneCurrentObject(Kernel::HLERequestContext& ctx) { // TODO(bunnei): This is just creating a new handle to the same Session. I assume this is wrong // and that we probably want to actually make an entirely new Session, but we still need to // verify this on hardware. + LOG_DEBUG(Service, "called"); + auto& kernel = system.Kernel(); + auto* session = ctx.Session()->GetParent(); + auto* port = session->GetParent()->GetParent(); + + // Reserve a new session from the process resource limit. + Kernel::KScopedResourceReservation session_reservation( + kernel.CurrentProcess()->GetResourceLimit(), Kernel::LimitableResource::Sessions); + if (!session_reservation.Succeeded()) { + IPC::ResponseBuilder rb{ctx, 2}; + rb.Push(Kernel::ResultLimitReached); + } + + // Create a new session. + auto* clone = Kernel::KSession::Create(kernel); + clone->Initialize(&port->GetClientPort(), session->GetName()); + + // Commit the session reservation. + session_reservation.Commit(); + + // Enqueue the session with the named port. + port->EnqueueSession(&clone->GetServerSession()); + + // Set the session request manager. + clone->GetServerSession().SetSessionRequestManager( + session->GetServerSession().GetSessionRequestManager()); + + // We succeeded. IPC::ResponseBuilder rb{ctx, 2, 0, 1, IPC::ResponseBuilder::Flags::AlwaysMoveHandles}; rb.Push(RESULT_SUCCESS); - rb.PushMoveObjects(ctx.Session()->GetParent()->GetClientSession()); + rb.PushMoveObjects(clone->GetClientSession()); } void Controller::CloneCurrentObjectEx(Kernel::HLERequestContext& ctx) { - LOG_WARNING(Service, "(STUBBED) called, using CloneCurrentObject"); + LOG_DEBUG(Service, "called"); CloneCurrentObject(ctx); } @@ -44,7 +77,7 @@ void Controller::QueryPointerBufferSize(Kernel::HLERequestContext& ctx) { IPC::ResponseBuilder rb{ctx, 3}; rb.Push(RESULT_SUCCESS); - rb.Push<u16>(0x1000); + rb.Push<u16>(0x8000); } // https://switchbrew.org/wiki/IPC_Marshalling diff --git a/src/core/hle/service/sm/sm.cpp b/src/core/hle/service/sm/sm.cpp index 568effbc9..a9bc7da74 100644 --- a/src/core/hle/service/sm/sm.cpp +++ b/src/core/hle/service/sm/sm.cpp @@ -9,6 +9,7 @@ #include "core/hle/kernel/k_client_port.h" #include "core/hle/kernel/k_client_session.h" #include "core/hle/kernel/k_port.h" +#include "core/hle/kernel/k_scoped_resource_reservation.h" #include "core/hle/kernel/k_server_port.h" #include "core/hle/kernel/k_server_session.h" #include "core/hle/kernel/k_session.h" @@ -18,6 +19,7 @@ namespace Service::SM { +constexpr ResultCode ERR_NOT_INITIALIZED(ErrorModule::SM, 2); constexpr ResultCode ERR_ALREADY_REGISTERED(ErrorModule::SM, 4); constexpr ResultCode ERR_INVALID_NAME(ErrorModule::SM, 6); constexpr ResultCode ERR_SERVICE_NOT_REGISTERED(ErrorModule::SM, 7); @@ -34,20 +36,17 @@ static ResultCode ValidateServiceName(const std::string& name) { LOG_ERROR(Service_SM, "Invalid service name! service={}", name); return ERR_INVALID_NAME; } - if (name.rfind('\0') != std::string::npos) { - LOG_ERROR(Service_SM, "A non null terminated service was passed"); - return ERR_INVALID_NAME; - } return RESULT_SUCCESS; } -void ServiceManager::InstallInterfaces(std::shared_ptr<ServiceManager> self, Core::System& system) { - ASSERT(self->sm_interface.expired()); +Kernel::KClientPort& ServiceManager::InterfaceFactory(ServiceManager& self, Core::System& system) { + ASSERT(self.sm_interface.expired()); auto sm = std::make_shared<SM>(self, system); - sm->InstallAsNamedPort(system.Kernel()); - self->sm_interface = sm; - self->controller_interface = std::make_unique<Controller>(system); + self.sm_interface = sm; + self.controller_interface = std::make_unique<Controller>(system); + + return sm->CreatePort(system.Kernel()); } ResultVal<Kernel::KServerPort*> ServiceManager::RegisterService(std::string name, @@ -107,52 +106,81 @@ SM::~SM() = default; void SM::Initialize(Kernel::HLERequestContext& ctx) { LOG_DEBUG(Service_SM, "called"); + is_initialized = true; + IPC::ResponseBuilder rb{ctx, 2}; rb.Push(RESULT_SUCCESS); } void SM::GetService(Kernel::HLERequestContext& ctx) { - IPC::RequestParser rp{ctx}; + auto result = GetServiceImpl(ctx); + if (result.Succeeded()) { + IPC::ResponseBuilder rb{ctx, 2, 0, 1, IPC::ResponseBuilder::Flags::AlwaysMoveHandles}; + rb.Push(result.Code()); + rb.PushMoveObjects(result.Unwrap()); + } else { + IPC::ResponseBuilder rb{ctx, 2}; + rb.Push(result.Code()); + } +} + +void SM::GetServiceTipc(Kernel::HLERequestContext& ctx) { + auto result = GetServiceImpl(ctx); + IPC::ResponseBuilder rb{ctx, 2, 0, 1, IPC::ResponseBuilder::Flags::AlwaysMoveHandles}; + rb.Push(result.Code()); + rb.PushMoveObjects(result.Succeeded() ? result.Unwrap() : nullptr); +} + +static std::string PopServiceName(IPC::RequestParser& rp) { auto name_buf = rp.PopRaw<std::array<char, 8>>(); - auto end = std::find(name_buf.begin(), name_buf.end(), '\0'); + std::string result; + for (const auto& c : name_buf) { + if (c >= ' ' && c <= '~') { + result.push_back(c); + } + } + return result; +} + +ResultVal<Kernel::KClientSession*> SM::GetServiceImpl(Kernel::HLERequestContext& ctx) { + if (!is_initialized) { + return ERR_NOT_INITIALIZED; + } - std::string name(name_buf.begin(), end); + IPC::RequestParser rp{ctx}; + std::string name(PopServiceName(rp)); - auto result = service_manager->GetServicePort(name); + // Find the named port. + auto result = service_manager.GetServicePort(name); if (result.Failed()) { - IPC::ResponseBuilder rb{ctx, 2}; - rb.Push(result.Code()); LOG_ERROR(Service_SM, "called service={} -> error 0x{:08X}", name, result.Code().raw); - if (name.length() == 0) - return; // LibNX Fix - UNIMPLEMENTED(); - return; + return result.Code(); } - auto* port = result.Unwrap(); + // Reserve a new session from the process resource limit. + Kernel::KScopedResourceReservation session_reservation( + kernel.CurrentProcess()->GetResourceLimit(), Kernel::LimitableResource::Sessions); + R_UNLESS(session_reservation.Succeeded(), Kernel::ResultLimitReached); + + // Create a new session. auto* session = Kernel::KSession::Create(kernel); session->Initialize(&port->GetClientPort(), std::move(name)); - if (port->GetServerPort().GetHLEHandler()) { - port->GetServerPort().GetHLEHandler()->ClientConnected(&session->GetServerSession()); - } else { - port->EnqueueSession(&session->GetServerSession()); - } + // Commit the session reservation. + session_reservation.Commit(); + + // Enqueue the session with the named port. + port->EnqueueSession(&session->GetServerSession()); LOG_DEBUG(Service_SM, "called service={} -> session={}", name, session->GetId()); - IPC::ResponseBuilder rb{ctx, 2, 0, 1, IPC::ResponseBuilder::Flags::AlwaysMoveHandles}; - rb.Push(RESULT_SUCCESS); - rb.PushMoveObjects(session->GetClientSession()); + + return MakeResult(&session->GetClientSession()); } void SM::RegisterService(Kernel::HLERequestContext& ctx) { IPC::RequestParser rp{ctx}; - - const auto name_buf = rp.PopRaw<std::array<char, 8>>(); - const auto end = std::find(name_buf.begin(), name_buf.end(), '\0'); - - const std::string name(name_buf.begin(), end); + std::string name(PopServiceName(rp)); const auto is_light = static_cast<bool>(rp.PopRaw<u32>()); const auto max_session_count = rp.PopRaw<u32>(); @@ -160,7 +188,7 @@ void SM::RegisterService(Kernel::HLERequestContext& ctx) { LOG_DEBUG(Service_SM, "called with name={}, max_session_count={}, is_light={}", name, max_session_count, is_light); - auto handle = service_manager->RegisterService(name, max_session_count); + auto handle = service_manager.RegisterService(name, max_session_count); if (handle.Failed()) { LOG_ERROR(Service_SM, "failed to register service with error_code={:08X}", handle.Code().raw); @@ -178,28 +206,31 @@ void SM::RegisterService(Kernel::HLERequestContext& ctx) { void SM::UnregisterService(Kernel::HLERequestContext& ctx) { IPC::RequestParser rp{ctx}; + std::string name(PopServiceName(rp)); - const auto name_buf = rp.PopRaw<std::array<char, 8>>(); - const auto end = std::find(name_buf.begin(), name_buf.end(), '\0'); - - const std::string name(name_buf.begin(), end); LOG_DEBUG(Service_SM, "called with name={}", name); IPC::ResponseBuilder rb{ctx, 2}; - rb.Push(service_manager->UnregisterService(name)); + rb.Push(service_manager.UnregisterService(name)); } -SM::SM(std::shared_ptr<ServiceManager> service_manager_, Core::System& system_) +SM::SM(ServiceManager& service_manager_, Core::System& system_) : ServiceFramework{system_, "sm:", 4}, - service_manager{std::move(service_manager_)}, kernel{system_.Kernel()} { - static const FunctionInfo functions[] = { + service_manager{service_manager_}, kernel{system_.Kernel()} { + RegisterHandlers({ {0, &SM::Initialize, "Initialize"}, {1, &SM::GetService, "GetService"}, {2, &SM::RegisterService, "RegisterService"}, {3, &SM::UnregisterService, "UnregisterService"}, {4, nullptr, "DetachClient"}, - }; - RegisterHandlers(functions); + }); + RegisterHandlersTipc({ + {0, &SM::Initialize, "Initialize"}, + {1, &SM::GetServiceTipc, "GetService"}, + {2, &SM::RegisterService, "RegisterService"}, + {3, &SM::UnregisterService, "UnregisterService"}, + {4, nullptr, "DetachClient"}, + }); } } // namespace Service::SM diff --git a/src/core/hle/service/sm/sm.h b/src/core/hle/service/sm/sm.h index af5010c3b..ea37f11d4 100644 --- a/src/core/hle/service/sm/sm.h +++ b/src/core/hle/service/sm/sm.h @@ -34,22 +34,26 @@ class Controller; /// Interface to "sm:" service class SM final : public ServiceFramework<SM> { public: - explicit SM(std::shared_ptr<ServiceManager> service_manager_, Core::System& system_); + explicit SM(ServiceManager& service_manager_, Core::System& system_); ~SM() override; private: void Initialize(Kernel::HLERequestContext& ctx); void GetService(Kernel::HLERequestContext& ctx); + void GetServiceTipc(Kernel::HLERequestContext& ctx); void RegisterService(Kernel::HLERequestContext& ctx); void UnregisterService(Kernel::HLERequestContext& ctx); - std::shared_ptr<ServiceManager> service_manager; + ResultVal<Kernel::KClientSession*> GetServiceImpl(Kernel::HLERequestContext& ctx); + + ServiceManager& service_manager; + bool is_initialized{}; Kernel::KernelCore& kernel; }; class ServiceManager { public: - static void InstallInterfaces(std::shared_ptr<ServiceManager> self, Core::System& system); + static Kernel::KClientPort& InterfaceFactory(ServiceManager& self, Core::System& system); explicit ServiceManager(Kernel::KernelCore& kernel_); ~ServiceManager(); @@ -69,7 +73,7 @@ public: if (port == nullptr) { return nullptr; } - return std::static_pointer_cast<T>(port->GetServerPort().GetHLEHandler()); + return std::static_pointer_cast<T>(port->GetServerPort().GetSessionRequestHandler()); } void InvokeControlRequest(Kernel::HLERequestContext& context); diff --git a/src/core/hle/service/ssl/ssl.cpp b/src/core/hle/service/ssl/ssl.cpp index 2c8899ae0..3b072f6bc 100644 --- a/src/core/hle/service/ssl/ssl.cpp +++ b/src/core/hle/service/ssl/ssl.cpp @@ -128,7 +128,7 @@ private: LOG_WARNING(Service_SSL, "(STUBBED) called"); - IPC::ResponseBuilder rb{ctx, 2}; + IPC::ResponseBuilder rb{ctx, 4}; rb.Push(RESULT_SUCCESS); rb.Push(client_id); } diff --git a/src/core/hle/service/time/ephemeral_network_system_clock_core.h b/src/core/hle/service/time/ephemeral_network_system_clock_core.h index 4c6cdef86..d12cb5335 100644 --- a/src/core/hle/service/time/ephemeral_network_system_clock_core.h +++ b/src/core/hle/service/time/ephemeral_network_system_clock_core.h @@ -10,8 +10,8 @@ namespace Service::Time::Clock { class EphemeralNetworkSystemClockCore final : public SystemClockCore { public: - explicit EphemeralNetworkSystemClockCore(SteadyClockCore& steady_clock_core) - : SystemClockCore{steady_clock_core} {} + explicit EphemeralNetworkSystemClockCore(SteadyClockCore& steady_clock_core_) + : SystemClockCore{steady_clock_core_} {} }; } // namespace Service::Time::Clock diff --git a/src/core/hle/service/time/local_system_clock_context_writer.h b/src/core/hle/service/time/local_system_clock_context_writer.h index 7050844c6..490d0ef3e 100644 --- a/src/core/hle/service/time/local_system_clock_context_writer.h +++ b/src/core/hle/service/time/local_system_clock_context_writer.h @@ -12,8 +12,8 @@ namespace Service::Time::Clock { class LocalSystemClockContextWriter final : public SystemClockContextUpdateCallback { public: - explicit LocalSystemClockContextWriter(SharedMemory& shared_memory) - : SystemClockContextUpdateCallback{}, shared_memory{shared_memory} {} + explicit LocalSystemClockContextWriter(SharedMemory& shared_memory_) + : SystemClockContextUpdateCallback{}, shared_memory{shared_memory_} {} protected: ResultCode Update() override { diff --git a/src/core/hle/service/time/network_system_clock_context_writer.h b/src/core/hle/service/time/network_system_clock_context_writer.h index 94d8788ff..e2920b8eb 100644 --- a/src/core/hle/service/time/network_system_clock_context_writer.h +++ b/src/core/hle/service/time/network_system_clock_context_writer.h @@ -12,8 +12,8 @@ namespace Service::Time::Clock { class NetworkSystemClockContextWriter final : public SystemClockContextUpdateCallback { public: - explicit NetworkSystemClockContextWriter(SharedMemory& shared_memory) - : SystemClockContextUpdateCallback{}, shared_memory{shared_memory} {} + explicit NetworkSystemClockContextWriter(SharedMemory& shared_memory_) + : SystemClockContextUpdateCallback{}, shared_memory{shared_memory_} {} protected: ResultCode Update() override { diff --git a/src/core/hle/service/time/standard_local_system_clock_core.h b/src/core/hle/service/time/standard_local_system_clock_core.h index 8c1882eb1..6320c7af1 100644 --- a/src/core/hle/service/time/standard_local_system_clock_core.h +++ b/src/core/hle/service/time/standard_local_system_clock_core.h @@ -10,8 +10,8 @@ namespace Service::Time::Clock { class StandardLocalSystemClockCore final : public SystemClockCore { public: - explicit StandardLocalSystemClockCore(SteadyClockCore& steady_clock_core) - : SystemClockCore{steady_clock_core} {} + explicit StandardLocalSystemClockCore(SteadyClockCore& steady_clock_core_) + : SystemClockCore{steady_clock_core_} {} }; } // namespace Service::Time::Clock diff --git a/src/core/hle/service/time/standard_network_system_clock_core.h b/src/core/hle/service/time/standard_network_system_clock_core.h index c993bdf79..9d0aeaedb 100644 --- a/src/core/hle/service/time/standard_network_system_clock_core.h +++ b/src/core/hle/service/time/standard_network_system_clock_core.h @@ -16,21 +16,21 @@ namespace Service::Time::Clock { class StandardNetworkSystemClockCore final : public SystemClockCore { public: - explicit StandardNetworkSystemClockCore(SteadyClockCore& steady_clock_core) - : SystemClockCore{steady_clock_core} {} + explicit StandardNetworkSystemClockCore(SteadyClockCore& steady_clock_core_) + : SystemClockCore{steady_clock_core_} {} void SetStandardNetworkClockSufficientAccuracy(TimeSpanType value) { standard_network_clock_sufficient_accuracy = value; } bool IsStandardNetworkSystemClockAccuracySufficient(Core::System& system) const { - SystemClockContext context{}; - if (GetClockContext(system, context) != RESULT_SUCCESS) { + SystemClockContext clock_ctx{}; + if (GetClockContext(system, clock_ctx) != RESULT_SUCCESS) { return {}; } s64 span{}; - if (context.steady_time_point.GetSpanBetween( + if (clock_ctx.steady_time_point.GetSpanBetween( GetSteadyClockCore().GetCurrentTimePoint(system), span) != RESULT_SUCCESS) { return {}; } diff --git a/src/core/hle/service/time/standard_user_system_clock_core.cpp b/src/core/hle/service/time/standard_user_system_clock_core.cpp index 7f47b12b8..41bc01abd 100644 --- a/src/core/hle/service/time/standard_user_system_clock_core.cpp +++ b/src/core/hle/service/time/standard_user_system_clock_core.cpp @@ -11,13 +11,13 @@ namespace Service::Time::Clock { StandardUserSystemClockCore::StandardUserSystemClockCore( - StandardLocalSystemClockCore& local_system_clock_core, - StandardNetworkSystemClockCore& network_system_clock_core, Core::System& system) - : SystemClockCore(local_system_clock_core.GetSteadyClockCore()), - local_system_clock_core{local_system_clock_core}, - network_system_clock_core{network_system_clock_core}, auto_correction_enabled{}, + StandardLocalSystemClockCore& local_system_clock_core_, + StandardNetworkSystemClockCore& network_system_clock_core_, Core::System& system_) + : SystemClockCore(local_system_clock_core_.GetSteadyClockCore()), + local_system_clock_core{local_system_clock_core_}, + network_system_clock_core{network_system_clock_core_}, auto_correction_time{SteadyClockTimePoint::GetRandom()}, auto_correction_event{ - system.Kernel()} { + system_.Kernel()} { Kernel::KAutoObject::Create(std::addressof(auto_correction_event)); auto_correction_event.Initialize("StandardUserSystemClockCore:AutoCorrectionEvent"); } @@ -35,13 +35,13 @@ ResultCode StandardUserSystemClockCore::SetAutomaticCorrectionEnabled(Core::Syst } ResultCode StandardUserSystemClockCore::GetClockContext(Core::System& system, - SystemClockContext& context) const { + SystemClockContext& ctx) const { if (const ResultCode result{ApplyAutomaticCorrection(system, false)}; result != RESULT_SUCCESS) { return result; } - return local_system_clock_core.GetClockContext(system, context); + return local_system_clock_core.GetClockContext(system, ctx); } ResultCode StandardUserSystemClockCore::Flush(const SystemClockContext&) { @@ -64,13 +64,13 @@ ResultCode StandardUserSystemClockCore::ApplyAutomaticCorrection(Core::System& s return ERROR_UNINITIALIZED_CLOCK; } - SystemClockContext context{}; - if (const ResultCode result{network_system_clock_core.GetClockContext(system, context)}; + SystemClockContext ctx{}; + if (const ResultCode result{network_system_clock_core.GetClockContext(system, ctx)}; result != RESULT_SUCCESS) { return result; } - local_system_clock_core.SetClockContext(context); + local_system_clock_core.SetClockContext(ctx); return RESULT_SUCCESS; } diff --git a/src/core/hle/service/time/standard_user_system_clock_core.h b/src/core/hle/service/time/standard_user_system_clock_core.h index 1bff8a5af..bf9ec5e42 100644 --- a/src/core/hle/service/time/standard_user_system_clock_core.h +++ b/src/core/hle/service/time/standard_user_system_clock_core.h @@ -23,13 +23,13 @@ class StandardNetworkSystemClockCore; class StandardUserSystemClockCore final : public SystemClockCore { public: - StandardUserSystemClockCore(StandardLocalSystemClockCore& local_system_clock_core, - StandardNetworkSystemClockCore& network_system_clock_core, - Core::System& system); + StandardUserSystemClockCore(StandardLocalSystemClockCore& local_system_clock_core_, + StandardNetworkSystemClockCore& network_system_clock_core_, + Core::System& system_); ResultCode SetAutomaticCorrectionEnabled(Core::System& system, bool value); - ResultCode GetClockContext(Core::System& system, SystemClockContext& context) const override; + ResultCode GetClockContext(Core::System& system, SystemClockContext& ctx) const override; bool IsAutomaticCorrectionEnabled() const { return auto_correction_enabled; diff --git a/src/core/hle/service/time/system_clock_core.cpp b/src/core/hle/service/time/system_clock_core.cpp index 46fc8c6c3..2ef442b56 100644 --- a/src/core/hle/service/time/system_clock_core.cpp +++ b/src/core/hle/service/time/system_clock_core.cpp @@ -8,8 +8,8 @@ namespace Service::Time::Clock { -SystemClockCore::SystemClockCore(SteadyClockCore& steady_clock_core) - : steady_clock_core{steady_clock_core} { +SystemClockCore::SystemClockCore(SteadyClockCore& steady_clock_core_) + : steady_clock_core{steady_clock_core_} { context.steady_time_point.clock_source_id = steady_clock_core.GetClockSourceId(); } diff --git a/src/core/hle/service/time/system_clock_core.h b/src/core/hle/service/time/system_clock_core.h index 82a8b79ff..b8e6122bf 100644 --- a/src/core/hle/service/time/system_clock_core.h +++ b/src/core/hle/service/time/system_clock_core.h @@ -21,7 +21,7 @@ class SystemClockContextUpdateCallback; class SystemClockCore { public: - explicit SystemClockCore(SteadyClockCore& steady_clock_core); + explicit SystemClockCore(SteadyClockCore& steady_clock_core_); virtual ~SystemClockCore(); SteadyClockCore& GetSteadyClockCore() const { diff --git a/src/core/hle/service/time/time_manager.cpp b/src/core/hle/service/time/time_manager.cpp index fe01a3739..4f9684de8 100644 --- a/src/core/hle/service/time/time_manager.cpp +++ b/src/core/hle/service/time/time_manager.cpp @@ -223,7 +223,7 @@ struct TimeManager::Impl final { TimeZone::TimeZoneContentManager time_zone_content_manager; }; -TimeManager::TimeManager(Core::System& system) : system{system} {} +TimeManager::TimeManager(Core::System& system_) : system{system_} {} TimeManager::~TimeManager() = default; diff --git a/src/core/hle/service/time/time_manager.h b/src/core/hle/service/time/time_manager.h index 4db8cc0e1..3af868d87 100644 --- a/src/core/hle/service/time/time_manager.h +++ b/src/core/hle/service/time/time_manager.h @@ -30,7 +30,7 @@ class NetworkSystemClockContextWriter; class TimeManager final { public: - explicit TimeManager(Core::System& system); + explicit TimeManager(Core::System& system_); ~TimeManager(); void Initialize(); diff --git a/src/core/hle/service/time/time_sharedmemory.cpp b/src/core/hle/service/time/time_sharedmemory.cpp index eb57899f6..176ad0eee 100644 --- a/src/core/hle/service/time/time_sharedmemory.cpp +++ b/src/core/hle/service/time/time_sharedmemory.cpp @@ -15,7 +15,7 @@ namespace Service::Time { static constexpr std::size_t SHARED_MEMORY_SIZE{0x1000}; -SharedMemory::SharedMemory(Core::System& system) : system(system) { +SharedMemory::SharedMemory(Core::System& system_) : system(system_) { std::memset(system.Kernel().GetTimeSharedMem().GetPointer(), 0, SHARED_MEMORY_SIZE); } diff --git a/src/core/hle/service/time/time_sharedmemory.h b/src/core/hle/service/time/time_sharedmemory.h index 1ad9a286d..d471b5d18 100644 --- a/src/core/hle/service/time/time_sharedmemory.h +++ b/src/core/hle/service/time/time_sharedmemory.h @@ -14,7 +14,7 @@ namespace Service::Time { class SharedMemory final { public: - explicit SharedMemory(Core::System& system); + explicit SharedMemory(Core::System& system_); ~SharedMemory(); // TODO(ogniK): We have to properly simulate memory barriers, how are we going to do this? diff --git a/src/core/hle/service/time/time_zone_content_manager.cpp b/src/core/hle/service/time/time_zone_content_manager.cpp index 3c8e71a3c..57f71e6f0 100644 --- a/src/core/hle/service/time/time_zone_content_manager.cpp +++ b/src/core/hle/service/time/time_zone_content_manager.cpp @@ -68,8 +68,8 @@ static std::vector<std::string> BuildLocationNameCache(Core::System& system) { return location_name_cache; } -TimeZoneContentManager::TimeZoneContentManager(Core::System& system) - : system{system}, location_name_cache{BuildLocationNameCache(system)} {} +TimeZoneContentManager::TimeZoneContentManager(Core::System& system_) + : system{system_}, location_name_cache{BuildLocationNameCache(system)} {} void TimeZoneContentManager::Initialize(TimeManager& time_manager) { std::string location_name; diff --git a/src/core/hle/service/time/time_zone_content_manager.h b/src/core/hle/service/time/time_zone_content_manager.h index 52dd1a020..cfa601084 100644 --- a/src/core/hle/service/time/time_zone_content_manager.h +++ b/src/core/hle/service/time/time_zone_content_manager.h @@ -21,7 +21,7 @@ namespace Service::Time::TimeZone { class TimeZoneContentManager final { public: - explicit TimeZoneContentManager(Core::System& system); + explicit TimeZoneContentManager(Core::System& system_); void Initialize(TimeManager& time_manager); diff --git a/src/core/hle/service/vi/display/vi_display.cpp b/src/core/hle/service/vi/display/vi_display.cpp index becbd36c1..0dd342dbf 100644 --- a/src/core/hle/service/vi/display/vi_display.cpp +++ b/src/core/hle/service/vi/display/vi_display.cpp @@ -17,8 +17,8 @@ namespace Service::VI { -Display::Display(u64 id, std::string name, Core::System& system) - : id{id}, name{std::move(name)}, vsync_event{system.Kernel()} { +Display::Display(u64 id, std::string name_, Core::System& system) + : display_id{id}, name{std::move(name_)}, vsync_event{system.Kernel()} { Kernel::KAutoObject::Create(std::addressof(vsync_event)); vsync_event.Initialize(fmt::format("Display VSync Event {}", id)); } diff --git a/src/core/hle/service/vi/display/vi_display.h b/src/core/hle/service/vi/display/vi_display.h index 388ce6083..166f2a4cc 100644 --- a/src/core/hle/service/vi/display/vi_display.h +++ b/src/core/hle/service/vi/display/vi_display.h @@ -32,14 +32,14 @@ public: /// Constructs a display with a given unique ID and name. /// /// @param id The unique ID for this display. - /// @param name The name for this display. + /// @param name_ The name for this display. /// - Display(u64 id, std::string name, Core::System& system); + Display(u64 id, std::string name_, Core::System& system); ~Display(); /// Gets the unique ID assigned to this display. u64 GetID() const { - return id; + return display_id; } /// Gets the name of this display @@ -96,7 +96,7 @@ public: const Layer* FindLayer(u64 layer_id) const; private: - u64 id; + u64 display_id; std::string name; std::vector<std::shared_ptr<Layer>> layers; diff --git a/src/core/hle/service/vi/layer/vi_layer.cpp b/src/core/hle/service/vi/layer/vi_layer.cpp index 954225c26..9bc382587 100644 --- a/src/core/hle/service/vi/layer/vi_layer.cpp +++ b/src/core/hle/service/vi/layer/vi_layer.cpp @@ -6,7 +6,7 @@ namespace Service::VI { -Layer::Layer(u64 id, NVFlinger::BufferQueue& queue) : id{id}, buffer_queue{queue} {} +Layer::Layer(u64 id, NVFlinger::BufferQueue& queue) : layer_id{id}, buffer_queue{queue} {} Layer::~Layer() = default; diff --git a/src/core/hle/service/vi/layer/vi_layer.h b/src/core/hle/service/vi/layer/vi_layer.h index c6bfd01f6..ebdd85505 100644 --- a/src/core/hle/service/vi/layer/vi_layer.h +++ b/src/core/hle/service/vi/layer/vi_layer.h @@ -31,7 +31,7 @@ public: /// Gets the ID for this layer. u64 GetID() const { - return id; + return layer_id; } /// Gets a reference to the buffer queue this layer is using. @@ -45,7 +45,7 @@ public: } private: - u64 id; + u64 layer_id; NVFlinger::BufferQueue& buffer_queue; }; diff --git a/src/core/hle/service/vi/vi.cpp b/src/core/hle/service/vi/vi.cpp index 32e47a43e..fdd2b4b4f 100644 --- a/src/core/hle/service/vi/vi.cpp +++ b/src/core/hle/service/vi/vi.cpp @@ -212,7 +212,7 @@ private: class IGBPConnectRequestParcel : public Parcel { public: - explicit IGBPConnectRequestParcel(std::vector<u8> buffer) : Parcel(std::move(buffer)) { + explicit IGBPConnectRequestParcel(std::vector<u8> buffer_) : Parcel(std::move(buffer_)) { Deserialize(); } @@ -274,8 +274,8 @@ private: class IGBPSetPreallocatedBufferRequestParcel : public Parcel { public: - explicit IGBPSetPreallocatedBufferRequestParcel(std::vector<u8> buffer) - : Parcel(std::move(buffer)) { + explicit IGBPSetPreallocatedBufferRequestParcel(std::vector<u8> buffer_) + : Parcel(std::move(buffer_)) { Deserialize(); } @@ -312,7 +312,7 @@ protected: class IGBPCancelBufferRequestParcel : public Parcel { public: - explicit IGBPCancelBufferRequestParcel(std::vector<u8> buffer) : Parcel(std::move(buffer)) { + explicit IGBPCancelBufferRequestParcel(std::vector<u8> buffer_) : Parcel(std::move(buffer_)) { Deserialize(); } @@ -338,7 +338,7 @@ protected: class IGBPDequeueBufferRequestParcel : public Parcel { public: - explicit IGBPDequeueBufferRequestParcel(std::vector<u8> buffer) : Parcel(std::move(buffer)) { + explicit IGBPDequeueBufferRequestParcel(std::vector<u8> buffer_) : Parcel(std::move(buffer_)) { Deserialize(); } @@ -360,8 +360,8 @@ public: class IGBPDequeueBufferResponseParcel : public Parcel { public: - explicit IGBPDequeueBufferResponseParcel(u32 slot, Service::Nvidia::MultiFence& multi_fence) - : slot(slot), multi_fence(multi_fence) {} + explicit IGBPDequeueBufferResponseParcel(u32 slot_, Nvidia::MultiFence& multi_fence_) + : slot(slot_), multi_fence(multi_fence_) {} protected: void SerializeData() override { @@ -377,7 +377,7 @@ protected: class IGBPRequestBufferRequestParcel : public Parcel { public: - explicit IGBPRequestBufferRequestParcel(std::vector<u8> buffer) : Parcel(std::move(buffer)) { + explicit IGBPRequestBufferRequestParcel(std::vector<u8> buffer_) : Parcel(std::move(buffer_)) { Deserialize(); } @@ -391,7 +391,7 @@ public: class IGBPRequestBufferResponseParcel : public Parcel { public: - explicit IGBPRequestBufferResponseParcel(NVFlinger::IGBPBuffer buffer) : buffer(buffer) {} + explicit IGBPRequestBufferResponseParcel(NVFlinger::IGBPBuffer buffer_) : buffer(buffer_) {} ~IGBPRequestBufferResponseParcel() override = default; protected: @@ -408,7 +408,7 @@ protected: class IGBPQueueBufferRequestParcel : public Parcel { public: - explicit IGBPQueueBufferRequestParcel(std::vector<u8> buffer) : Parcel(std::move(buffer)) { + explicit IGBPQueueBufferRequestParcel(std::vector<u8> buffer_) : Parcel(std::move(buffer_)) { Deserialize(); } @@ -470,7 +470,7 @@ private: class IGBPQueryRequestParcel : public Parcel { public: - explicit IGBPQueryRequestParcel(std::vector<u8> buffer) : Parcel(std::move(buffer)) { + explicit IGBPQueryRequestParcel(std::vector<u8> buffer_) : Parcel(std::move(buffer_)) { Deserialize(); } @@ -484,7 +484,7 @@ public: class IGBPQueryResponseParcel : public Parcel { public: - explicit IGBPQueryResponseParcel(u32 value) : value(value) {} + explicit IGBPQueryResponseParcel(u32 value_) : value{value_} {} ~IGBPQueryResponseParcel() override = default; protected: |