diff options
485 files changed, 6715 insertions, 5958 deletions
diff --git a/.ci/scripts/windows/scan_dll.py b/.ci/scripts/windows/scan_dll.py index f374e0d78..a536f7375 100644 --- a/.ci/scripts/windows/scan_dll.py +++ b/.ci/scripts/windows/scan_dll.py @@ -40,7 +40,7 @@ def parse_imports(file_name): def parse_imports_recursive(file_name, path_list=[]): q = queue.Queue() # create a FIFO queue - # file_name can be a string or a list for the convience + # file_name can be a string or a list for the convenience if isinstance(file_name, str): q.put(file_name) elif isinstance(file_name, list): diff --git a/.codespellrc b/.codespellrc new file mode 100644 index 000000000..786a991eb --- /dev/null +++ b/.codespellrc @@ -0,0 +1,6 @@ +; SPDX-FileCopyrightText: 2023 yuzu Emulator Project +; SPDX-License-Identifier: GPL-2.0-or-later + +[codespell] +skip = ./.git,./build,./dist,./Doxyfile,./externals,./LICENSES +ignore-words-list = aci,allright,ba,deques,froms,hda,inout,lod,masia,nam,nax,nd,pullrequests,pullrequest,te,transfered,unstall,uscaled,zink diff --git a/.github/workflows/codespell.yml b/.github/workflows/codespell.yml new file mode 100644 index 000000000..d873fb725 --- /dev/null +++ b/.github/workflows/codespell.yml @@ -0,0 +1,17 @@ +# SPDX-FileCopyrightText: 2023 yuzu Emulator Project +# SPDX-License-Identifier: GPL-2.0-or-later +# GitHub Action to automate the identification of common misspellings in text files. +# https://github.com/codespell-project/actions-codespell +# https://github.com/codespell-project/codespell +name: codespell +on: pull_request +permissions: {} +jobs: + codespell: + name: Check for spelling errors + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + with: + persist-credentials: false + - uses: codespell-project/actions-codespell@master diff --git a/CMakeLists.txt b/CMakeLists.txt index f26a0c6b8..6932b6fab 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -344,12 +344,12 @@ if(ENABLE_QT) find_package(PkgConfig REQUIRED) pkg_check_modules(QT_DEP_GLU QUIET glu>=9.0.0) if (NOT QT_DEP_GLU_FOUND) - message(FATAL_ERROR "Qt bundled pacakge dependency `glu` not found. \ + message(FATAL_ERROR "Qt bundled package dependency `glu` not found. \ Perhaps `libglu1-mesa-dev` needs to be installed?") endif() pkg_check_modules(QT_DEP_MESA QUIET dri>=20.0.8) if (NOT QT_DEP_MESA_FOUND) - message(FATAL_ERROR "Qt bundled pacakge dependency `dri` not found. \ + message(FATAL_ERROR "Qt bundled package dependency `dri` not found. \ Perhaps `mesa-common-dev` needs to be installed?") endif() @@ -477,8 +477,8 @@ if (APPLE) find_library(COCOA_LIBRARY Cocoa) set(PLATFORM_LIBRARIES ${COCOA_LIBRARY} ${IOKIT_LIBRARY} ${COREVIDEO_LIBRARY}) elseif (WIN32) - # WSAPoll and SHGetKnownFolderPath (AppData/Roaming) didn't exist before WinNT 6.x (Vista) - add_definitions(-D_WIN32_WINNT=0x0600 -DWINVER=0x0600) + # Target Windows 10 + add_definitions(-D_WIN32_WINNT=0x0A00 -DWINVER=0x0A00) set(PLATFORM_LIBRARIES winmm ws2_32 iphlpapi) if (MINGW) # PSAPI is the Process Status API diff --git a/CMakeModules/FindFFmpeg.cmake b/CMakeModules/FindFFmpeg.cmake index eedf28aea..5cb1f3c8a 100644 --- a/CMakeModules/FindFFmpeg.cmake +++ b/CMakeModules/FindFFmpeg.cmake @@ -14,7 +14,7 @@ # FFmpeg_LIBRARIES: aggregate all the paths to the libraries # FFmpeg_FOUND: True if all components have been found # -# This module defines the following targets, which are prefered over variables: +# This module defines the following targets, which are preferred over variables: # # FFmpeg::<component>: Target to use <component> directly, with include path, # library and dependencies set up. If you are using a static build, you are diff --git a/dist/yuzu.manifest b/dist/yuzu.manifest index 10a8df9b5..f2c8639a2 100644 --- a/dist/yuzu.manifest +++ b/dist/yuzu.manifest @@ -36,12 +36,6 @@ SPDX-License-Identifier: GPL-2.0-or-later <application> <!-- Windows 10 --> <supportedOS Id="{8e0f7a12-bfb3-4fe8-b9a5-48fd50a15a9a}"/> - <!-- Windows 8.1 --> - <supportedOS Id="{1f676c76-80e1-4239-95bb-83d0f6d0da78}"/> - <!-- Windows 8 --> - <supportedOS Id="{4a2f28e3-53b9-4441-ba9c-d69d4a4a6e38}"/> - <!-- Windows 7 --> - <supportedOS Id="{35138b9a-5d96-4fbd-8e2d-a2440225f93a}"/> </application> </compatibility> <trustInfo diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index c7283e82c..0eca8e90e 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -83,7 +83,7 @@ if (MSVC) ) if (USE_CCACHE OR YUZU_USE_PRECOMPILED_HEADERS) - # when caching, we need to use /Z7 to downgrade debug info to use an older but more cachable format + # when caching, we need to use /Z7 to downgrade debug info to use an older but more cacheable format # Precompiled headers are deleted if not using /Z7. See https://github.com/nanoant/CMakePCHCompiler/issues/21 add_compile_options(/Z7) else() diff --git a/src/audio_core/audio_in_manager.cpp b/src/audio_core/audio_in_manager.cpp index f39fb4002..3dfb613cb 100644 --- a/src/audio_core/audio_in_manager.cpp +++ b/src/audio_core/audio_in_manager.cpp @@ -20,7 +20,7 @@ Manager::Manager(Core::System& system_) : system{system_} { Result Manager::AcquireSessionId(size_t& session_id) { if (num_free_sessions == 0) { LOG_ERROR(Service_Audio, "All 4 AudioIn sessions are in use, cannot create any more"); - return Service::Audio::ERR_MAXIMUM_SESSIONS_REACHED; + return Service::Audio::ResultOutOfSessions; } session_id = session_ids[next_session_id]; next_session_id = (next_session_id + 1) % MaxInSessions; diff --git a/src/audio_core/audio_manager.cpp b/src/audio_core/audio_manager.cpp index 2acde668e..10b56f214 100644 --- a/src/audio_core/audio_manager.cpp +++ b/src/audio_core/audio_manager.cpp @@ -19,7 +19,7 @@ void AudioManager::Shutdown() { Result AudioManager::SetOutManager(BufferEventFunc buffer_func) { if (!running) { - return Service::Audio::ERR_OPERATION_FAILED; + return Service::Audio::ResultOperationFailed; } std::scoped_lock l{lock}; @@ -35,7 +35,7 @@ Result AudioManager::SetOutManager(BufferEventFunc buffer_func) { Result AudioManager::SetInManager(BufferEventFunc buffer_func) { if (!running) { - return Service::Audio::ERR_OPERATION_FAILED; + return Service::Audio::ResultOperationFailed; } std::scoped_lock l{lock}; diff --git a/src/audio_core/audio_out_manager.cpp b/src/audio_core/audio_out_manager.cpp index 1766efde1..f22821360 100644 --- a/src/audio_core/audio_out_manager.cpp +++ b/src/audio_core/audio_out_manager.cpp @@ -19,7 +19,7 @@ Manager::Manager(Core::System& system_) : system{system_} { Result Manager::AcquireSessionId(size_t& session_id) { if (num_free_sessions == 0) { LOG_ERROR(Service_Audio, "All 12 Audio Out sessions are in use, cannot create any more"); - return Service::Audio::ERR_MAXIMUM_SESSIONS_REACHED; + return Service::Audio::ResultOutOfSessions; } session_id = session_ids[next_session_id]; next_session_id = (next_session_id + 1) % MaxOutSessions; diff --git a/src/audio_core/audio_out_manager.h b/src/audio_core/audio_out_manager.h index 24981e08f..1e05ec5ed 100644 --- a/src/audio_core/audio_out_manager.h +++ b/src/audio_core/audio_out_manager.h @@ -58,7 +58,7 @@ public: /** * Get a list of audio out device names. * - * @oaram names - Output container to write names to. + * @param names - Output container to write names to. * @return Number of names written. */ u32 GetAudioOutDeviceNames( diff --git a/src/audio_core/audio_render_manager.cpp b/src/audio_core/audio_render_manager.cpp index 7aba2b423..320715727 100644 --- a/src/audio_core/audio_render_manager.cpp +++ b/src/audio_core/audio_render_manager.cpp @@ -28,7 +28,7 @@ SystemManager& Manager::GetSystemManager() { Result Manager::GetWorkBufferSize(const AudioRendererParameterInternal& params, u64& out_count) const { if (!CheckValidRevision(params.revision)) { - return Service::Audio::ERR_INVALID_REVISION; + return Service::Audio::ResultInvalidRevision; } out_count = System::GetWorkBufferSize(params); diff --git a/src/audio_core/device/audio_buffer.h b/src/audio_core/device/audio_buffer.h index 7128ef72a..4eb80c2ba 100644 --- a/src/audio_core/device/audio_buffer.h +++ b/src/audio_core/device/audio_buffer.h @@ -16,7 +16,7 @@ struct AudioBuffer { s64 played_timestamp; /// Game memory address for these samples. VAddr samples; - /// Unqiue identifier for this buffer. + /// Unique identifier for this buffer. u64 tag; /// Size of the samples buffer. u64 size; diff --git a/src/audio_core/in/audio_in.cpp b/src/audio_core/in/audio_in.cpp index 91ccd5ad7..df8c44d1f 100644 --- a/src/audio_core/in/audio_in.cpp +++ b/src/audio_core/in/audio_in.cpp @@ -46,7 +46,7 @@ Result In::AppendBuffer(const AudioInBuffer& buffer, u64 tag) { if (system.AppendBuffer(buffer, tag)) { return ResultSuccess; } - return Service::Audio::ERR_BUFFER_COUNT_EXCEEDED; + return Service::Audio::ResultBufferCountReached; } void In::ReleaseAndRegisterBuffers() { diff --git a/src/audio_core/in/audio_in_system.cpp b/src/audio_core/in/audio_in_system.cpp index 934ef8c1c..e23e51758 100644 --- a/src/audio_core/in/audio_in_system.cpp +++ b/src/audio_core/in/audio_in_system.cpp @@ -45,11 +45,11 @@ Result System::IsConfigValid(const std::string_view device_name, const AudioInParameter& in_params) const { if ((device_name.size() > 0) && (device_name != GetDefaultDeviceName() && device_name != GetDefaultUacDeviceName())) { - return Service::Audio::ERR_INVALID_DEVICE_NAME; + return Service::Audio::ResultNotFound; } if (in_params.sample_rate != TargetSampleRate && in_params.sample_rate > 0) { - return Service::Audio::ERR_INVALID_SAMPLE_RATE; + return Service::Audio::ResultInvalidSampleRate; } return ResultSuccess; @@ -80,7 +80,7 @@ Result System::Initialize(std::string device_name, const AudioInParameter& in_pa Result System::Start() { if (state != State::Stopped) { - return Service::Audio::ERR_OPERATION_FAILED; + return Service::Audio::ResultOperationFailed; } session->Initialize(name, sample_format, channel_count, session_id, handle, diff --git a/src/audio_core/out/audio_out.cpp b/src/audio_core/out/audio_out.cpp index d3ee4f0eb..b7ea13405 100644 --- a/src/audio_core/out/audio_out.cpp +++ b/src/audio_core/out/audio_out.cpp @@ -46,7 +46,7 @@ Result Out::AppendBuffer(const AudioOutBuffer& buffer, const u64 tag) { if (system.AppendBuffer(buffer, tag)) { return ResultSuccess; } - return Service::Audio::ERR_BUFFER_COUNT_EXCEEDED; + return Service::Audio::ResultBufferCountReached; } void Out::ReleaseAndRegisterBuffers() { diff --git a/src/audio_core/out/audio_out_system.cpp b/src/audio_core/out/audio_out_system.cpp index e096a1dac..bd13f7219 100644 --- a/src/audio_core/out/audio_out_system.cpp +++ b/src/audio_core/out/audio_out_system.cpp @@ -33,11 +33,11 @@ std::string_view System::GetDefaultOutputDeviceName() const { Result System::IsConfigValid(std::string_view device_name, const AudioOutParameter& in_params) const { if ((device_name.size() > 0) && (device_name != GetDefaultOutputDeviceName())) { - return Service::Audio::ERR_INVALID_DEVICE_NAME; + return Service::Audio::ResultNotFound; } if (in_params.sample_rate != TargetSampleRate && in_params.sample_rate > 0) { - return Service::Audio::ERR_INVALID_SAMPLE_RATE; + return Service::Audio::ResultInvalidSampleRate; } if (in_params.channel_count == 0 || in_params.channel_count == 2 || @@ -45,7 +45,7 @@ Result System::IsConfigValid(std::string_view device_name, return ResultSuccess; } - return Service::Audio::ERR_INVALID_CHANNEL_COUNT; + return Service::Audio::ResultInvalidChannelCount; } Result System::Initialize(std::string device_name, const AudioOutParameter& in_params, u32 handle_, @@ -80,7 +80,7 @@ size_t System::GetSessionId() const { Result System::Start() { if (state != State::Stopped) { - return Service::Audio::ERR_OPERATION_FAILED; + return Service::Audio::ResultOperationFailed; } session->Initialize(name, sample_format, channel_count, session_id, handle, diff --git a/src/audio_core/renderer/adsp/audio_renderer.cpp b/src/audio_core/renderer/adsp/audio_renderer.cpp index 78c15629b..42b4b167a 100644 --- a/src/audio_core/renderer/adsp/audio_renderer.cpp +++ b/src/audio_core/renderer/adsp/audio_renderer.cpp @@ -135,7 +135,7 @@ void AudioRenderer::ThreadFunc() { static constexpr char name[]{"AudioRenderer"}; MicroProfileOnThreadCreate(name); Common::SetCurrentThreadName(name); - Common::SetCurrentThreadPriority(Common::ThreadPriority::Critical); + Common::SetCurrentThreadPriority(Common::ThreadPriority::High); if (mailbox->ADSPWaitMessage() != RenderMessage::AudioRenderer_InitializeOK) { LOG_ERROR(Service_Audio, "ADSP Audio Renderer -- Failed to receive initialize message from host!"); @@ -165,7 +165,7 @@ void AudioRenderer::ThreadFunc() { // Check this buffer is valid, as it may not be used. if (command_buffer.buffer != 0) { // If there are no remaining commands (from the previous list), - // this is a new command list, initalize it. + // this is a new command list, initialize it. if (command_buffer.remaining_command_count == 0) { command_list_processor.Initialize(system, command_buffer.buffer, command_buffer.size, streams[index]); diff --git a/src/audio_core/renderer/audio_renderer.cpp b/src/audio_core/renderer/audio_renderer.cpp index 51aa17599..a8257eb2e 100644 --- a/src/audio_core/renderer/audio_renderer.cpp +++ b/src/audio_core/renderer/audio_renderer.cpp @@ -22,7 +22,7 @@ Result Renderer::Initialize(const AudioRendererParameterInternal& params, if (!manager.AddSystem(system)) { LOG_ERROR(Service_Audio, "Both Audio Render sessions are in use, cannot create any more"); - return Service::Audio::ERR_MAXIMUM_SESSIONS_REACHED; + return Service::Audio::ResultOutOfSessions; } system_registered = true; } diff --git a/src/audio_core/renderer/behavior/behavior_info.h b/src/audio_core/renderer/behavior/behavior_info.h index 15c948344..b52340229 100644 --- a/src/audio_core/renderer/behavior/behavior_info.h +++ b/src/audio_core/renderer/behavior/behavior_info.h @@ -155,7 +155,7 @@ public: /** * Check if a variadic command buffer is supported. * As of Rev 5 with the added optional performance metric logging, the command - * buffer can be a variable size, so take that into account for calcualting its size. + * buffer can be a variable size, so take that into account for calculating its size. * * @return True if supported, otherwise false. */ diff --git a/src/audio_core/renderer/behavior/info_updater.cpp b/src/audio_core/renderer/behavior/info_updater.cpp index 574cf0982..e312eb166 100644 --- a/src/audio_core/renderer/behavior/info_updater.cpp +++ b/src/audio_core/renderer/behavior/info_updater.cpp @@ -48,7 +48,7 @@ Result InfoUpdater::UpdateVoiceChannelResources(VoiceContext& voice_context) { LOG_ERROR(Service_Audio, "Consumed an incorrect voice resource size, header size={}, consumed={}", in_header->voice_resources_size, consumed_input_size); - return Service::Audio::ERR_INVALID_UPDATE_DATA; + return Service::Audio::ResultInvalidUpdateInfo; } input += consumed_input_size; @@ -123,7 +123,7 @@ Result InfoUpdater::UpdateVoices(VoiceContext& voice_context, if (consumed_input_size != in_header->voices_size) { LOG_ERROR(Service_Audio, "Consumed an incorrect voices size, header size={}, consumed={}", in_header->voices_size, consumed_input_size); - return Service::Audio::ERR_INVALID_UPDATE_DATA; + return Service::Audio::ResultInvalidUpdateInfo; } out_header->voices_size = consumed_output_size; @@ -184,7 +184,7 @@ Result InfoUpdater::UpdateEffectsVersion1(EffectContext& effect_context, const b if (consumed_input_size != in_header->effects_size) { LOG_ERROR(Service_Audio, "Consumed an incorrect effects size, header size={}, consumed={}", in_header->effects_size, consumed_input_size); - return Service::Audio::ERR_INVALID_UPDATE_DATA; + return Service::Audio::ResultInvalidUpdateInfo; } out_header->effects_size = consumed_output_size; @@ -239,7 +239,7 @@ Result InfoUpdater::UpdateEffectsVersion2(EffectContext& effect_context, const b if (consumed_input_size != in_header->effects_size) { LOG_ERROR(Service_Audio, "Consumed an incorrect effects size, header size={}, consumed={}", in_header->effects_size, consumed_input_size); - return Service::Audio::ERR_INVALID_UPDATE_DATA; + return Service::Audio::ResultInvalidUpdateInfo; } out_header->effects_size = consumed_output_size; @@ -267,7 +267,7 @@ Result InfoUpdater::UpdateMixes(MixContext& mix_context, const u32 mix_buffer_co } if (mix_buffer_count == 0) { - return Service::Audio::ERR_INVALID_UPDATE_DATA; + return Service::Audio::ResultInvalidUpdateInfo; } std::span<const MixInfo::InParameter> in_params{ @@ -281,13 +281,13 @@ Result InfoUpdater::UpdateMixes(MixContext& mix_context, const u32 mix_buffer_co total_buffer_count += params.buffer_count; if (params.dest_mix_id > static_cast<s32>(mix_context.GetCount()) && params.dest_mix_id != UnusedMixId && params.mix_id != FinalMixId) { - return Service::Audio::ERR_INVALID_UPDATE_DATA; + return Service::Audio::ResultInvalidUpdateInfo; } } } if (total_buffer_count > mix_buffer_count) { - return Service::Audio::ERR_INVALID_UPDATE_DATA; + return Service::Audio::ResultInvalidUpdateInfo; } bool mix_dirty{false}; @@ -317,7 +317,7 @@ Result InfoUpdater::UpdateMixes(MixContext& mix_context, const u32 mix_buffer_co if (mix_dirty) { if (behaviour.IsSplitterSupported() && splitter_context.UsingSplitter()) { if (!mix_context.TSortInfo(splitter_context)) { - return Service::Audio::ERR_INVALID_UPDATE_DATA; + return Service::Audio::ResultInvalidUpdateInfo; } } else { mix_context.SortInfo(); @@ -327,7 +327,7 @@ Result InfoUpdater::UpdateMixes(MixContext& mix_context, const u32 mix_buffer_co if (consumed_input_size != in_header->mix_size) { LOG_ERROR(Service_Audio, "Consumed an incorrect mixes size, header size={}, consumed={}", in_header->mix_size, consumed_input_size); - return Service::Audio::ERR_INVALID_UPDATE_DATA; + return Service::Audio::ResultInvalidUpdateInfo; } input += mix_count * sizeof(MixInfo::InParameter); @@ -384,7 +384,7 @@ Result InfoUpdater::UpdateSinks(SinkContext& sink_context, std::span<MemoryPoolI if (consumed_input_size != in_header->sinks_size) { LOG_ERROR(Service_Audio, "Consumed an incorrect sinks size, header size={}, consumed={}", in_header->sinks_size, consumed_input_size); - return Service::Audio::ERR_INVALID_UPDATE_DATA; + return Service::Audio::ResultInvalidUpdateInfo; } input += consumed_input_size; @@ -411,7 +411,7 @@ Result InfoUpdater::UpdateMemoryPools(std::span<MemoryPoolInfo> memory_pools, state != MemoryPoolInfo::ResultState::MapFailed && state != MemoryPoolInfo::ResultState::InUse) { LOG_WARNING(Service_Audio, "Invalid ResultState from updating memory pools"); - return Service::Audio::ERR_INVALID_UPDATE_DATA; + return Service::Audio::ResultInvalidUpdateInfo; } } @@ -423,7 +423,7 @@ Result InfoUpdater::UpdateMemoryPools(std::span<MemoryPoolInfo> memory_pools, LOG_ERROR(Service_Audio, "Consumed an incorrect memory pool size, header size={}, consumed={}", in_header->memory_pool_size, consumed_input_size); - return Service::Audio::ERR_INVALID_UPDATE_DATA; + return Service::Audio::ResultInvalidUpdateInfo; } input += consumed_input_size; @@ -453,7 +453,7 @@ Result InfoUpdater::UpdatePerformanceBuffer(std::span<u8> performance_output, LOG_ERROR(Service_Audio, "Consumed an incorrect performance size, header size={}, consumed={}", in_header->performance_buffer_size, consumed_input_size); - return Service::Audio::ERR_INVALID_UPDATE_DATA; + return Service::Audio::ResultInvalidUpdateInfo; } input += consumed_input_size; @@ -467,18 +467,18 @@ Result InfoUpdater::UpdateBehaviorInfo(BehaviorInfo& behaviour_) { const auto in_params{reinterpret_cast<const BehaviorInfo::InParameter*>(input)}; if (!CheckValidRevision(in_params->revision)) { - return Service::Audio::ERR_INVALID_UPDATE_DATA; + return Service::Audio::ResultInvalidUpdateInfo; } if (in_params->revision != behaviour_.GetUserRevision()) { - return Service::Audio::ERR_INVALID_UPDATE_DATA; + return Service::Audio::ResultInvalidUpdateInfo; } behaviour_.ClearError(); behaviour_.UpdateFlags(in_params->flags); if (in_header->behaviour_size != sizeof(BehaviorInfo::InParameter)) { - return Service::Audio::ERR_INVALID_UPDATE_DATA; + return Service::Audio::ResultInvalidUpdateInfo; } input += sizeof(BehaviorInfo::InParameter); @@ -500,7 +500,7 @@ Result InfoUpdater::UpdateErrorInfo(const BehaviorInfo& behaviour_) { Result InfoUpdater::UpdateSplitterInfo(SplitterContext& splitter_context) { u32 consumed_size{0}; if (!splitter_context.Update(input, consumed_size)) { - return Service::Audio::ERR_INVALID_UPDATE_DATA; + return Service::Audio::ResultInvalidUpdateInfo; } input += consumed_size; @@ -529,9 +529,9 @@ Result InfoUpdater::UpdateRendererInfo(const u64 elapsed_frames) { Result InfoUpdater::CheckConsumedSize() { if (CpuAddr(input) - CpuAddr(input_origin.data()) != expected_input_size) { - return Service::Audio::ERR_INVALID_UPDATE_DATA; + return Service::Audio::ResultInvalidUpdateInfo; } else if (CpuAddr(output) - CpuAddr(output_origin.data()) != expected_output_size) { - return Service::Audio::ERR_INVALID_UPDATE_DATA; + return Service::Audio::ResultInvalidUpdateInfo; } return ResultSuccess; } diff --git a/src/audio_core/renderer/command/effect/reverb.cpp b/src/audio_core/renderer/command/effect/reverb.cpp index 6fe844ff0..8b9b65214 100644 --- a/src/audio_core/renderer/command/effect/reverb.cpp +++ b/src/audio_core/renderer/command/effect/reverb.cpp @@ -308,7 +308,8 @@ static void ApplyReverbEffect(const ReverbInfo::ParameterVersion2& params, Rever } Common::FixedPoint<50, 14> pre_delay_sample{ - state.pre_delay_line.Read() * Common::FixedPoint<50, 14>::from_base(params.late_gain)}; + state.pre_delay_line.TapOut(state.pre_delay_time) * + Common::FixedPoint<50, 14>::from_base(params.late_gain)}; std::array<Common::FixedPoint<50, 14>, ReverbInfo::MaxDelayLines> mix_matrix{ state.prev_feedback_output[2] + state.prev_feedback_output[1] + pre_delay_sample, diff --git a/src/audio_core/renderer/effect/effect_info_base.h b/src/audio_core/renderer/effect/effect_info_base.h index 8525fde05..dbdccf278 100644 --- a/src/audio_core/renderer/effect/effect_info_base.h +++ b/src/audio_core/renderer/effect/effect_info_base.h @@ -192,7 +192,7 @@ public: /** * Get this effect's parameter data. * - * @return Pointer to the parametter, must be cast to the correct type. + * @return Pointer to the parameter, must be cast to the correct type. */ u8* GetParameter() { return parameter.data(); @@ -201,7 +201,7 @@ public: /** * Get this effect's parameter data. * - * @return Pointer to the parametter, must be cast to the correct type. + * @return Pointer to the parameter, must be cast to the correct type. */ u8* GetStateBuffer() { return state.data(); diff --git a/src/audio_core/renderer/effect/i3dl2.h b/src/audio_core/renderer/effect/i3dl2.h index 1ebbc5c4c..6e3ffd1d4 100644 --- a/src/audio_core/renderer/effect/i3dl2.h +++ b/src/audio_core/renderer/effect/i3dl2.h @@ -104,7 +104,8 @@ public: } void Write(const Common::FixedPoint<50, 14> sample) { - *(input++) = sample; + *input = sample; + input++; if (input >= buffer_end) { input = buffer.data(); } diff --git a/src/audio_core/renderer/effect/reverb.h b/src/audio_core/renderer/effect/reverb.h index a72475c3c..6cc345ef6 100644 --- a/src/audio_core/renderer/effect/reverb.h +++ b/src/audio_core/renderer/effect/reverb.h @@ -79,12 +79,10 @@ public: return; } sample_count = delay_time; - input = &buffer[(output - buffer.data() + sample_count) % (sample_count_max + 1)]; + input = &buffer[0]; } Common::FixedPoint<50, 14> Tick(const Common::FixedPoint<50, 14> sample) { - Write(sample); - auto out_sample{Read()}; output++; @@ -92,6 +90,7 @@ public: output = buffer.data(); } + Write(sample); return out_sample; } @@ -100,7 +99,8 @@ public: } void Write(const Common::FixedPoint<50, 14> sample) { - *(input++) = sample; + *input = sample; + input++; if (input >= buffer_end) { input = buffer.data(); } diff --git a/src/audio_core/renderer/memory/memory_pool_info.h b/src/audio_core/renderer/memory/memory_pool_info.h index 537a466ec..80c571bc1 100644 --- a/src/audio_core/renderer/memory/memory_pool_info.h +++ b/src/audio_core/renderer/memory/memory_pool_info.h @@ -29,7 +29,7 @@ public: */ enum class State { Invalid, - Aquired, + Acquired, RequestDetach, Detached, RequestAttach, diff --git a/src/audio_core/renderer/memory/pool_mapper.cpp b/src/audio_core/renderer/memory/pool_mapper.cpp index 2baf2ce08..7fd2b5f47 100644 --- a/src/audio_core/renderer/memory/pool_mapper.cpp +++ b/src/audio_core/renderer/memory/pool_mapper.cpp @@ -92,7 +92,7 @@ bool PoolMapper::TryAttachBuffer(BehaviorInfo::ErrorInfo& error_info, AddressInf address_info.Setup(address, size); if (!FillDspAddr(address_info)) { - error_info.error_code = Service::Audio::ERR_POOL_MAPPING_FAILED; + error_info.error_code = Service::Audio::ResultInvalidAddressInfo; error_info.address = address; return force_map; } diff --git a/src/audio_core/renderer/mix/mix_context.h b/src/audio_core/renderer/mix/mix_context.h index da3aa2829..bcd9637da 100644 --- a/src/audio_core/renderer/mix/mix_context.h +++ b/src/audio_core/renderer/mix/mix_context.h @@ -93,7 +93,7 @@ public: * Splitter sort, traverse the splitter node graph and sort the sorted mixes from results. * * @param splitter_context - Splitter context for the sort. - * @return True if the sort was successful, othewise false. + * @return True if the sort was successful, otherwise false. */ bool TSortInfo(const SplitterContext& splitter_context); diff --git a/src/audio_core/renderer/performance/performance_detail.h b/src/audio_core/renderer/performance/performance_detail.h index 3a4897e60..f603b9026 100644 --- a/src/audio_core/renderer/performance/performance_detail.h +++ b/src/audio_core/renderer/performance/performance_detail.h @@ -33,7 +33,7 @@ struct PerformanceDetailVersion1 { /* 0x0D */ PerformanceEntryType entry_type; }; static_assert(sizeof(PerformanceDetailVersion1) == 0x10, - "PerformanceDetailVersion1 has the worng size!"); + "PerformanceDetailVersion1 has the wrong size!"); struct PerformanceDetailVersion2 { /* 0x00 */ u32 node_id; @@ -45,6 +45,6 @@ struct PerformanceDetailVersion2 { /* 0x14 */ char unk14[0x4]; }; static_assert(sizeof(PerformanceDetailVersion2) == 0x18, - "PerformanceDetailVersion2 has the worng size!"); + "PerformanceDetailVersion2 has the wrong size!"); } // namespace AudioCore::AudioRenderer diff --git a/src/audio_core/renderer/performance/performance_entry.h b/src/audio_core/renderer/performance/performance_entry.h index d1b21406b..d6b1158db 100644 --- a/src/audio_core/renderer/performance/performance_entry.h +++ b/src/audio_core/renderer/performance/performance_entry.h @@ -22,7 +22,7 @@ struct PerformanceEntryVersion1 { /* 0x0C */ PerformanceEntryType entry_type; }; static_assert(sizeof(PerformanceEntryVersion1) == 0x10, - "PerformanceEntryVersion1 has the worng size!"); + "PerformanceEntryVersion1 has the wrong size!"); struct PerformanceEntryVersion2 { /* 0x00 */ u32 node_id; @@ -32,6 +32,6 @@ struct PerformanceEntryVersion2 { /* 0x0D */ char unk0D[0xB]; }; static_assert(sizeof(PerformanceEntryVersion2) == 0x18, - "PerformanceEntryVersion2 has the worng size!"); + "PerformanceEntryVersion2 has the wrong size!"); } // namespace AudioCore::AudioRenderer diff --git a/src/audio_core/renderer/performance/performance_frame_header.h b/src/audio_core/renderer/performance/performance_frame_header.h index 707cc0afb..b1848284e 100644 --- a/src/audio_core/renderer/performance/performance_frame_header.h +++ b/src/audio_core/renderer/performance/performance_frame_header.h @@ -16,7 +16,7 @@ struct PerformanceFrameHeaderVersion1 { /* 0x14 */ u32 frame_index; }; static_assert(sizeof(PerformanceFrameHeaderVersion1) == 0x18, - "PerformanceFrameHeaderVersion1 has the worng size!"); + "PerformanceFrameHeaderVersion1 has the wrong size!"); struct PerformanceFrameHeaderVersion2 { /* 0x00 */ u32 magic; // "PERF" @@ -31,6 +31,6 @@ struct PerformanceFrameHeaderVersion2 { /* 0x25 */ char unk25[0xB]; }; static_assert(sizeof(PerformanceFrameHeaderVersion2) == 0x30, - "PerformanceFrameHeaderVersion2 has the worng size!"); + "PerformanceFrameHeaderVersion2 has the wrong size!"); } // namespace AudioCore::AudioRenderer diff --git a/src/audio_core/renderer/splitter/splitter_context.h b/src/audio_core/renderer/splitter/splitter_context.h index cfd092b4f..1a63db1d3 100644 --- a/src/audio_core/renderer/splitter/splitter_context.h +++ b/src/audio_core/renderer/splitter/splitter_context.h @@ -55,7 +55,7 @@ public: /** * Get the total number of splitter destinations. * - * @return Number of destiantions. + * @return Number of destinations. */ u32 GetDataCount() const; diff --git a/src/audio_core/renderer/splitter/splitter_destinations_data.h b/src/audio_core/renderer/splitter/splitter_destinations_data.h index bd3d55748..d55ce0ad3 100644 --- a/src/audio_core/renderer/splitter/splitter_destinations_data.h +++ b/src/audio_core/renderer/splitter/splitter_destinations_data.h @@ -87,7 +87,7 @@ public: /** * Update this destination. * - * @param params - Inpout parameters to update the destination. + * @param params - Input parameters to update the destination. */ void Update(const InParameter& params); @@ -126,9 +126,9 @@ private: std::array<f32, MaxMixBuffers> prev_mix_volumes{0.0f}; /// Next destination in the mix chain SplitterDestinationData* next{}; - /// Is this destiantion in use? + /// Is this destination in use? bool in_use{}; - /// Does this destiantion need its volumes updated? + /// Does this destination need its volumes updated? bool need_update{}; }; diff --git a/src/audio_core/renderer/splitter/splitter_info.h b/src/audio_core/renderer/splitter/splitter_info.h index d1d75064c..b0ad01fe0 100644 --- a/src/audio_core/renderer/splitter/splitter_info.h +++ b/src/audio_core/renderer/splitter/splitter_info.h @@ -49,14 +49,14 @@ public: /** * Get the number of destinations in this splitter. * - * @return The number of destiantions. + * @return The number of destinations. */ u32 GetDestinationCount() const; /** * Set the number of destinations in this splitter. * - * @param count - The new number of destiantions. + * @param count - The new number of destinations. */ void SetDestinationCount(u32 count); diff --git a/src/audio_core/renderer/system.cpp b/src/audio_core/renderer/system.cpp index 31cbee282..28f063641 100644 --- a/src/audio_core/renderer/system.cpp +++ b/src/audio_core/renderer/system.cpp @@ -101,15 +101,15 @@ Result System::Initialize(const AudioRendererParameterInternal& params, Kernel::KTransferMemory* transfer_memory, u64 transfer_memory_size, u32 process_handle_, u64 applet_resource_user_id_, s32 session_id_) { if (!CheckValidRevision(params.revision)) { - return Service::Audio::ERR_INVALID_REVISION; + return Service::Audio::ResultInvalidRevision; } if (GetWorkBufferSize(params) > transfer_memory_size) { - return Service::Audio::ERR_INSUFFICIENT_BUFFER_SIZE; + return Service::Audio::ResultInsufficientBuffer; } if (process_handle_ == 0) { - return Service::Audio::ERR_INVALID_PROCESS_HANDLE; + return Service::Audio::ResultInvalidHandle; } behavior.SetUserLibRevision(params.revision); @@ -143,19 +143,19 @@ Result System::Initialize(const AudioRendererParameterInternal& params, samples_workbuffer = allocator.Allocate<s32>((voice_channels + mix_buffer_count) * sample_count, 0x10); if (samples_workbuffer.empty()) { - return Service::Audio::ERR_INSUFFICIENT_BUFFER_SIZE; + return Service::Audio::ResultInsufficientBuffer; } auto upsampler_workbuffer{allocator.Allocate<s32>( (voice_channels + mix_buffer_count) * TargetSampleCount * upsampler_count, 0x10)}; if (upsampler_workbuffer.empty()) { - return Service::Audio::ERR_INSUFFICIENT_BUFFER_SIZE; + return Service::Audio::ResultInsufficientBuffer; } depop_buffer = allocator.Allocate<s32>(Common::AlignUp(static_cast<u32>(mix_buffer_count), 0x40), 0x40); if (depop_buffer.empty()) { - return Service::Audio::ERR_INSUFFICIENT_BUFFER_SIZE; + return Service::Audio::ResultInsufficientBuffer; } // invalidate samples_workbuffer DSP cache @@ -166,12 +166,12 @@ Result System::Initialize(const AudioRendererParameterInternal& params, } if (voice_infos.empty()) { - return Service::Audio::ERR_INSUFFICIENT_BUFFER_SIZE; + return Service::Audio::ResultInsufficientBuffer; } auto sorted_voice_infos{allocator.Allocate<VoiceInfo*>(params.voices, 0x10)}; if (sorted_voice_infos.empty()) { - return Service::Audio::ERR_INSUFFICIENT_BUFFER_SIZE; + return Service::Audio::ResultInsufficientBuffer; } std::memset(sorted_voice_infos.data(), 0, sorted_voice_infos.size_bytes()); @@ -183,12 +183,12 @@ Result System::Initialize(const AudioRendererParameterInternal& params, } if (voice_channel_resources.empty()) { - return Service::Audio::ERR_INSUFFICIENT_BUFFER_SIZE; + return Service::Audio::ResultInsufficientBuffer; } auto voice_cpu_states{allocator.Allocate<VoiceState>(params.voices, 0x10)}; if (voice_cpu_states.empty()) { - return Service::Audio::ERR_INSUFFICIENT_BUFFER_SIZE; + return Service::Audio::ResultInsufficientBuffer; } for (auto& voice_state : voice_cpu_states) { @@ -198,7 +198,7 @@ Result System::Initialize(const AudioRendererParameterInternal& params, auto mix_infos{allocator.Allocate<MixInfo>(params.sub_mixes + 1, 0x10)}; if (mix_infos.empty()) { - return Service::Audio::ERR_INSUFFICIENT_BUFFER_SIZE; + return Service::Audio::ResultInsufficientBuffer; } u32 effect_process_order_count{0}; @@ -208,7 +208,7 @@ Result System::Initialize(const AudioRendererParameterInternal& params, effect_process_order_count = params.effects * (params.sub_mixes + 1); effect_process_order_buffer = allocator.Allocate<s32>(effect_process_order_count, 0x10); if (effect_process_order_buffer.empty()) { - return Service::Audio::ERR_INSUFFICIENT_BUFFER_SIZE; + return Service::Audio::ResultInsufficientBuffer; } } @@ -222,7 +222,7 @@ Result System::Initialize(const AudioRendererParameterInternal& params, auto sorted_mix_infos{allocator.Allocate<MixInfo*>(params.sub_mixes + 1, 0x10)}; if (sorted_mix_infos.empty()) { - return Service::Audio::ERR_INSUFFICIENT_BUFFER_SIZE; + return Service::Audio::ResultInsufficientBuffer; } std::memset(sorted_mix_infos.data(), 0, sorted_mix_infos.size_bytes()); @@ -235,7 +235,7 @@ Result System::Initialize(const AudioRendererParameterInternal& params, auto edge_matrix_workbuffer{allocator.Allocate<u8>(edge_matrix_size, 1)}; if (node_states_workbuffer.empty() || edge_matrix_workbuffer.size() == 0) { - return Service::Audio::ERR_INSUFFICIENT_BUFFER_SIZE; + return Service::Audio::ResultInsufficientBuffer; } mix_context.Initialize(sorted_mix_infos, mix_infos, params.sub_mixes + 1, @@ -250,7 +250,7 @@ Result System::Initialize(const AudioRendererParameterInternal& params, upsampler_manager = allocator.Allocate<UpsamplerManager>(1, 0x10).data(); if (upsampler_manager == nullptr) { - return Service::Audio::ERR_INSUFFICIENT_BUFFER_SIZE; + return Service::Audio::ResultInsufficientBuffer; } memory_pool_workbuffer = allocator.Allocate<MemoryPoolInfo>(memory_pool_count, 0x10); @@ -259,18 +259,18 @@ Result System::Initialize(const AudioRendererParameterInternal& params, } if (memory_pool_workbuffer.empty() && memory_pool_count > 0) { - return Service::Audio::ERR_INSUFFICIENT_BUFFER_SIZE; + return Service::Audio::ResultInsufficientBuffer; } if (!splitter_context.Initialize(behavior, params, allocator)) { - return Service::Audio::ERR_INSUFFICIENT_BUFFER_SIZE; + return Service::Audio::ResultInsufficientBuffer; } std::span<EffectResultState> effect_result_states_cpu{}; if (behavior.IsEffectInfoVersion2Supported() && params.effects > 0) { effect_result_states_cpu = allocator.Allocate<EffectResultState>(params.effects, 0x10); if (effect_result_states_cpu.empty()) { - return Service::Audio::ERR_INSUFFICIENT_BUFFER_SIZE; + return Service::Audio::ResultInsufficientBuffer; } std::memset(effect_result_states_cpu.data(), 0, effect_result_states_cpu.size_bytes()); } @@ -289,7 +289,7 @@ Result System::Initialize(const AudioRendererParameterInternal& params, upsampler_workbuffer); if (upsampler_infos.empty()) { - return Service::Audio::ERR_INSUFFICIENT_BUFFER_SIZE; + return Service::Audio::ResultInsufficientBuffer; } auto effect_infos{allocator.Allocate<EffectInfoBase>(params.effects, 0x40)}; @@ -298,14 +298,14 @@ Result System::Initialize(const AudioRendererParameterInternal& params, } if (effect_infos.empty() && params.effects > 0) { - return Service::Audio::ERR_INSUFFICIENT_BUFFER_SIZE; + return Service::Audio::ResultInsufficientBuffer; } std::span<EffectResultState> effect_result_states_dsp{}; if (behavior.IsEffectInfoVersion2Supported() && params.effects > 0) { effect_result_states_dsp = allocator.Allocate<EffectResultState>(params.effects, 0x40); if (effect_result_states_dsp.empty()) { - return Service::Audio::ERR_INSUFFICIENT_BUFFER_SIZE; + return Service::Audio::ResultInsufficientBuffer; } std::memset(effect_result_states_dsp.data(), 0, effect_result_states_dsp.size_bytes()); } @@ -319,14 +319,14 @@ Result System::Initialize(const AudioRendererParameterInternal& params, } if (sinks.empty()) { - return Service::Audio::ERR_INSUFFICIENT_BUFFER_SIZE; + return Service::Audio::ResultInsufficientBuffer; } sink_context.Initialize(sinks, params.sinks); auto voice_dsp_states{allocator.Allocate<VoiceState>(params.voices, 0x40)}; if (voice_dsp_states.empty()) { - return Service::Audio::ERR_INSUFFICIENT_BUFFER_SIZE; + return Service::Audio::ResultInsufficientBuffer; } for (auto& voice_state : voice_dsp_states) { @@ -344,7 +344,7 @@ Result System::Initialize(const AudioRendererParameterInternal& params, 0xC}; performance_workbuffer = allocator.Allocate<u8>(perf_workbuffer_size, 0x40); if (performance_workbuffer.empty()) { - return Service::Audio::ERR_INSUFFICIENT_BUFFER_SIZE; + return Service::Audio::ResultInsufficientBuffer; } std::memset(performance_workbuffer.data(), 0, performance_workbuffer.size_bytes()); performance_manager.Initialize(performance_workbuffer, performance_workbuffer.size_bytes(), @@ -360,7 +360,7 @@ Result System::Initialize(const AudioRendererParameterInternal& params, command_workbuffer_size = allocator.GetRemainingSize(); command_workbuffer = allocator.Allocate<u8>(command_workbuffer_size, 0x40); if (command_workbuffer.empty()) { - return Service::Audio::ERR_INSUFFICIENT_BUFFER_SIZE; + return Service::Audio::ResultInsufficientBuffer; } command_buffer_size = 0; diff --git a/src/audio_core/renderer/system.h b/src/audio_core/renderer/system.h index 429196e41..e328783b6 100644 --- a/src/audio_core/renderer/system.h +++ b/src/audio_core/renderer/system.h @@ -154,7 +154,7 @@ public: ExecutionMode GetExecutionMode() const; /** - * Get the rendering deivce for this system. + * Get the rendering device for this system. * This is unused. * * @return Rendering device for this system. @@ -241,7 +241,7 @@ private: std::span<u8> command_workbuffer{}; /// Size of command workbuffer u64 command_workbuffer_size{}; - /// Numebr of commands in the workbuffer + /// Number of commands in the workbuffer u64 command_buffer_size{}; /// Manager for upsamplers UpsamplerManager* upsampler_manager{}; diff --git a/src/audio_core/renderer/system_manager.h b/src/audio_core/renderer/system_manager.h index 81457a3a1..415ddb74f 100644 --- a/src/audio_core/renderer/system_manager.h +++ b/src/audio_core/renderer/system_manager.h @@ -36,7 +36,7 @@ public: /** * Initialize the system manager, called when any system is registered. * - * @return True if sucessfully initialized, otherwise false. + * @return True if successfully initialized, otherwise false. */ bool InitializeUnsafe(); @@ -50,7 +50,7 @@ public: * The manager does not own the system, so do not free it without calling Remove. * * @param system - The system to add. - * @return True if succesfully added, otherwise false. + * @return True if successfully added, otherwise false. */ bool Add(System& system); @@ -58,7 +58,7 @@ public: * Remove an audio render system from the manager. * * @param system - The system to remove. - * @return True if succesfully removed, otherwise false. + * @return True if successfully removed, otherwise false. */ bool Remove(System& system); diff --git a/src/audio_core/renderer/voice/voice_info.cpp b/src/audio_core/renderer/voice/voice_info.cpp index 1849eeb57..c0bfb23fc 100644 --- a/src/audio_core/renderer/voice/voice_info.cpp +++ b/src/audio_core/renderer/voice/voice_info.cpp @@ -181,7 +181,7 @@ void VoiceInfo::UpdateWaveBuffer(std::span<BehaviorInfo::ErrorInfo> error_info, if (wave_buffer_internal.start_offset * byte_size > wave_buffer_internal.size || wave_buffer_internal.end_offset * byte_size > wave_buffer_internal.size) { LOG_ERROR(Service_Audio, "Invalid PCM16 start/end wavebuffer sizes!"); - error_info[0].error_code = Service::Audio::ERR_INVALID_UPDATE_DATA; + error_info[0].error_code = Service::Audio::ResultInvalidUpdateInfo; error_info[0].address = wave_buffer_internal.address; return; } @@ -192,7 +192,7 @@ void VoiceInfo::UpdateWaveBuffer(std::span<BehaviorInfo::ErrorInfo> error_info, if (wave_buffer_internal.start_offset * byte_size > wave_buffer_internal.size || wave_buffer_internal.end_offset * byte_size > wave_buffer_internal.size) { LOG_ERROR(Service_Audio, "Invalid PCMFloat start/end wavebuffer sizes!"); - error_info[0].error_code = Service::Audio::ERR_INVALID_UPDATE_DATA; + error_info[0].error_code = Service::Audio::ResultInvalidUpdateInfo; error_info[0].address = wave_buffer_internal.address; return; } @@ -216,7 +216,7 @@ void VoiceInfo::UpdateWaveBuffer(std::span<BehaviorInfo::ErrorInfo> error_info, if (start > static_cast<s64>(wave_buffer_internal.size) || end > static_cast<s64>(wave_buffer_internal.size)) { LOG_ERROR(Service_Audio, "Invalid ADPCM start/end wavebuffer sizes!"); - error_info[0].error_code = Service::Audio::ERR_INVALID_UPDATE_DATA; + error_info[0].error_code = Service::Audio::ResultInvalidUpdateInfo; error_info[0].address = wave_buffer_internal.address; return; } @@ -228,7 +228,7 @@ void VoiceInfo::UpdateWaveBuffer(std::span<BehaviorInfo::ErrorInfo> error_info, if (wave_buffer_internal.start_offset < 0 || wave_buffer_internal.end_offset < 0) { LOG_ERROR(Service_Audio, "Invalid input start/end wavebuffer sizes!"); - error_info[0].error_code = Service::Audio::ERR_INVALID_UPDATE_DATA; + error_info[0].error_code = Service::Audio::ResultInvalidUpdateInfo; error_info[0].address = wave_buffer_internal.address; return; } diff --git a/src/audio_core/renderer/voice/voice_info.h b/src/audio_core/renderer/voice/voice_info.h index 930180895..3c5d3e04f 100644 --- a/src/audio_core/renderer/voice/voice_info.h +++ b/src/audio_core/renderer/voice/voice_info.h @@ -183,7 +183,7 @@ public: void Initialize(); /** - * Does this voice ned an update? + * Does this voice need an update? * * @param params - Input parameters to check matching. * @@ -236,7 +236,7 @@ public: * * @param error_info - Output array of errors. * @param wave_buffer - The wavebuffer to be updated. - * @param wave_buffer_internal - Input parametters to be used for the update. + * @param wave_buffer_internal - Input parameters to be used for the update. * @param sample_format - Sample format of the wavebuffer. * @param valid - Is this wavebuffer valid? * @param pool_mapper - Used to map the wavebuffers. diff --git a/src/common/CMakeLists.txt b/src/common/CMakeLists.txt index 56b247ac4..61ab68864 100644 --- a/src/common/CMakeLists.txt +++ b/src/common/CMakeLists.txt @@ -91,6 +91,7 @@ add_library(common STATIC multi_level_page_table.h nvidia_flags.cpp nvidia_flags.h + overflow.h page_table.cpp page_table.h param_package.cpp @@ -113,6 +114,8 @@ add_library(common STATIC socket_types.h spin_lock.cpp spin_lock.h + steady_clock.cpp + steady_clock.h stream.cpp stream.h string_util.cpp @@ -142,6 +145,14 @@ add_library(common STATIC zstd_compression.h ) +if (WIN32) + target_sources(common PRIVATE + windows/timer_resolution.cpp + windows/timer_resolution.h + ) + target_link_libraries(common PRIVATE ntdll) +endif() + if(ARCHITECTURE_x86_64) target_sources(common PRIVATE diff --git a/src/common/announce_multiplayer_room.h b/src/common/announce_multiplayer_room.h index 4a3100fa4..f32060196 100644 --- a/src/common/announce_multiplayer_room.h +++ b/src/common/announce_multiplayer_room.h @@ -66,7 +66,7 @@ public: * @param description The room description * @param port The port of the room * @param net_version The version of the libNetwork that gets used - * @param has_password True if the room is passowrd protected + * @param has_password True if the room is password protected * @param preferred_game The preferred game of the room * @param preferred_game_id The title id of the preferred game */ diff --git a/src/common/bit_cast.h b/src/common/bit_cast.h index 535148b4d..c6110c542 100644 --- a/src/common/bit_cast.h +++ b/src/common/bit_cast.h @@ -3,19 +3,21 @@ #pragma once -#include <cstring> -#include <type_traits> +#include <version> + +#ifdef __cpp_lib_bit_cast +#include <bit> +#endif namespace Common { template <typename To, typename From> -[[nodiscard]] std::enable_if_t<sizeof(To) == sizeof(From) && std::is_trivially_copyable_v<From> && - std::is_trivially_copyable_v<To>, - To> -BitCast(const From& src) noexcept { - To dst; - std::memcpy(&dst, &src, sizeof(To)); - return dst; +constexpr inline To BitCast(const From& from) { +#ifdef __cpp_lib_bit_cast + return std::bit_cast<To>(from); +#else + return __builtin_bit_cast(To, from); +#endif } } // namespace Common diff --git a/src/common/fiber.cpp b/src/common/fiber.cpp index bc92b360b..c991b7cf1 100644 --- a/src/common/fiber.cpp +++ b/src/common/fiber.cpp @@ -90,7 +90,7 @@ Fiber::~Fiber() { } void Fiber::Exit() { - ASSERT_MSG(impl->is_thread_fiber, "Exitting non main thread fiber"); + ASSERT_MSG(impl->is_thread_fiber, "Exiting non main thread fiber"); if (!impl->is_thread_fiber) { return; } diff --git a/src/common/fixed_point.h b/src/common/fixed_point.h index f899b0d54..b0f3ae2cc 100644 --- a/src/common/fixed_point.h +++ b/src/common/fixed_point.h @@ -22,7 +22,7 @@ class FixedPoint; namespace detail { // helper templates to make magic with types :) -// these allow us to determine resonable types from +// these allow us to determine reasonable types from // a desired size, they also let us infer the next largest type // from a type which is nice for the division op template <size_t T> diff --git a/src/common/host_memory.cpp b/src/common/host_memory.cpp index 611c7d1a3..8e4f1f97a 100644 --- a/src/common/host_memory.cpp +++ b/src/common/host_memory.cpp @@ -322,7 +322,7 @@ private: } /// Return true when a given memory region is a "nieche" and the placeholders don't have to be - /// splitted. + /// split. bool IsNiechePlaceholder(size_t virtual_offset, size_t length) const { const auto it = placeholders.upper_bound({virtual_offset, virtual_offset + length}); if (it != placeholders.end() && it->lower() == virtual_offset + length) { @@ -484,7 +484,7 @@ class HostMemory::Impl { public: explicit Impl(size_t /*backing_size */, size_t /* virtual_size */) { // This is just a place holder. - // Please implement fastmem in a propper way on your platform. + // Please implement fastmem in a proper way on your platform. throw std::bad_alloc{}; } diff --git a/src/common/input.h b/src/common/input.h index b5748a6c8..51b277c1f 100644 --- a/src/common/input.h +++ b/src/common/input.h @@ -15,7 +15,7 @@ namespace Common::Input { -// Type of data that is expected to recieve or send +// Type of data that is expected to receive or send enum class InputType { None, Battery, @@ -46,7 +46,7 @@ enum class PollingMode { // Constant polling of buttons, analogs and motion data Active, // Only update on button change, digital analogs - Pasive, + Passive, // Enable near field communication polling NFC, // Enable infrared camera polling @@ -103,7 +103,7 @@ enum class VibrationAmplificationType { struct AnalogProperties { // Anything below this value will be detected as zero float deadzone{}; - // Anyting above this values will be detected as one + // Anything above this values will be detected as one float range{1.0f}; // Minimum value to be detected as active float threshold{0.5f}; @@ -209,7 +209,7 @@ struct LedStatus { bool led_4{}; }; -// Raw data fom camera +// Raw data from camera struct CameraStatus { CameraFormat format{CameraFormat::None}; std::vector<u8> data{}; @@ -428,7 +428,7 @@ inline void UnregisterOutputFactory(const std::string& name) { } /** - * Create an input device from given paramters. + * Create an input device from given parameters. * @tparam InputDeviceType the type of input devices to create * @param params a serialized ParamPackage string that contains all parameters for creating the * device diff --git a/src/common/logging/filter.cpp b/src/common/logging/filter.cpp index a959acb74..c95909561 100644 --- a/src/common/logging/filter.cpp +++ b/src/common/logging/filter.cpp @@ -119,7 +119,7 @@ bool ParseFilterRule(Filter& instance, Iterator begin, Iterator end) { SUB(Service, NPNS) \ SUB(Service, NS) \ SUB(Service, NVDRV) \ - SUB(Service, NVFlinger) \ + SUB(Service, Nvnflinger) \ SUB(Service, OLSC) \ SUB(Service, PCIE) \ SUB(Service, PCTL) \ diff --git a/src/common/logging/types.h b/src/common/logging/types.h index 595c15ada..8356e3183 100644 --- a/src/common/logging/types.h +++ b/src/common/logging/types.h @@ -29,107 +29,107 @@ enum class Level : u8 { * filter.cpp. */ enum class Class : u8 { - Log, ///< Messages about the log system itself - Common, ///< Library routines - Common_Filesystem, ///< Filesystem interface library - Common_Memory, ///< Memory mapping and management functions - Core, ///< LLE emulation core - Core_ARM, ///< ARM CPU core - Core_Timing, ///< CoreTiming functions - Config, ///< Emulator configuration (including commandline) - Debug, ///< Debugging tools - Debug_Emulated, ///< Debug messages from the emulated programs - Debug_GPU, ///< GPU debugging tools - Debug_Breakpoint, ///< Logging breakpoints and watchpoints - Debug_GDBStub, ///< GDB Stub - Kernel, ///< The HLE implementation of the CTR kernel - Kernel_SVC, ///< Kernel system calls - Service, ///< HLE implementation of system services. Each major service - ///< should have its own subclass. - Service_ACC, ///< The ACC (Accounts) service - Service_AM, ///< The AM (Applet manager) service - Service_AOC, ///< The AOC (AddOn Content) service - Service_APM, ///< The APM (Performance) service - Service_ARP, ///< The ARP service - Service_Audio, ///< The Audio (Audio control) service - Service_BCAT, ///< The BCAT service - Service_BGTC, ///< The BGTC (Background Task Controller) service - Service_BPC, ///< The BPC service - Service_BTDRV, ///< The Bluetooth driver service - Service_BTM, ///< The BTM service - Service_Capture, ///< The capture service - Service_ERPT, ///< The error reporting service - Service_ETicket, ///< The ETicket service - Service_EUPLD, ///< The error upload service - Service_Fatal, ///< The Fatal service - Service_FGM, ///< The FGM service - Service_Friend, ///< The friend service - Service_FS, ///< The FS (Filesystem) service - Service_GRC, ///< The game recording service - Service_HID, ///< The HID (Human interface device) service - Service_IRS, ///< The IRS service - Service_JIT, ///< The JIT service - Service_LBL, ///< The LBL (LCD backlight) service - Service_LDN, ///< The LDN (Local domain network) service - Service_LDR, ///< The loader service - Service_LM, ///< The LM (Logger) service - Service_Migration, ///< The migration service - Service_Mii, ///< The Mii service - Service_MM, ///< The MM (Multimedia) service - Service_MNPP, ///< The MNPP service - Service_NCM, ///< The NCM service - Service_NFC, ///< The NFC (Near-field communication) service - Service_NFP, ///< The NFP service - Service_NGCT, ///< The NGCT (No Good Content for Terra) service - Service_NIFM, ///< The NIFM (Network interface) service - Service_NIM, ///< The NIM service - Service_NOTIF, ///< The NOTIF (Notification) service - Service_NPNS, ///< The NPNS service - Service_NS, ///< The NS services - Service_NVDRV, ///< The NVDRV (Nvidia driver) service - Service_NVFlinger, ///< The NVFlinger service - Service_OLSC, ///< The OLSC service - Service_PCIE, ///< The PCIe service - Service_PCTL, ///< The PCTL (Parental control) service - Service_PCV, ///< The PCV service - Service_PM, ///< The PM service - Service_PREPO, ///< The PREPO (Play report) service - Service_PSC, ///< The PSC service - Service_PTM, ///< The PTM service - Service_SET, ///< The SET (Settings) service - Service_SM, ///< The SM (Service manager) service - Service_SPL, ///< The SPL service - Service_SSL, ///< The SSL service - Service_TCAP, ///< The TCAP service. - Service_Time, ///< The time service - Service_USB, ///< The USB (Universal Serial Bus) service - Service_VI, ///< The VI (Video interface) service - Service_WLAN, ///< The WLAN (Wireless local area network) service - HW, ///< Low-level hardware emulation - HW_Memory, ///< Memory-map and address translation - HW_LCD, ///< LCD register emulation - HW_GPU, ///< GPU control emulation - HW_AES, ///< AES engine emulation - IPC, ///< IPC interface - Frontend, ///< Emulator UI - Render, ///< Emulator video output and hardware acceleration - Render_Software, ///< Software renderer backend - Render_OpenGL, ///< OpenGL backend - Render_Vulkan, ///< Vulkan backend - Shader, ///< Shader recompiler - Shader_SPIRV, ///< Shader SPIR-V code generation - Shader_GLASM, ///< Shader GLASM code generation - Shader_GLSL, ///< Shader GLSL code generation - Audio, ///< Audio emulation - Audio_DSP, ///< The HLE implementation of the DSP - Audio_Sink, ///< Emulator audio output backend - Loader, ///< ROM loader - CheatEngine, ///< Memory manipulation and engine VM functions - Crypto, ///< Cryptographic engine/functions - Input, ///< Input emulation - Network, ///< Network emulation - WebService, ///< Interface to yuzu Web Services - Count ///< Total number of logging classes + Log, ///< Messages about the log system itself + Common, ///< Library routines + Common_Filesystem, ///< Filesystem interface library + Common_Memory, ///< Memory mapping and management functions + Core, ///< LLE emulation core + Core_ARM, ///< ARM CPU core + Core_Timing, ///< CoreTiming functions + Config, ///< Emulator configuration (including commandline) + Debug, ///< Debugging tools + Debug_Emulated, ///< Debug messages from the emulated programs + Debug_GPU, ///< GPU debugging tools + Debug_Breakpoint, ///< Logging breakpoints and watchpoints + Debug_GDBStub, ///< GDB Stub + Kernel, ///< The HLE implementation of the CTR kernel + Kernel_SVC, ///< Kernel system calls + Service, ///< HLE implementation of system services. Each major service + ///< should have its own subclass. + Service_ACC, ///< The ACC (Accounts) service + Service_AM, ///< The AM (Applet manager) service + Service_AOC, ///< The AOC (AddOn Content) service + Service_APM, ///< The APM (Performance) service + Service_ARP, ///< The ARP service + Service_Audio, ///< The Audio (Audio control) service + Service_BCAT, ///< The BCAT service + Service_BGTC, ///< The BGTC (Background Task Controller) service + Service_BPC, ///< The BPC service + Service_BTDRV, ///< The Bluetooth driver service + Service_BTM, ///< The BTM service + Service_Capture, ///< The capture service + Service_ERPT, ///< The error reporting service + Service_ETicket, ///< The ETicket service + Service_EUPLD, ///< The error upload service + Service_Fatal, ///< The Fatal service + Service_FGM, ///< The FGM service + Service_Friend, ///< The friend service + Service_FS, ///< The FS (Filesystem) service + Service_GRC, ///< The game recording service + Service_HID, ///< The HID (Human interface device) service + Service_IRS, ///< The IRS service + Service_JIT, ///< The JIT service + Service_LBL, ///< The LBL (LCD backlight) service + Service_LDN, ///< The LDN (Local domain network) service + Service_LDR, ///< The loader service + Service_LM, ///< The LM (Logger) service + Service_Migration, ///< The migration service + Service_Mii, ///< The Mii service + Service_MM, ///< The MM (Multimedia) service + Service_MNPP, ///< The MNPP service + Service_NCM, ///< The NCM service + Service_NFC, ///< The NFC (Near-field communication) service + Service_NFP, ///< The NFP service + Service_NGCT, ///< The NGCT (No Good Content for Terra) service + Service_NIFM, ///< The NIFM (Network interface) service + Service_NIM, ///< The NIM service + Service_NOTIF, ///< The NOTIF (Notification) service + Service_NPNS, ///< The NPNS service + Service_NS, ///< The NS services + Service_NVDRV, ///< The NVDRV (Nvidia driver) service + Service_Nvnflinger, ///< The Nvnflinger service + Service_OLSC, ///< The OLSC service + Service_PCIE, ///< The PCIe service + Service_PCTL, ///< The PCTL (Parental control) service + Service_PCV, ///< The PCV service + Service_PM, ///< The PM service + Service_PREPO, ///< The PREPO (Play report) service + Service_PSC, ///< The PSC service + Service_PTM, ///< The PTM service + Service_SET, ///< The SET (Settings) service + Service_SM, ///< The SM (Service manager) service + Service_SPL, ///< The SPL service + Service_SSL, ///< The SSL service + Service_TCAP, ///< The TCAP service. + Service_Time, ///< The time service + Service_USB, ///< The USB (Universal Serial Bus) service + Service_VI, ///< The VI (Video interface) service + Service_WLAN, ///< The WLAN (Wireless local area network) service + HW, ///< Low-level hardware emulation + HW_Memory, ///< Memory-map and address translation + HW_LCD, ///< LCD register emulation + HW_GPU, ///< GPU control emulation + HW_AES, ///< AES engine emulation + IPC, ///< IPC interface + Frontend, ///< Emulator UI + Render, ///< Emulator video output and hardware acceleration + Render_Software, ///< Software renderer backend + Render_OpenGL, ///< OpenGL backend + Render_Vulkan, ///< Vulkan backend + Shader, ///< Shader recompiler + Shader_SPIRV, ///< Shader SPIR-V code generation + Shader_GLASM, ///< Shader GLASM code generation + Shader_GLSL, ///< Shader GLSL code generation + Audio, ///< Audio emulation + Audio_DSP, ///< The HLE implementation of the DSP + Audio_Sink, ///< Emulator audio output backend + Loader, ///< ROM loader + CheatEngine, ///< Memory manipulation and engine VM functions + Crypto, ///< Cryptographic engine/functions + Input, ///< Input emulation + Network, ///< Network emulation + WebService, ///< Interface to yuzu Web Services + Count ///< Total number of logging classes }; } // namespace Common::Log diff --git a/src/common/overflow.h b/src/common/overflow.h new file mode 100644 index 000000000..44d8e7e73 --- /dev/null +++ b/src/common/overflow.h @@ -0,0 +1,22 @@ +// SPDX-FileCopyrightText: Copyright 2023 yuzu Emulator Project +// SPDX-License-Identifier: GPL-2.0-or-later + +#pragma once + +#include <type_traits> +#include "bit_cast.h" + +namespace Common { + +template <typename T> + requires(std::is_integral_v<T> && std::is_signed_v<T>) +inline T WrappingAdd(T lhs, T rhs) { + using U = std::make_unsigned_t<T>; + + U lhs_u = BitCast<U>(lhs); + U rhs_u = BitCast<U>(rhs); + + return BitCast<T>(lhs_u + rhs_u); +} + +} // namespace Common diff --git a/src/common/settings.h b/src/common/settings.h index 512ecff69..b77a1580a 100644 --- a/src/common/settings.h +++ b/src/common/settings.h @@ -128,7 +128,7 @@ public: /** * Sets a default value, label, and setting value. * - * @param default_val Intial value of the setting, and default value of the setting + * @param default_val Initial value of the setting, and default value of the setting * @param name Label for the setting */ explicit Setting(const Type& default_val, const std::string& name) @@ -139,7 +139,7 @@ public: /** * Sets a default value, minimum value, maximum value, and label. * - * @param default_val Intial value of the setting, and default value of the setting + * @param default_val Initial value of the setting, and default value of the setting * @param min_val Sets the minimum allowed value of the setting * @param max_val Sets the maximum allowed value of the setting * @param name Label for the setting @@ -231,7 +231,7 @@ public: /** * Sets a default value, label, and setting value. * - * @param default_val Intial value of the setting, and default value of the setting + * @param default_val Initial value of the setting, and default value of the setting * @param name Label for the setting */ explicit SwitchableSetting(const Type& default_val, const std::string& name) @@ -242,7 +242,7 @@ public: /** * Sets a default value, minimum value, maximum value, and label. * - * @param default_val Intial value of the setting, and default value of the setting + * @param default_val Initial value of the setting, and default value of the setting * @param min_val Sets the minimum allowed value of the setting * @param max_val Sets the maximum allowed value of the setting * @param name Label for the setting @@ -503,7 +503,7 @@ struct Values { Setting<bool> tas_loop{false, "tas_loop"}; Setting<bool> mouse_panning{false, "mouse_panning"}; - Setting<u8, true> mouse_panning_sensitivity{10, 1, 100, "mouse_panning_sensitivity"}; + Setting<u8, true> mouse_panning_sensitivity{50, 1, 100, "mouse_panning_sensitivity"}; Setting<bool> mouse_enabled{false, "mouse_enabled"}; Setting<bool> emulate_analog_keyboard{false, "emulate_analog_keyboard"}; diff --git a/src/common/steady_clock.cpp b/src/common/steady_clock.cpp new file mode 100644 index 000000000..782859196 --- /dev/null +++ b/src/common/steady_clock.cpp @@ -0,0 +1,81 @@ +// SPDX-FileCopyrightText: Copyright 2023 yuzu Emulator Project +// SPDX-License-Identifier: GPL-2.0-or-later + +#if defined(_WIN32) +#include <windows.h> +#else +#include <time.h> +#endif + +#include "common/steady_clock.h" + +namespace Common { + +#ifdef _WIN32 +static s64 WindowsQueryPerformanceFrequency() { + LARGE_INTEGER frequency; + QueryPerformanceFrequency(&frequency); + return frequency.QuadPart; +} + +static s64 WindowsQueryPerformanceCounter() { + LARGE_INTEGER counter; + QueryPerformanceCounter(&counter); + return counter.QuadPart; +} + +static s64 GetSystemTimeNS() { + // GetSystemTimePreciseAsFileTime returns the file time in 100ns units. + static constexpr s64 Multiplier = 100; + // Convert Windows epoch to Unix epoch. + static constexpr s64 WindowsEpochToUnixEpochNS = 0x19DB1DED53E8000LL; + + FILETIME filetime; + GetSystemTimePreciseAsFileTime(&filetime); + return Multiplier * ((static_cast<s64>(filetime.dwHighDateTime) << 32) + + static_cast<s64>(filetime.dwLowDateTime)) - + WindowsEpochToUnixEpochNS; +} +#endif + +SteadyClock::time_point SteadyClock::Now() noexcept { +#if defined(_WIN32) + static const auto freq = WindowsQueryPerformanceFrequency(); + const auto counter = WindowsQueryPerformanceCounter(); + + // 10 MHz is a very common QPC frequency on modern PCs. + // Optimizing for this specific frequency can double the performance of + // this function by avoiding the expensive frequency conversion path. + static constexpr s64 TenMHz = 10'000'000; + + if (freq == TenMHz) [[likely]] { + static_assert(period::den % TenMHz == 0); + static constexpr s64 Multiplier = period::den / TenMHz; + return time_point{duration{counter * Multiplier}}; + } + + const auto whole = (counter / freq) * period::den; + const auto part = (counter % freq) * period::den / freq; + return time_point{duration{whole + part}}; +#elif defined(__APPLE__) + return time_point{duration{clock_gettime_nsec_np(CLOCK_MONOTONIC_RAW)}}; +#else + timespec ts; + clock_gettime(CLOCK_MONOTONIC, &ts); + return time_point{std::chrono::seconds{ts.tv_sec} + std::chrono::nanoseconds{ts.tv_nsec}}; +#endif +} + +RealTimeClock::time_point RealTimeClock::Now() noexcept { +#if defined(_WIN32) + return time_point{duration{GetSystemTimeNS()}}; +#elif defined(__APPLE__) + return time_point{duration{clock_gettime_nsec_np(CLOCK_REALTIME)}}; +#else + timespec ts; + clock_gettime(CLOCK_REALTIME, &ts); + return time_point{std::chrono::seconds{ts.tv_sec} + std::chrono::nanoseconds{ts.tv_nsec}}; +#endif +} + +}; // namespace Common diff --git a/src/common/steady_clock.h b/src/common/steady_clock.h new file mode 100644 index 000000000..dbd0e2513 --- /dev/null +++ b/src/common/steady_clock.h @@ -0,0 +1,34 @@ +// SPDX-FileCopyrightText: Copyright 2023 yuzu Emulator Project +// SPDX-License-Identifier: GPL-2.0-or-later + +#pragma once + +#include <chrono> + +#include "common/common_types.h" + +namespace Common { + +struct SteadyClock { + using rep = s64; + using period = std::nano; + using duration = std::chrono::nanoseconds; + using time_point = std::chrono::time_point<SteadyClock>; + + static constexpr bool is_steady = true; + + [[nodiscard]] static time_point Now() noexcept; +}; + +struct RealTimeClock { + using rep = s64; + using period = std::nano; + using duration = std::chrono::nanoseconds; + using time_point = std::chrono::time_point<RealTimeClock>; + + static constexpr bool is_steady = false; + + [[nodiscard]] static time_point Now() noexcept; +}; + +} // namespace Common diff --git a/src/common/swap.h b/src/common/swap.h index 037b82781..085baaf9a 100644 --- a/src/common/swap.h +++ b/src/common/swap.h @@ -229,7 +229,7 @@ public: value = swap(swap() - 1); return old; } - // Comparaison + // Comparison // v == i bool operator==(const swapped_t& i) const { return swap() == i.swap(); @@ -368,7 +368,7 @@ public: // Member /** todo **/ - // Arithmetics + // Arithmetic template <typename S, typename T2, typename F2> friend S operator+(const S& p, const swapped_t v); @@ -384,7 +384,7 @@ public: template <typename S, typename T2, typename F2> friend S operator%(const S& p, const swapped_t v); - // Arithmetics + assignments + // Arithmetic + assignments template <typename S, typename T2, typename F2> friend S operator+=(const S& p, const swapped_t v); @@ -415,7 +415,7 @@ public: friend bool operator==(const S& p, const swapped_t v); }; -// Arithmetics +// Arithmetic template <typename S, typename T, typename F> S operator+(const S& i, const swap_struct_t<T, F> v) { return i + v.swap(); @@ -441,7 +441,7 @@ S operator%(const S& i, const swap_struct_t<T, F> v) { return i % v.swap(); } -// Arithmetics + assignments +// Arithmetic + assignments template <typename S, typename T, typename F> S& operator+=(S& i, const swap_struct_t<T, F> v) { i += v.swap(); @@ -465,7 +465,7 @@ S operator&(const swap_struct_t<T, F> v, const S& i) { return static_cast<S>(v.swap() & i); } -// Comparaison +// Comparison template <typename S, typename T, typename F> bool operator<(const S& p, const swap_struct_t<T, F> v) { return p < v.swap(); diff --git a/src/common/wall_clock.cpp b/src/common/wall_clock.cpp index ae07f2811..817e71d52 100644 --- a/src/common/wall_clock.cpp +++ b/src/common/wall_clock.cpp @@ -1,6 +1,7 @@ // SPDX-FileCopyrightText: Copyright 2020 yuzu Emulator Project // SPDX-License-Identifier: GPL-2.0-or-later +#include "common/steady_clock.h" #include "common/uint128.h" #include "common/wall_clock.h" @@ -11,45 +12,32 @@ namespace Common { -using base_timer = std::chrono::steady_clock; -using base_time_point = std::chrono::time_point<base_timer>; - class StandardWallClock final : public WallClock { public: explicit StandardWallClock(u64 emulated_cpu_frequency_, u64 emulated_clock_frequency_) - : WallClock(emulated_cpu_frequency_, emulated_clock_frequency_, false) { - start_time = base_timer::now(); - } + : WallClock{emulated_cpu_frequency_, emulated_clock_frequency_, false}, + start_time{SteadyClock::Now()} {} std::chrono::nanoseconds GetTimeNS() override { - base_time_point current = base_timer::now(); - auto elapsed = current - start_time; - return std::chrono::duration_cast<std::chrono::nanoseconds>(elapsed); + return SteadyClock::Now() - start_time; } std::chrono::microseconds GetTimeUS() override { - base_time_point current = base_timer::now(); - auto elapsed = current - start_time; - return std::chrono::duration_cast<std::chrono::microseconds>(elapsed); + return std::chrono::duration_cast<std::chrono::microseconds>(GetTimeNS()); } std::chrono::milliseconds GetTimeMS() override { - base_time_point current = base_timer::now(); - auto elapsed = current - start_time; - return std::chrono::duration_cast<std::chrono::milliseconds>(elapsed); + return std::chrono::duration_cast<std::chrono::milliseconds>(GetTimeNS()); } u64 GetClockCycles() override { - std::chrono::nanoseconds time_now = GetTimeNS(); - const u128 temporary = - Common::Multiply64Into128(time_now.count(), emulated_clock_frequency); - return Common::Divide128On32(temporary, 1000000000).first; + const u128 temp = Common::Multiply64Into128(GetTimeNS().count(), emulated_clock_frequency); + return Common::Divide128On32(temp, NS_RATIO).first; } u64 GetCPUCycles() override { - std::chrono::nanoseconds time_now = GetTimeNS(); - const u128 temporary = Common::Multiply64Into128(time_now.count(), emulated_cpu_frequency); - return Common::Divide128On32(temporary, 1000000000).first; + const u128 temp = Common::Multiply64Into128(GetTimeNS().count(), emulated_cpu_frequency); + return Common::Divide128On32(temp, NS_RATIO).first; } void Pause([[maybe_unused]] bool is_paused) override { @@ -57,7 +45,7 @@ public: } private: - base_time_point start_time; + SteadyClock::time_point start_time; }; #ifdef ARCHITECTURE_x86_64 @@ -93,4 +81,9 @@ std::unique_ptr<WallClock> CreateBestMatchingClock(u64 emulated_cpu_frequency, #endif +std::unique_ptr<WallClock> CreateStandardWallClock(u64 emulated_cpu_frequency, + u64 emulated_clock_frequency) { + return std::make_unique<StandardWallClock>(emulated_cpu_frequency, emulated_clock_frequency); +} + } // namespace Common diff --git a/src/common/wall_clock.h b/src/common/wall_clock.h index 828a523a8..157ec5eae 100644 --- a/src/common/wall_clock.h +++ b/src/common/wall_clock.h @@ -55,4 +55,7 @@ private: [[nodiscard]] std::unique_ptr<WallClock> CreateBestMatchingClock(u64 emulated_cpu_frequency, u64 emulated_clock_frequency); +[[nodiscard]] std::unique_ptr<WallClock> CreateStandardWallClock(u64 emulated_cpu_frequency, + u64 emulated_clock_frequency); + } // namespace Common diff --git a/src/common/windows/timer_resolution.cpp b/src/common/windows/timer_resolution.cpp new file mode 100644 index 000000000..29c6e5c7e --- /dev/null +++ b/src/common/windows/timer_resolution.cpp @@ -0,0 +1,109 @@ +// SPDX-FileCopyrightText: Copyright 2023 yuzu Emulator Project +// SPDX-License-Identifier: GPL-2.0-or-later + +#include <windows.h> + +#include "common/windows/timer_resolution.h" + +extern "C" { +// http://undocumented.ntinternals.net/index.html?page=UserMode%2FUndocumented%20Functions%2FTime%2FNtQueryTimerResolution.html +NTSYSAPI LONG NTAPI NtQueryTimerResolution(PULONG MinimumResolution, PULONG MaximumResolution, + PULONG CurrentResolution); + +// http://undocumented.ntinternals.net/index.html?page=UserMode%2FUndocumented%20Functions%2FTime%2FNtSetTimerResolution.html +NTSYSAPI LONG NTAPI NtSetTimerResolution(ULONG DesiredResolution, BOOLEAN SetResolution, + PULONG CurrentResolution); + +// http://undocumented.ntinternals.net/index.html?page=UserMode%2FUndocumented%20Functions%2FNT%20Objects%2FThread%2FNtDelayExecution.html +NTSYSAPI LONG NTAPI NtDelayExecution(BOOLEAN Alertable, PLARGE_INTEGER DelayInterval); +} + +// Defines for compatibility with older Windows 10 SDKs. + +#ifndef PROCESS_POWER_THROTTLING_EXECUTION_SPEED +#define PROCESS_POWER_THROTTLING_EXECUTION_SPEED 0x1 +#endif +#ifndef PROCESS_POWER_THROTTLING_IGNORE_TIMER_RESOLUTION +#define PROCESS_POWER_THROTTLING_IGNORE_TIMER_RESOLUTION 0x4 +#endif + +namespace Common::Windows { + +namespace { + +using namespace std::chrono; + +constexpr nanoseconds ToNS(ULONG hundred_ns) { + return nanoseconds{hundred_ns * 100}; +} + +constexpr ULONG ToHundredNS(nanoseconds ns) { + return static_cast<ULONG>(ns.count()) / 100; +} + +struct TimerResolution { + std::chrono::nanoseconds minimum; + std::chrono::nanoseconds maximum; + std::chrono::nanoseconds current; +}; + +TimerResolution GetTimerResolution() { + ULONG MinimumTimerResolution; + ULONG MaximumTimerResolution; + ULONG CurrentTimerResolution; + NtQueryTimerResolution(&MinimumTimerResolution, &MaximumTimerResolution, + &CurrentTimerResolution); + return { + .minimum{ToNS(MinimumTimerResolution)}, + .maximum{ToNS(MaximumTimerResolution)}, + .current{ToNS(CurrentTimerResolution)}, + }; +} + +void SetHighQoS() { + // https://learn.microsoft.com/en-us/windows/win32/procthread/quality-of-service + PROCESS_POWER_THROTTLING_STATE PowerThrottling{ + .Version{PROCESS_POWER_THROTTLING_CURRENT_VERSION}, + .ControlMask{PROCESS_POWER_THROTTLING_EXECUTION_SPEED | + PROCESS_POWER_THROTTLING_IGNORE_TIMER_RESOLUTION}, + .StateMask{}, + }; + SetProcessInformation(GetCurrentProcess(), ProcessPowerThrottling, &PowerThrottling, + sizeof(PROCESS_POWER_THROTTLING_STATE)); +} + +} // Anonymous namespace + +nanoseconds GetMinimumTimerResolution() { + return GetTimerResolution().minimum; +} + +nanoseconds GetMaximumTimerResolution() { + return GetTimerResolution().maximum; +} + +nanoseconds GetCurrentTimerResolution() { + return GetTimerResolution().current; +} + +nanoseconds SetCurrentTimerResolution(nanoseconds timer_resolution) { + // Set the timer resolution, and return the current timer resolution. + const auto DesiredTimerResolution = ToHundredNS(timer_resolution); + ULONG CurrentTimerResolution; + NtSetTimerResolution(DesiredTimerResolution, TRUE, &CurrentTimerResolution); + return ToNS(CurrentTimerResolution); +} + +nanoseconds SetCurrentTimerResolutionToMaximum() { + SetHighQoS(); + return SetCurrentTimerResolution(GetMaximumTimerResolution()); +} + +void SleepForOneTick() { + LARGE_INTEGER DelayInterval{ + .QuadPart{-1}, + }; + NtDelayExecution(FALSE, &DelayInterval); +} + +} // namespace Common::Windows diff --git a/src/common/windows/timer_resolution.h b/src/common/windows/timer_resolution.h new file mode 100644 index 000000000..e1e50a62d --- /dev/null +++ b/src/common/windows/timer_resolution.h @@ -0,0 +1,38 @@ +// SPDX-FileCopyrightText: Copyright 2023 yuzu Emulator Project +// SPDX-License-Identifier: GPL-2.0-or-later + +#pragma once + +#include <chrono> + +namespace Common::Windows { + +/// Returns the minimum (least precise) supported timer resolution in nanoseconds. +std::chrono::nanoseconds GetMinimumTimerResolution(); + +/// Returns the maximum (most precise) supported timer resolution in nanoseconds. +std::chrono::nanoseconds GetMaximumTimerResolution(); + +/// Returns the current timer resolution in nanoseconds. +std::chrono::nanoseconds GetCurrentTimerResolution(); + +/** + * Sets the current timer resolution. + * + * @param timer_resolution Timer resolution in nanoseconds. + * + * @returns The current timer resolution. + */ +std::chrono::nanoseconds SetCurrentTimerResolution(std::chrono::nanoseconds timer_resolution); + +/** + * Sets the current timer resolution to the maximum supported timer resolution. + * + * @returns The current timer resolution. + */ +std::chrono::nanoseconds SetCurrentTimerResolutionToMaximum(); + +/// Sleep for one tick of the current timer resolution. +void SleepForOneTick(); + +} // namespace Common::Windows diff --git a/src/common/x64/native_clock.cpp b/src/common/x64/native_clock.cpp index 8b08332ab..76c66e7ee 100644 --- a/src/common/x64/native_clock.cpp +++ b/src/common/x64/native_clock.cpp @@ -6,6 +6,7 @@ #include <thread> #include "common/atomic_ops.h" +#include "common/steady_clock.h" #include "common/uint128.h" #include "common/x64/native_clock.h" @@ -39,6 +40,12 @@ static u64 FencedRDTSC() { } #endif +template <u64 Nearest> +static u64 RoundToNearest(u64 value) { + const auto mod = value % Nearest; + return mod >= (Nearest / 2) ? (value - mod + Nearest) : (value - mod); +} + u64 EstimateRDTSCFrequency() { // Discard the first result measuring the rdtsc. FencedRDTSC(); @@ -46,18 +53,18 @@ u64 EstimateRDTSCFrequency() { FencedRDTSC(); // Get the current time. - const auto start_time = std::chrono::steady_clock::now(); + const auto start_time = Common::RealTimeClock::Now(); const u64 tsc_start = FencedRDTSC(); - // Wait for 200 milliseconds. - std::this_thread::sleep_for(std::chrono::milliseconds{200}); - const auto end_time = std::chrono::steady_clock::now(); + // Wait for 250 milliseconds. + std::this_thread::sleep_for(std::chrono::milliseconds{250}); + const auto end_time = Common::RealTimeClock::Now(); const u64 tsc_end = FencedRDTSC(); // Calculate differences. const u64 timer_diff = static_cast<u64>( std::chrono::duration_cast<std::chrono::nanoseconds>(end_time - start_time).count()); const u64 tsc_diff = tsc_end - tsc_start; const u64 tsc_freq = MultiplyAndDivide64(tsc_diff, 1000000000ULL, timer_diff); - return tsc_freq; + return RoundToNearest<1000>(tsc_freq); } namespace X64 { @@ -65,13 +72,29 @@ NativeClock::NativeClock(u64 emulated_cpu_frequency_, u64 emulated_clock_frequen u64 rtsc_frequency_) : WallClock(emulated_cpu_frequency_, emulated_clock_frequency_, true), rtsc_frequency{ rtsc_frequency_} { + // Thread to re-adjust the RDTSC frequency after 10 seconds has elapsed. + time_sync_thread = std::jthread{[this](std::stop_token token) { + // Get the current time. + const auto start_time = Common::RealTimeClock::Now(); + const u64 tsc_start = FencedRDTSC(); + // Wait for 10 seconds. + if (!Common::StoppableTimedWait(token, std::chrono::seconds{10})) { + return; + } + const auto end_time = Common::RealTimeClock::Now(); + const u64 tsc_end = FencedRDTSC(); + // Calculate differences. + const u64 timer_diff = static_cast<u64>( + std::chrono::duration_cast<std::chrono::nanoseconds>(end_time - start_time).count()); + const u64 tsc_diff = tsc_end - tsc_start; + const u64 tsc_freq = MultiplyAndDivide64(tsc_diff, 1000000000ULL, timer_diff); + rtsc_frequency = tsc_freq; + CalculateAndSetFactors(); + }}; + time_point.inner.last_measure = FencedRDTSC(); time_point.inner.accumulated_ticks = 0U; - ns_rtsc_factor = GetFixedPoint64Factor(NS_RATIO, rtsc_frequency); - us_rtsc_factor = GetFixedPoint64Factor(US_RATIO, rtsc_frequency); - ms_rtsc_factor = GetFixedPoint64Factor(MS_RATIO, rtsc_frequency); - clock_rtsc_factor = GetFixedPoint64Factor(emulated_clock_frequency, rtsc_frequency); - cpu_rtsc_factor = GetFixedPoint64Factor(emulated_cpu_frequency, rtsc_frequency); + CalculateAndSetFactors(); } u64 NativeClock::GetRTSC() { @@ -131,6 +154,14 @@ u64 NativeClock::GetCPUCycles() { return MultiplyHigh(rtsc_value, cpu_rtsc_factor); } +void NativeClock::CalculateAndSetFactors() { + ns_rtsc_factor = GetFixedPoint64Factor(NS_RATIO, rtsc_frequency); + us_rtsc_factor = GetFixedPoint64Factor(US_RATIO, rtsc_frequency); + ms_rtsc_factor = GetFixedPoint64Factor(MS_RATIO, rtsc_frequency); + clock_rtsc_factor = GetFixedPoint64Factor(emulated_clock_frequency, rtsc_frequency); + cpu_rtsc_factor = GetFixedPoint64Factor(emulated_cpu_frequency, rtsc_frequency); +} + } // namespace X64 } // namespace Common diff --git a/src/common/x64/native_clock.h b/src/common/x64/native_clock.h index 38ae7a462..03ca291d8 100644 --- a/src/common/x64/native_clock.h +++ b/src/common/x64/native_clock.h @@ -3,6 +3,7 @@ #pragma once +#include "common/polyfill_thread.h" #include "common/wall_clock.h" namespace Common { @@ -28,6 +29,8 @@ public: private: u64 GetRTSC(); + void CalculateAndSetFactors(); + union alignas(16) TimePoint { TimePoint() : pack{} {} u128 pack{}; @@ -47,6 +50,8 @@ private: u64 ms_rtsc_factor{}; u64 rtsc_frequency; + + std::jthread time_sync_thread; }; } // namespace X64 diff --git a/src/core/CMakeLists.txt b/src/core/CMakeLists.txt index cdebb0bd8..378e6c023 100644 --- a/src/core/CMakeLists.txt +++ b/src/core/CMakeLists.txt @@ -158,7 +158,7 @@ add_library(core STATIC hid/motion_input.h hle/api_version.h hle/ipc.h - hle/ipc_helpers.h + hle/kernel/board/nintendo/nx/k_memory_layout.cpp hle/kernel/board/nintendo/nx/k_memory_layout.h hle/kernel/board/nintendo/nx/k_system_control.cpp hle/kernel/board/nintendo/nx/k_system_control.h @@ -168,8 +168,6 @@ add_library(core STATIC hle/kernel/svc_results.h hle/kernel/global_scheduler_context.cpp hle/kernel/global_scheduler_context.h - hle/kernel/hle_ipc.cpp - hle/kernel/hle_ipc.h hle/kernel/init/init_slab_setup.cpp hle/kernel/init/init_slab_setup.h hle/kernel/initial_process.h @@ -214,12 +212,10 @@ add_library(core STATIC hle/kernel/k_light_condition_variable.h hle/kernel/k_light_lock.cpp hle/kernel/k_light_lock.h - hle/kernel/k_linked_list.h hle/kernel/k_memory_block.h hle/kernel/k_memory_block_manager.cpp hle/kernel/k_memory_block_manager.h hle/kernel/k_memory_layout.cpp - hle/kernel/k_memory_layout.board.nintendo_nx.cpp hle/kernel/k_memory_layout.h hle/kernel/k_memory_manager.cpp hle/kernel/k_memory_manager.h @@ -457,7 +453,6 @@ add_library(core STATIC hle/service/filesystem/fsp_srv.h hle/service/fgm/fgm.cpp hle/service/fgm/fgm.h - hle/service/friend/errors.h hle/service/friend/friend.cpp hle/service/friend/friend.h hle/service/friend/friend_interface.cpp @@ -629,35 +624,35 @@ add_library(core STATIC hle/service/nvdrv/nvdrv_interface.h hle/service/nvdrv/nvmemp.cpp hle/service/nvdrv/nvmemp.h - hle/service/nvflinger/binder.h - hle/service/nvflinger/buffer_item.h - hle/service/nvflinger/buffer_item_consumer.cpp - hle/service/nvflinger/buffer_item_consumer.h - hle/service/nvflinger/buffer_queue_consumer.cpp - hle/service/nvflinger/buffer_queue_consumer.h - hle/service/nvflinger/buffer_queue_core.cpp - hle/service/nvflinger/buffer_queue_core.h - hle/service/nvflinger/buffer_queue_defs.h - hle/service/nvflinger/buffer_queue_producer.cpp - hle/service/nvflinger/buffer_queue_producer.h - hle/service/nvflinger/buffer_slot.h - hle/service/nvflinger/buffer_transform_flags.h - hle/service/nvflinger/consumer_base.cpp - hle/service/nvflinger/consumer_base.h - hle/service/nvflinger/consumer_listener.h - hle/service/nvflinger/graphic_buffer_producer.cpp - hle/service/nvflinger/graphic_buffer_producer.h - hle/service/nvflinger/hos_binder_driver_server.cpp - hle/service/nvflinger/hos_binder_driver_server.h - hle/service/nvflinger/nvflinger.cpp - hle/service/nvflinger/nvflinger.h - hle/service/nvflinger/parcel.h - hle/service/nvflinger/pixel_format.h - hle/service/nvflinger/producer_listener.h - hle/service/nvflinger/status.h - hle/service/nvflinger/ui/fence.h - hle/service/nvflinger/ui/graphic_buffer.h - hle/service/nvflinger/window.h + hle/service/nvnflinger/binder.h + hle/service/nvnflinger/buffer_item.h + hle/service/nvnflinger/buffer_item_consumer.cpp + hle/service/nvnflinger/buffer_item_consumer.h + hle/service/nvnflinger/buffer_queue_consumer.cpp + hle/service/nvnflinger/buffer_queue_consumer.h + hle/service/nvnflinger/buffer_queue_core.cpp + hle/service/nvnflinger/buffer_queue_core.h + hle/service/nvnflinger/buffer_queue_defs.h + hle/service/nvnflinger/buffer_queue_producer.cpp + hle/service/nvnflinger/buffer_queue_producer.h + hle/service/nvnflinger/buffer_slot.h + hle/service/nvnflinger/buffer_transform_flags.h + hle/service/nvnflinger/consumer_base.cpp + hle/service/nvnflinger/consumer_base.h + hle/service/nvnflinger/consumer_listener.h + hle/service/nvnflinger/graphic_buffer_producer.cpp + hle/service/nvnflinger/graphic_buffer_producer.h + hle/service/nvnflinger/hos_binder_driver_server.cpp + hle/service/nvnflinger/hos_binder_driver_server.h + hle/service/nvnflinger/nvnflinger.cpp + hle/service/nvnflinger/nvnflinger.h + hle/service/nvnflinger/parcel.h + hle/service/nvnflinger/pixel_format.h + hle/service/nvnflinger/producer_listener.h + hle/service/nvnflinger/status.h + hle/service/nvnflinger/ui/fence.h + hle/service/nvnflinger/ui/graphic_buffer.h + hle/service/nvnflinger/window.h hle/service/olsc/olsc.cpp hle/service/olsc/olsc.h hle/service/pcie/pcie.cpp @@ -680,6 +675,9 @@ add_library(core STATIC hle/service/ptm/ptm.h hle/service/ptm/ts.cpp hle/service/ptm/ts.h + hle/service/hle_ipc.cpp + hle/service/hle_ipc.h + hle/service/ipc_helpers.h hle/service/kernel_helpers.cpp hle/service/kernel_helpers.h hle/service/mutex.cpp diff --git a/src/core/constants.cpp b/src/core/constants.cpp index 4430173ef..760dc5f23 100644 --- a/src/core/constants.cpp +++ b/src/core/constants.cpp @@ -4,13 +4,24 @@ #include "core/constants.h" namespace Core::Constants { -const std::array<u8, 107> ACCOUNT_BACKUP_JPEG{{ - 0xff, 0xd8, 0xff, 0xdb, 0x00, 0x43, 0x00, 0x03, 0x02, 0x02, 0x02, 0x02, 0x02, 0x03, 0x02, 0x02, - 0x02, 0x03, 0x03, 0x03, 0x03, 0x04, 0x06, 0x04, 0x04, 0x04, 0x04, 0x04, 0x08, 0x06, 0x06, 0x05, - 0x06, 0x09, 0x08, 0x0a, 0x0a, 0x09, 0x08, 0x09, 0x09, 0x0a, 0x0c, 0x0f, 0x0c, 0x0a, 0x0b, 0x0e, - 0x0b, 0x09, 0x09, 0x0d, 0x11, 0x0d, 0x0e, 0x0f, 0x10, 0x10, 0x11, 0x10, 0x0a, 0x0c, 0x12, 0x13, - 0x12, 0x10, 0x13, 0x0f, 0x10, 0x10, 0x10, 0xff, 0xc9, 0x00, 0x0b, 0x08, 0x00, 0x01, 0x00, 0x01, - 0x01, 0x01, 0x11, 0x00, 0xff, 0xcc, 0x00, 0x06, 0x00, 0x10, 0x10, 0x05, 0xff, 0xda, 0x00, 0x08, - 0x01, 0x01, 0x00, 0x00, 0x3f, 0x00, 0xd2, 0xcf, 0x20, 0xff, 0xd9, +const std::array<u8, 287> ACCOUNT_BACKUP_JPEG{{ + 0xff, 0xd8, 0xff, 0xe0, 0x00, 0x10, 0x4a, 0x46, 0x49, 0x46, 0x00, 0x01, 0x01, 0x01, 0x00, 0x48, + 0x00, 0x48, 0x00, 0x00, 0xff, 0xdb, 0x00, 0x43, 0x00, 0x06, 0x04, 0x04, 0x04, 0x05, 0x04, 0x06, + 0x05, 0x05, 0x06, 0x09, 0x06, 0x05, 0x06, 0x09, 0x0b, 0x08, 0x06, 0x06, 0x08, 0x0b, 0x0c, 0x0a, + 0x0a, 0x0b, 0x0a, 0x0a, 0x0c, 0x10, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x10, 0x0c, 0x0e, 0x0f, + 0x10, 0x0f, 0x0e, 0x0c, 0x13, 0x13, 0x14, 0x14, 0x13, 0x13, 0x1c, 0x1b, 0x1b, 0x1b, 0x1c, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0xff, 0xdb, 0x00, 0x43, 0x01, 0x07, 0x07, + 0x07, 0x0d, 0x0c, 0x0d, 0x18, 0x10, 0x10, 0x18, 0x1a, 0x15, 0x11, 0x15, 0x1a, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0xff, 0xc0, + 0x00, 0x11, 0x08, 0x00, 0x20, 0x00, 0x20, 0x03, 0x01, 0x22, 0x00, 0x02, 0x11, 0x01, 0x03, 0x11, + 0x01, 0xff, 0xc4, 0x00, 0x14, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xc4, 0x00, 0x14, 0x10, 0x01, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xc4, 0x00, + 0x14, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0xff, 0xc4, 0x00, 0x14, 0x11, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xda, 0x00, 0x0c, 0x03, 0x01, 0x00, + 0x02, 0x11, 0x03, 0x11, 0x00, 0x3f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xd9, }}; } diff --git a/src/core/constants.h b/src/core/constants.h index f916ce0b6..f1f67d3b8 100644 --- a/src/core/constants.h +++ b/src/core/constants.h @@ -12,6 +12,6 @@ namespace Core::Constants { // ACC Service - Blank JPEG used as user icon in absentia of real one. -extern const std::array<u8, 107> ACCOUNT_BACKUP_JPEG; +extern const std::array<u8, 287> ACCOUNT_BACKUP_JPEG; } // namespace Core::Constants diff --git a/src/core/core.cpp b/src/core/core.cpp index 4a1372d15..d2b597068 100644 --- a/src/core/core.cpp +++ b/src/core/core.cpp @@ -358,7 +358,7 @@ struct System::Impl { void ShutdownMainProcess() { SetShuttingDown(true); - // Log last frame performance stats if game was loded + // Log last frame performance stats if game was loaded if (perf_stats) { const auto perf_results = GetAndResetPerfStats(); constexpr auto performance = Common::Telemetry::FieldType::Performance; @@ -434,7 +434,7 @@ struct System::Impl { } Service::Glue::ApplicationLaunchProperty launch{}; - launch.title_id = process.GetProgramID(); + launch.title_id = process.GetProgramId(); FileSys::PatchManager pm{launch.title_id, fs_controller, *content_provider}; launch.version = pm.GetGameVersion().value_or(0); @@ -762,7 +762,7 @@ const Core::SpeedLimiter& System::SpeedLimiter() const { } u64 System::GetApplicationProcessProgramID() const { - return impl->kernel.ApplicationProcess()->GetProgramID(); + return impl->kernel.ApplicationProcess()->GetProgramId(); } Loader::ResultStatus System::GetGameName(std::string& out) const { diff --git a/src/core/core.h b/src/core/core.h index 91e78672e..5843696d4 100644 --- a/src/core/core.h +++ b/src/core/core.h @@ -146,7 +146,7 @@ public: /** * Initializes the system - * This function will initialize core functionaility used for system emulation + * This function will initialize core functionality used for system emulation */ void Initialize(); diff --git a/src/core/core_timing.cpp b/src/core/core_timing.cpp index 3a63b52e3..cd4df4522 100644 --- a/src/core/core_timing.cpp +++ b/src/core/core_timing.cpp @@ -6,6 +6,10 @@ #include <string> #include <tuple> +#ifdef _WIN32 +#include "common/windows/timer_resolution.h" +#endif + #include "common/microprofile.h" #include "core/core_timing.h" #include "core/core_timing_util.h" @@ -38,7 +42,8 @@ struct CoreTiming::Event { }; CoreTiming::CoreTiming() - : clock{Common::CreateBestMatchingClock(Hardware::BASE_CLOCK_RATE, Hardware::CNTFREQ)} {} + : cpu_clock{Common::CreateBestMatchingClock(Hardware::BASE_CLOCK_RATE, Hardware::CNTFREQ)}, + event_clock{Common::CreateStandardWallClock(Hardware::BASE_CLOCK_RATE, Hardware::CNTFREQ)} {} CoreTiming::~CoreTiming() { Reset(); @@ -48,7 +53,7 @@ void CoreTiming::ThreadEntry(CoreTiming& instance) { static constexpr char name[] = "HostTiming"; MicroProfileOnThreadCreate(name); Common::SetCurrentThreadName(name); - Common::SetCurrentThreadPriority(Common::ThreadPriority::Critical); + Common::SetCurrentThreadPriority(Common::ThreadPriority::High); instance.on_thread_init(); instance.ThreadLoop(); MicroProfileOnThreadExit(); @@ -185,15 +190,15 @@ void CoreTiming::ResetTicks() { } u64 CoreTiming::GetCPUTicks() const { - if (is_multicore) { - return clock->GetCPUCycles(); + if (is_multicore) [[likely]] { + return cpu_clock->GetCPUCycles(); } return ticks; } u64 CoreTiming::GetClockTicks() const { - if (is_multicore) { - return clock->GetClockCycles(); + if (is_multicore) [[likely]] { + return cpu_clock->GetClockCycles(); } return CpuCyclesToClockCycles(ticks); } @@ -252,21 +257,20 @@ void CoreTiming::ThreadLoop() { const auto next_time = Advance(); if (next_time) { // There are more events left in the queue, wait until the next event. - const auto wait_time = *next_time - GetGlobalTimeNs().count(); + auto wait_time = *next_time - GetGlobalTimeNs().count(); if (wait_time > 0) { #ifdef _WIN32 - // Assume a timer resolution of 1ms. - static constexpr s64 TimerResolutionNS = 1000000; + const auto timer_resolution_ns = + Common::Windows::GetCurrentTimerResolution().count(); - // Sleep in discrete intervals of the timer resolution, and spin the rest. - const auto sleep_time = wait_time - (wait_time % TimerResolutionNS); - if (sleep_time > 0) { - event.WaitFor(std::chrono::nanoseconds(sleep_time)); - } + while (!paused && !event.IsSet() && wait_time > 0) { + wait_time = *next_time - GetGlobalTimeNs().count(); - while (!paused && !event.IsSet() && GetGlobalTimeNs().count() < *next_time) { - // Yield to reduce thread starvation. - std::this_thread::yield(); + if (wait_time >= timer_resolution_ns) { + Common::Windows::SleepForOneTick(); + } else { + std::this_thread::yield(); + } } if (event.IsSet()) { @@ -285,9 +289,9 @@ void CoreTiming::ThreadLoop() { } paused_set = true; - clock->Pause(true); + event_clock->Pause(true); pause_event.Wait(); - clock->Pause(false); + event_clock->Pause(false); } } @@ -303,16 +307,23 @@ void CoreTiming::Reset() { has_started = false; } +std::chrono::nanoseconds CoreTiming::GetCPUTimeNs() const { + if (is_multicore) [[likely]] { + return cpu_clock->GetTimeNS(); + } + return CyclesToNs(ticks); +} + std::chrono::nanoseconds CoreTiming::GetGlobalTimeNs() const { - if (is_multicore) { - return clock->GetTimeNS(); + if (is_multicore) [[likely]] { + return event_clock->GetTimeNS(); } return CyclesToNs(ticks); } std::chrono::microseconds CoreTiming::GetGlobalTimeUs() const { - if (is_multicore) { - return clock->GetTimeUS(); + if (is_multicore) [[likely]] { + return event_clock->GetTimeUS(); } return CyclesToUs(ticks); } diff --git a/src/core/core_timing.h b/src/core/core_timing.h index da366637b..e7c4a949f 100644 --- a/src/core/core_timing.h +++ b/src/core/core_timing.h @@ -122,6 +122,9 @@ public: /// Returns current time in emulated in Clock cycles u64 GetClockTicks() const; + /// Returns current time in nanoseconds. + std::chrono::nanoseconds GetCPUTimeNs() const; + /// Returns current time in microseconds. std::chrono::microseconds GetGlobalTimeUs() const; @@ -139,14 +142,15 @@ private: void Reset(); - std::unique_ptr<Common::WallClock> clock; + std::unique_ptr<Common::WallClock> cpu_clock; + std::unique_ptr<Common::WallClock> event_clock; s64 global_timer = 0; // The queue is a min-heap using std::make_heap/push_heap/pop_heap. // We don't use std::priority_queue because we need to be able to serialize, unserialize and // erase arbitrary events (RemoveEvent()) regardless of the queue order. These aren't - // accomodated by the standard adaptor class. + // accommodated by the standard adaptor class. std::vector<Event> event_queue; u64 event_fifo_id = 0; diff --git a/src/core/cpu_manager.cpp b/src/core/cpu_manager.cpp index 04a11f444..980bb97f9 100644 --- a/src/core/cpu_manager.cpp +++ b/src/core/cpu_manager.cpp @@ -192,7 +192,7 @@ void CpuManager::RunThread(std::stop_token token, std::size_t core) { } MicroProfileOnThreadCreate(name.c_str()); Common::SetCurrentThreadName(name.c_str()); - Common::SetCurrentThreadPriority(Common::ThreadPriority::High); + Common::SetCurrentThreadPriority(Common::ThreadPriority::Critical); auto& data = core_data[core]; data.host_context = Common::Fiber::ThreadToFiber(); diff --git a/src/core/crypto/ctr_encryption_layer.h b/src/core/crypto/ctr_encryption_layer.h index 77f08d776..d85ad8f78 100644 --- a/src/core/crypto/ctr_encryption_layer.h +++ b/src/core/crypto/ctr_encryption_layer.h @@ -11,7 +11,7 @@ namespace Core::Crypto { -// Sits on top of a VirtualFile and provides CTR-mode AES decription. +// Sits on top of a VirtualFile and provides CTR-mode AES description. class CTREncryptionLayer : public EncryptionLayer { public: using IVData = std::array<u8, 16>; diff --git a/src/core/crypto/key_manager.h b/src/core/crypto/key_manager.h index dbf9ebfe4..673cec463 100644 --- a/src/core/crypto/key_manager.h +++ b/src/core/crypto/key_manager.h @@ -249,7 +249,7 @@ public: static bool KeyFileExists(bool title); - // Call before using the sd seed to attempt to derive it if it dosen't exist. Needs system + // Call before using the sd seed to attempt to derive it if it doesn't exist. Needs system // save 8*43 and the private file to exist. void DeriveSDSeedLazy(); diff --git a/src/core/crypto/xts_encryption_layer.h b/src/core/crypto/xts_encryption_layer.h index 735e660cb..68b5643b1 100644 --- a/src/core/crypto/xts_encryption_layer.h +++ b/src/core/crypto/xts_encryption_layer.h @@ -9,7 +9,7 @@ namespace Core::Crypto { -// Sits on top of a VirtualFile and provides XTS-mode AES decription. +// Sits on top of a VirtualFile and provides XTS-mode AES description. class XTSEncryptionLayer : public EncryptionLayer { public: XTSEncryptionLayer(FileSys::VirtualFile base, Key256 key); diff --git a/src/core/debugger/gdbstub.cpp b/src/core/debugger/gdbstub.cpp index 18afe97e1..b2fe6bd7d 100644 --- a/src/core/debugger/gdbstub.cpp +++ b/src/core/debugger/gdbstub.cpp @@ -421,7 +421,7 @@ void GDBStub::HandleBreakpointRemove(std::string_view command) { static std::optional<std::string> GetNameFromThreadType32(Core::Memory::Memory& memory, const Kernel::KThread* thread) { // Read thread type from TLS - const VAddr tls_thread_type{memory.Read32(thread->GetTLSAddress() + 0x1fc)}; + const VAddr tls_thread_type{memory.Read32(thread->GetTlsAddress() + 0x1fc)}; const VAddr argument_thread_type{thread->GetArgument()}; if (argument_thread_type && tls_thread_type != argument_thread_type) { @@ -452,7 +452,7 @@ static std::optional<std::string> GetNameFromThreadType32(Core::Memory::Memory& static std::optional<std::string> GetNameFromThreadType64(Core::Memory::Memory& memory, const Kernel::KThread* thread) { // Read thread type from TLS - const VAddr tls_thread_type{memory.Read64(thread->GetTLSAddress() + 0x1f8)}; + const VAddr tls_thread_type{memory.Read64(thread->GetTlsAddress() + 0x1f8)}; const VAddr argument_thread_type{thread->GetArgument()}; if (argument_thread_type && tls_thread_type != argument_thread_type) { @@ -576,7 +576,7 @@ void GDBStub::HandleQuery(std::string_view command) { const auto& threads = system.ApplicationProcess()->GetThreadList(); std::vector<std::string> thread_ids; for (const auto& thread : threads) { - thread_ids.push_back(fmt::format("{:x}", thread->GetThreadID())); + thread_ids.push_back(fmt::format("{:x}", thread->GetThreadId())); } SendReply(fmt::format("m{}", fmt::join(thread_ids, ","))); } else if (command.starts_with("sThreadInfo")) { @@ -591,11 +591,11 @@ void GDBStub::HandleQuery(std::string_view command) { for (const auto* thread : threads) { auto thread_name{GetThreadName(system, thread)}; if (!thread_name) { - thread_name = fmt::format("Thread {:d}", thread->GetThreadID()); + thread_name = fmt::format("Thread {:d}", thread->GetThreadId()); } buffer += fmt::format(R"(<thread id="{:x}" core="{:d}" name="{}">{}</thread>)", - thread->GetThreadID(), thread->GetActiveCore(), + thread->GetThreadId(), thread->GetActiveCore(), EscapeXML(*thread_name), GetThreadState(thread)); } @@ -756,7 +756,7 @@ void GDBStub::HandleRcmd(const std::vector<u8>& command) { reply = fmt::format("Process: {:#x} ({})\n" "Program Id: {:#018x}\n", - process->GetProcessID(), process->GetName(), process->GetProgramID()); + process->GetProcessId(), process->GetName(), process->GetProgramId()); reply += fmt::format("Layout:\n" " Alias: {:#012x} - {:#012x}\n" @@ -819,7 +819,7 @@ void GDBStub::HandleRcmd(const std::vector<u8>& command) { Kernel::KThread* GDBStub::GetThreadByID(u64 thread_id) { const auto& threads{system.ApplicationProcess()->GetThreadList()}; for (auto* thread : threads) { - if (thread->GetThreadID() == thread_id) { + if (thread->GetThreadId() == thread_id) { return thread; } } diff --git a/src/core/debugger/gdbstub_arch.cpp b/src/core/debugger/gdbstub_arch.cpp index 831c48513..75c94a91a 100644 --- a/src/core/debugger/gdbstub_arch.cpp +++ b/src/core/debugger/gdbstub_arch.cpp @@ -259,7 +259,7 @@ void GDBStubA64::WriteRegisters(Kernel::KThread* thread, std::string_view regist std::string GDBStubA64::ThreadStatus(const Kernel::KThread* thread, u8 signal) const { return fmt::format("T{:02x}{:02x}:{};{:02x}:{};{:02x}:{};thread:{:x};", signal, PC_REGISTER, RegRead(thread, PC_REGISTER), SP_REGISTER, RegRead(thread, SP_REGISTER), - LR_REGISTER, RegRead(thread, LR_REGISTER), thread->GetThreadID()); + LR_REGISTER, RegRead(thread, LR_REGISTER), thread->GetThreadId()); } u32 GDBStubA64::BreakpointInstruction() const { @@ -469,7 +469,7 @@ void GDBStubA32::WriteRegisters(Kernel::KThread* thread, std::string_view regist std::string GDBStubA32::ThreadStatus(const Kernel::KThread* thread, u8 signal) const { return fmt::format("T{:02x}{:02x}:{};{:02x}:{};{:02x}:{};thread:{:x};", signal, PC_REGISTER, RegRead(thread, PC_REGISTER), SP_REGISTER, RegRead(thread, SP_REGISTER), - LR_REGISTER, RegRead(thread, LR_REGISTER), thread->GetThreadID()); + LR_REGISTER, RegRead(thread, LR_REGISTER), thread->GetThreadId()); } u32 GDBStubA32::BreakpointInstruction() const { diff --git a/src/core/file_sys/content_archive.h b/src/core/file_sys/content_archive.h index 7fdc45ea7..20f524f80 100644 --- a/src/core/file_sys/content_archive.h +++ b/src/core/file_sys/content_archive.h @@ -93,7 +93,7 @@ inline bool IsDirectoryLogoPartition(const VirtualDir& pfs) { pfs->GetFile("StartupMovie.gif") != nullptr; } -// An implementation of VfsDirectory that represents a Nintendo Content Archive (NCA) conatiner. +// An implementation of VfsDirectory that represents a Nintendo Content Archive (NCA) container. // After construction, use GetStatus to determine if the file is valid and ready to be used. class NCA : public ReadOnlyVfsDirectory { public: diff --git a/src/core/file_sys/registered_cache.h b/src/core/file_sys/registered_cache.h index 587f8cae8..bd7f53eaf 100644 --- a/src/core/file_sys/registered_cache.h +++ b/src/core/file_sys/registered_cache.h @@ -162,7 +162,7 @@ public: InstallResult InstallEntry(const NSP& nsp, bool overwrite_if_exists = false, const VfsCopyFunction& copy = &VfsRawCopy); - // Due to the fact that we must use Meta-type NCAs to determine the existance of files, this + // Due to the fact that we must use Meta-type NCAs to determine the existence of files, this // poses quite a challenge. Instead of creating a new meta NCA for this file, yuzu will create a // dir inside the NAND called 'yuzu_meta' and store the raw CNMT there. // TODO(DarkLordZach): Author real meta-type NCAs and install those. diff --git a/src/core/file_sys/vfs.h b/src/core/file_sys/vfs.h index 8fc1738a4..a93e21f67 100644 --- a/src/core/file_sys/vfs.h +++ b/src/core/file_sys/vfs.h @@ -45,7 +45,7 @@ public: // Return whether or not the user has write permission on this filesystem. virtual bool IsWritable() const; - // Determine if the entry at path is non-existant, a file, or a directory. + // Determine if the entry at path is non-existent, a file, or a directory. virtual VfsEntryType GetEntryType(std::string_view path) const; // Opens the file with path relative to root. If it doesn't exist, returns nullptr. @@ -58,7 +58,7 @@ public: // Moves the file from old_path to new_path, returning the moved file on success and nullptr on // failure. virtual VirtualFile MoveFile(std::string_view old_path, std::string_view new_path); - // Deletes the file with path relative to root, returing true on success. + // Deletes the file with path relative to root, returning true on success. virtual bool DeleteFile(std::string_view path); // Opens the directory with path relative to root. If it doesn't exist, returns nullptr. @@ -71,7 +71,7 @@ public: // Moves the directory from old_path to new_path, returning the moved directory on success and // nullptr on failure. virtual VirtualDir MoveDirectory(std::string_view old_path, std::string_view new_path); - // Deletes the directory with path relative to root, returing true on success. + // Deletes the directory with path relative to root, returning true on success. virtual bool DeleteDirectory(std::string_view path); protected: @@ -144,7 +144,7 @@ public: return Read(reinterpret_cast<u8*>(data), sizeof(T), offset); } - // Writes exactly one byte to offset in file and retuns whether or not the byte was written + // Writes exactly one byte to offset in file and returns whether or not the byte was written // successfully. virtual bool WriteByte(u8 data, std::size_t offset = 0); // Writes a vector of bytes to offset in file and returns the number of bytes successfully @@ -191,13 +191,13 @@ public: VfsDirectory() = default; virtual ~VfsDirectory(); - // Retrives the file located at path as if the current directory was root. Returns nullptr if + // Retrieves the file located at path as if the current directory was root. Returns nullptr if // not found. virtual VirtualFile GetFileRelative(std::string_view path) const; // Calls GetFileRelative(path) on the root of the current directory. virtual VirtualFile GetFileAbsolute(std::string_view path) const; - // Retrives the directory located at path as if the current directory was root. Returns nullptr + // Retrieves the directory located at path as if the current directory was root. Returns nullptr // if not found. virtual VirtualDir GetDirectoryRelative(std::string_view path) const; // Calls GetDirectoryRelative(path) on the root of the current directory. @@ -205,7 +205,7 @@ public: // Returns a vector containing all of the files in this directory. virtual std::vector<VirtualFile> GetFiles() const = 0; - // Returns the file with filename matching name. Returns nullptr if directory dosen't have a + // Returns the file with filename matching name. Returns nullptr if directory doesn't have a // file with name. virtual VirtualFile GetFile(std::string_view name) const; @@ -214,7 +214,7 @@ public: // Returns a vector containing all of the subdirectories in this directory. virtual std::vector<VirtualDir> GetSubdirectories() const = 0; - // Returns the directory with name matching name. Returns nullptr if directory dosen't have a + // Returns the directory with name matching name. Returns nullptr if directory doesn't have a // directory with name. virtual VirtualDir GetSubdirectory(std::string_view name) const; diff --git a/src/core/file_sys/vfs_real.h b/src/core/file_sys/vfs_real.h index acde1ac89..b92c84316 100644 --- a/src/core/file_sys/vfs_real.h +++ b/src/core/file_sys/vfs_real.h @@ -38,7 +38,7 @@ private: boost::container::flat_map<std::string, std::weak_ptr<Common::FS::IOFile>> cache; }; -// An implmentation of VfsFile that represents a file on the user's computer. +// An implementation of VfsFile that represents a file on the user's computer. class RealVfsFile : public VfsFile { friend class RealVfsDirectory; friend class RealVfsFilesystem; diff --git a/src/core/frontend/emu_window.h b/src/core/frontend/emu_window.h index cf85ba29e..1093800f6 100644 --- a/src/core/frontend/emu_window.h +++ b/src/core/frontend/emu_window.h @@ -205,7 +205,7 @@ protected: } /** - * Converts a screen postion into the equivalent touchscreen position. + * Converts a screen position into the equivalent touchscreen position. */ std::pair<f32, f32> MapToTouchScreen(u32 framebuffer_x, u32 framebuffer_y) const; diff --git a/src/core/hardware_properties.h b/src/core/hardware_properties.h index 45567b840..191c28bb4 100644 --- a/src/core/hardware_properties.h +++ b/src/core/hardware_properties.h @@ -13,11 +13,9 @@ namespace Core { namespace Hardware { -// The below clock rate is based on Switch's clockspeed being widely known as 1.020GHz -// The exact value used is of course unverified. -constexpr u64 BASE_CLOCK_RATE = 1019215872; // Switch cpu frequency is 1020MHz un/docked -constexpr u64 CNTFREQ = 19200000; // Switch's hardware clock speed -constexpr u32 NUM_CPU_CORES = 4; // Number of CPU Cores +constexpr u64 BASE_CLOCK_RATE = 1'020'000'000; // Default CPU Frequency = 1020 MHz +constexpr u64 CNTFREQ = 19'200'000; // CNTPCT_EL0 Frequency = 19.2 MHz +constexpr u32 NUM_CPU_CORES = 4; // Number of CPU Cores // Virtual to Physical core map. constexpr std::array<s32, Common::BitSize<u64>()> VirtualToPhysicalCoreMap{ diff --git a/src/core/hid/emulated_controller.h b/src/core/hid/emulated_controller.h index a9da465a2..429655355 100644 --- a/src/core/hid/emulated_controller.h +++ b/src/core/hid/emulated_controller.h @@ -132,7 +132,7 @@ struct ControllerStatus { RingAnalogValue ring_analog_value{}; NfcValues nfc_values{}; - // Data for HID serices + // Data for HID services HomeButtonState home_button_state{}; CaptureButtonState capture_button_state{}; NpadButtonState npad_button_state{}; @@ -357,7 +357,7 @@ public: /** * Sends a small vibration to the output device - * @return true if SetVibration was successfull + * @return true if SetVibration was successful */ bool IsVibrationEnabled(std::size_t device_index); @@ -373,7 +373,7 @@ public: /** * Sets the desired camera format to be polled from a controller * @param camera_format size of each frame - * @return true if SetCameraFormat was successfull + * @return true if SetCameraFormat was successful */ bool SetCameraFormat(Core::IrSensor::ImageTransferProcessorFormat camera_format); diff --git a/src/core/hid/emulated_devices.h b/src/core/hid/emulated_devices.h index caf2ca659..5eab693e4 100644 --- a/src/core/hid/emulated_devices.h +++ b/src/core/hid/emulated_devices.h @@ -53,7 +53,7 @@ struct DeviceStatus { MouseWheelValues mouse_wheel_values{}; MouseStickValue mouse_stick_value{}; - // Data for HID serices + // Data for HID services KeyboardKey keyboard_state{}; KeyboardModifier keyboard_moddifier_state{}; MouseButton mouse_button_state{}; @@ -75,7 +75,7 @@ struct InterfaceUpdateCallback { class EmulatedDevices { public: /** - * Contains all input data related to external devices that aren't necesarily a controller + * Contains all input data related to external devices that aren't necessarily a controller * This includes devices such as the keyboard or mouse */ explicit EmulatedDevices(); diff --git a/src/core/hid/input_converter.cpp b/src/core/hid/input_converter.cpp index 3f7b8c090..7cee39a53 100644 --- a/src/core/hid/input_converter.cpp +++ b/src/core/hid/input_converter.cpp @@ -328,7 +328,7 @@ void SanitizeAnalog(Common::Input::AnalogStatus& analog, bool clamp_value) { // Apply center offset raw_value -= properties.offset; - // Set initial values to be formated + // Set initial values to be formatted value = raw_value; // Calculate vector size @@ -398,7 +398,7 @@ void SanitizeStick(Common::Input::AnalogStatus& analog_x, Common::Input::AnalogS raw_x = properties_x.inverted ? -raw_x : raw_x; raw_y = properties_y.inverted ? -raw_y : raw_y; - // Set initial values to be formated + // Set initial values to be formatted x = raw_x; y = raw_y; diff --git a/src/core/hid/motion_input.h b/src/core/hid/motion_input.h index e2c1bbf95..9f3fc1cf7 100644 --- a/src/core/hid/motion_input.h +++ b/src/core/hid/motion_input.h @@ -84,7 +84,7 @@ private: // Gyroscope vector measurement in radians/s. Common::Vec3f gyro; - // Vector to be substracted from gyro measurements + // Vector to be subtracted from gyro measurements Common::Vec3f gyro_bias; // Minimum gyro amplitude to detect if the device is moving diff --git a/src/core/hle/kernel/k_memory_layout.board.nintendo_nx.cpp b/src/core/hle/kernel/board/nintendo/nx/k_memory_layout.cpp index 098ba6eac..098ba6eac 100644 --- a/src/core/hle/kernel/k_memory_layout.board.nintendo_nx.cpp +++ b/src/core/hle/kernel/board/nintendo/nx/k_memory_layout.cpp diff --git a/src/core/hle/kernel/global_scheduler_context.cpp b/src/core/hle/kernel/global_scheduler_context.cpp index fd911a3a5..7b090ccb5 100644 --- a/src/core/hle/kernel/global_scheduler_context.cpp +++ b/src/core/hle/kernel/global_scheduler_context.cpp @@ -12,20 +12,19 @@ namespace Kernel { -GlobalSchedulerContext::GlobalSchedulerContext(KernelCore& kernel_) - : kernel{kernel_}, scheduler_lock{kernel_} {} +GlobalSchedulerContext::GlobalSchedulerContext(KernelCore& kernel) + : m_kernel{kernel}, m_scheduler_lock{kernel} {} GlobalSchedulerContext::~GlobalSchedulerContext() = default; void GlobalSchedulerContext::AddThread(KThread* thread) { - std::scoped_lock lock{global_list_guard}; - thread_list.push_back(thread); + std::scoped_lock lock{m_global_list_guard}; + m_thread_list.push_back(thread); } void GlobalSchedulerContext::RemoveThread(KThread* thread) { - std::scoped_lock lock{global_list_guard}; - thread_list.erase(std::remove(thread_list.begin(), thread_list.end(), thread), - thread_list.end()); + std::scoped_lock lock{m_global_list_guard}; + std::erase(m_thread_list, thread); } void GlobalSchedulerContext::PreemptThreads() { @@ -38,37 +37,37 @@ void GlobalSchedulerContext::PreemptThreads() { 63, }; - ASSERT(IsLocked()); + ASSERT(KScheduler::IsSchedulerLockedByCurrentThread(m_kernel)); for (u32 core_id = 0; core_id < Core::Hardware::NUM_CPU_CORES; core_id++) { const u32 priority = preemption_priorities[core_id]; - KScheduler::RotateScheduledQueue(kernel, core_id, priority); + KScheduler::RotateScheduledQueue(m_kernel, core_id, priority); } } bool GlobalSchedulerContext::IsLocked() const { - return scheduler_lock.IsLockedByCurrentThread(); + return m_scheduler_lock.IsLockedByCurrentThread(); } void GlobalSchedulerContext::RegisterDummyThreadForWakeup(KThread* thread) { - ASSERT(IsLocked()); + ASSERT(this->IsLocked()); - woken_dummy_threads.insert(thread); + m_woken_dummy_threads.insert(thread); } void GlobalSchedulerContext::UnregisterDummyThreadForWakeup(KThread* thread) { - ASSERT(IsLocked()); + ASSERT(this->IsLocked()); - woken_dummy_threads.erase(thread); + m_woken_dummy_threads.erase(thread); } void GlobalSchedulerContext::WakeupWaitingDummyThreads() { - ASSERT(IsLocked()); + ASSERT(this->IsLocked()); - for (auto* thread : woken_dummy_threads) { + for (auto* thread : m_woken_dummy_threads) { thread->DummyThreadEndWait(); } - woken_dummy_threads.clear(); + m_woken_dummy_threads.clear(); } } // namespace Kernel diff --git a/src/core/hle/kernel/global_scheduler_context.h b/src/core/hle/kernel/global_scheduler_context.h index 220ed6192..c48e8cd12 100644 --- a/src/core/hle/kernel/global_scheduler_context.h +++ b/src/core/hle/kernel/global_scheduler_context.h @@ -33,7 +33,7 @@ class GlobalSchedulerContext final { public: using LockType = KAbstractSchedulerLock<KScheduler>; - explicit GlobalSchedulerContext(KernelCore& kernel_); + explicit GlobalSchedulerContext(KernelCore& kernel); ~GlobalSchedulerContext(); /// Adds a new thread to the scheduler @@ -43,8 +43,9 @@ public: void RemoveThread(KThread* thread); /// Returns a list of all threads managed by the scheduler - [[nodiscard]] const std::vector<KThread*>& GetThreadList() const { - return thread_list; + /// This is only safe to iterate while holding the scheduler lock + const std::vector<KThread*>& GetThreadList() const { + return m_thread_list; } /** @@ -63,30 +64,26 @@ public: void RegisterDummyThreadForWakeup(KThread* thread); void WakeupWaitingDummyThreads(); - [[nodiscard]] LockType& SchedulerLock() { - return scheduler_lock; - } - - [[nodiscard]] const LockType& SchedulerLock() const { - return scheduler_lock; + LockType& SchedulerLock() { + return m_scheduler_lock; } private: friend class KScopedSchedulerLock; friend class KScopedSchedulerLockAndSleep; - KernelCore& kernel; + KernelCore& m_kernel; - std::atomic_bool scheduler_update_needed{}; - KSchedulerPriorityQueue priority_queue; - LockType scheduler_lock; + std::atomic_bool m_scheduler_update_needed{}; + KSchedulerPriorityQueue m_priority_queue; + LockType m_scheduler_lock; /// Lists dummy threads pending wakeup on lock release - std::set<KThread*> woken_dummy_threads; + std::set<KThread*> m_woken_dummy_threads; /// Lists all thread ids that aren't deleted/etc. - std::vector<KThread*> thread_list; - std::mutex global_list_guard; + std::vector<KThread*> m_thread_list; + std::mutex m_global_list_guard; }; } // namespace Kernel diff --git a/src/core/hle/kernel/k_address_arbiter.cpp b/src/core/hle/kernel/k_address_arbiter.cpp index fb86451ea..30a4e6edb 100644 --- a/src/core/hle/kernel/k_address_arbiter.cpp +++ b/src/core/hle/kernel/k_address_arbiter.cpp @@ -14,8 +14,8 @@ namespace Kernel { -KAddressArbiter::KAddressArbiter(Core::System& system_) - : system{system_}, kernel{system.Kernel()} {} +KAddressArbiter::KAddressArbiter(Core::System& system) + : m_system{system}, m_kernel{system.Kernel()} {} KAddressArbiter::~KAddressArbiter() = default; namespace { @@ -90,8 +90,8 @@ bool UpdateIfEqual(Core::System& system, s32* out, VAddr address, s32 value, s32 class ThreadQueueImplForKAddressArbiter final : public KThreadQueue { public: - explicit ThreadQueueImplForKAddressArbiter(KernelCore& kernel_, KAddressArbiter::ThreadTree* t) - : KThreadQueue(kernel_), m_tree(t) {} + explicit ThreadQueueImplForKAddressArbiter(KernelCore& kernel, KAddressArbiter::ThreadTree* t) + : KThreadQueue(kernel), m_tree(t) {} void CancelWait(KThread* waiting_thread, Result wait_result, bool cancel_timer_task) override { // If the thread is waiting on an address arbiter, remove it from the tree. @@ -105,7 +105,7 @@ public: } private: - KAddressArbiter::ThreadTree* m_tree; + KAddressArbiter::ThreadTree* m_tree{}; }; } // namespace @@ -114,10 +114,10 @@ Result KAddressArbiter::Signal(VAddr addr, s32 count) { // Perform signaling. s32 num_waiters{}; { - KScopedSchedulerLock sl(kernel); + KScopedSchedulerLock sl(m_kernel); - auto it = thread_tree.nfind_key({addr, -1}); - while ((it != thread_tree.end()) && (count <= 0 || num_waiters < count) && + auto it = m_tree.nfind_key({addr, -1}); + while ((it != m_tree.end()) && (count <= 0 || num_waiters < count) && (it->GetAddressArbiterKey() == addr)) { // End the thread's wait. KThread* target_thread = std::addressof(*it); @@ -126,31 +126,27 @@ Result KAddressArbiter::Signal(VAddr addr, s32 count) { ASSERT(target_thread->IsWaitingForAddressArbiter()); target_thread->ClearAddressArbiter(); - it = thread_tree.erase(it); + it = m_tree.erase(it); ++num_waiters; } } - return ResultSuccess; + R_SUCCEED(); } Result KAddressArbiter::SignalAndIncrementIfEqual(VAddr addr, s32 value, s32 count) { // Perform signaling. s32 num_waiters{}; { - KScopedSchedulerLock sl(kernel); + KScopedSchedulerLock sl(m_kernel); // Check the userspace value. s32 user_value{}; - if (!UpdateIfEqual(system, &user_value, addr, value, value + 1)) { - LOG_ERROR(Kernel, "Invalid current memory!"); - return ResultInvalidCurrentMemory; - } - if (user_value != value) { - return ResultInvalidState; - } + R_UNLESS(UpdateIfEqual(m_system, std::addressof(user_value), addr, value, value + 1), + ResultInvalidCurrentMemory); + R_UNLESS(user_value == value, ResultInvalidState); - auto it = thread_tree.nfind_key({addr, -1}); - while ((it != thread_tree.end()) && (count <= 0 || num_waiters < count) && + auto it = m_tree.nfind_key({addr, -1}); + while ((it != m_tree.end()) && (count <= 0 || num_waiters < count) && (it->GetAddressArbiterKey() == addr)) { // End the thread's wait. KThread* target_thread = std::addressof(*it); @@ -159,33 +155,33 @@ Result KAddressArbiter::SignalAndIncrementIfEqual(VAddr addr, s32 value, s32 cou ASSERT(target_thread->IsWaitingForAddressArbiter()); target_thread->ClearAddressArbiter(); - it = thread_tree.erase(it); + it = m_tree.erase(it); ++num_waiters; } } - return ResultSuccess; + R_SUCCEED(); } Result KAddressArbiter::SignalAndModifyByWaitingCountIfEqual(VAddr addr, s32 value, s32 count) { // Perform signaling. s32 num_waiters{}; { - [[maybe_unused]] const KScopedSchedulerLock sl(kernel); + KScopedSchedulerLock sl(m_kernel); - auto it = thread_tree.nfind_key({addr, -1}); + auto it = m_tree.nfind_key({addr, -1}); // Determine the updated value. s32 new_value{}; if (count <= 0) { - if (it != thread_tree.end() && it->GetAddressArbiterKey() == addr) { + if (it != m_tree.end() && it->GetAddressArbiterKey() == addr) { new_value = value - 2; } else { new_value = value + 1; } } else { - if (it != thread_tree.end() && it->GetAddressArbiterKey() == addr) { + if (it != m_tree.end() && it->GetAddressArbiterKey() == addr) { auto tmp_it = it; s32 tmp_num_waiters{}; - while (++tmp_it != thread_tree.end() && tmp_it->GetAddressArbiterKey() == addr) { + while (++tmp_it != m_tree.end() && tmp_it->GetAddressArbiterKey() == addr) { if (tmp_num_waiters++ >= count) { break; } @@ -205,20 +201,15 @@ Result KAddressArbiter::SignalAndModifyByWaitingCountIfEqual(VAddr addr, s32 val s32 user_value{}; bool succeeded{}; if (value != new_value) { - succeeded = UpdateIfEqual(system, &user_value, addr, value, new_value); + succeeded = UpdateIfEqual(m_system, std::addressof(user_value), addr, value, new_value); } else { - succeeded = ReadFromUser(system, &user_value, addr); + succeeded = ReadFromUser(m_system, std::addressof(user_value), addr); } - if (!succeeded) { - LOG_ERROR(Kernel, "Invalid current memory!"); - return ResultInvalidCurrentMemory; - } - if (user_value != value) { - return ResultInvalidState; - } + R_UNLESS(succeeded, ResultInvalidCurrentMemory); + R_UNLESS(user_value == value, ResultInvalidState); - while ((it != thread_tree.end()) && (count <= 0 || num_waiters < count) && + while ((it != m_tree.end()) && (count <= 0 || num_waiters < count) && (it->GetAddressArbiterKey() == addr)) { // End the thread's wait. KThread* target_thread = std::addressof(*it); @@ -227,58 +218,60 @@ Result KAddressArbiter::SignalAndModifyByWaitingCountIfEqual(VAddr addr, s32 val ASSERT(target_thread->IsWaitingForAddressArbiter()); target_thread->ClearAddressArbiter(); - it = thread_tree.erase(it); + it = m_tree.erase(it); ++num_waiters; } } - return ResultSuccess; + R_SUCCEED(); } Result KAddressArbiter::WaitIfLessThan(VAddr addr, s32 value, bool decrement, s64 timeout) { // Prepare to wait. - KThread* cur_thread = GetCurrentThreadPointer(kernel); - ThreadQueueImplForKAddressArbiter wait_queue(kernel, std::addressof(thread_tree)); + KThread* cur_thread = GetCurrentThreadPointer(m_kernel); + KHardwareTimer* timer{}; + ThreadQueueImplForKAddressArbiter wait_queue(m_kernel, std::addressof(m_tree)); { - KScopedSchedulerLockAndSleep slp{kernel, cur_thread, timeout}; + KScopedSchedulerLockAndSleep slp{m_kernel, std::addressof(timer), cur_thread, timeout}; // Check that the thread isn't terminating. if (cur_thread->IsTerminationRequested()) { slp.CancelSleep(); - return ResultTerminationRequested; + R_THROW(ResultTerminationRequested); } // Read the value from userspace. s32 user_value{}; bool succeeded{}; if (decrement) { - succeeded = DecrementIfLessThan(system, &user_value, addr, value); + succeeded = DecrementIfLessThan(m_system, std::addressof(user_value), addr, value); } else { - succeeded = ReadFromUser(system, &user_value, addr); + succeeded = ReadFromUser(m_system, std::addressof(user_value), addr); } if (!succeeded) { slp.CancelSleep(); - return ResultInvalidCurrentMemory; + R_THROW(ResultInvalidCurrentMemory); } // Check that the value is less than the specified one. if (user_value >= value) { slp.CancelSleep(); - return ResultInvalidState; + R_THROW(ResultInvalidState); } // Check that the timeout is non-zero. if (timeout == 0) { slp.CancelSleep(); - return ResultTimedOut; + R_THROW(ResultTimedOut); } // Set the arbiter. - cur_thread->SetAddressArbiter(&thread_tree, addr); - thread_tree.insert(*cur_thread); + cur_thread->SetAddressArbiter(std::addressof(m_tree), addr); + m_tree.insert(*cur_thread); // Wait for the thread to finish. + wait_queue.SetHardwareTimer(timer); cur_thread->BeginWait(std::addressof(wait_queue)); cur_thread->SetWaitReasonForDebugging(ThreadWaitReasonForDebugging::Arbitration); } @@ -289,42 +282,44 @@ Result KAddressArbiter::WaitIfLessThan(VAddr addr, s32 value, bool decrement, s6 Result KAddressArbiter::WaitIfEqual(VAddr addr, s32 value, s64 timeout) { // Prepare to wait. - KThread* cur_thread = GetCurrentThreadPointer(kernel); - ThreadQueueImplForKAddressArbiter wait_queue(kernel, std::addressof(thread_tree)); + KThread* cur_thread = GetCurrentThreadPointer(m_kernel); + KHardwareTimer* timer{}; + ThreadQueueImplForKAddressArbiter wait_queue(m_kernel, std::addressof(m_tree)); { - KScopedSchedulerLockAndSleep slp{kernel, cur_thread, timeout}; + KScopedSchedulerLockAndSleep slp{m_kernel, std::addressof(timer), cur_thread, timeout}; // Check that the thread isn't terminating. if (cur_thread->IsTerminationRequested()) { slp.CancelSleep(); - return ResultTerminationRequested; + R_THROW(ResultTerminationRequested); } // Read the value from userspace. s32 user_value{}; - if (!ReadFromUser(system, &user_value, addr)) { + if (!ReadFromUser(m_system, std::addressof(user_value), addr)) { slp.CancelSleep(); - return ResultInvalidCurrentMemory; + R_THROW(ResultInvalidCurrentMemory); } // Check that the value is equal. if (value != user_value) { slp.CancelSleep(); - return ResultInvalidState; + R_THROW(ResultInvalidState); } // Check that the timeout is non-zero. if (timeout == 0) { slp.CancelSleep(); - return ResultTimedOut; + R_THROW(ResultTimedOut); } // Set the arbiter. - cur_thread->SetAddressArbiter(&thread_tree, addr); - thread_tree.insert(*cur_thread); + cur_thread->SetAddressArbiter(std::addressof(m_tree), addr); + m_tree.insert(*cur_thread); // Wait for the thread to finish. + wait_queue.SetHardwareTimer(timer); cur_thread->BeginWait(std::addressof(wait_queue)); cur_thread->SetWaitReasonForDebugging(ThreadWaitReasonForDebugging::Arbitration); } diff --git a/src/core/hle/kernel/k_address_arbiter.h b/src/core/hle/kernel/k_address_arbiter.h index e4085ae22..9a8c1ae94 100644 --- a/src/core/hle/kernel/k_address_arbiter.h +++ b/src/core/hle/kernel/k_address_arbiter.h @@ -22,47 +22,46 @@ class KAddressArbiter { public: using ThreadTree = KConditionVariable::ThreadTree; - explicit KAddressArbiter(Core::System& system_); + explicit KAddressArbiter(Core::System& system); ~KAddressArbiter(); - [[nodiscard]] Result SignalToAddress(VAddr addr, Svc::SignalType type, s32 value, s32 count) { + Result SignalToAddress(VAddr addr, Svc::SignalType type, s32 value, s32 count) { switch (type) { case Svc::SignalType::Signal: - return Signal(addr, count); + R_RETURN(this->Signal(addr, count)); case Svc::SignalType::SignalAndIncrementIfEqual: - return SignalAndIncrementIfEqual(addr, value, count); + R_RETURN(this->SignalAndIncrementIfEqual(addr, value, count)); case Svc::SignalType::SignalAndModifyByWaitingCountIfEqual: - return SignalAndModifyByWaitingCountIfEqual(addr, value, count); + R_RETURN(this->SignalAndModifyByWaitingCountIfEqual(addr, value, count)); + default: + UNREACHABLE(); } - ASSERT(false); - return ResultUnknown; } - [[nodiscard]] Result WaitForAddress(VAddr addr, Svc::ArbitrationType type, s32 value, - s64 timeout) { + Result WaitForAddress(VAddr addr, Svc::ArbitrationType type, s32 value, s64 timeout) { switch (type) { case Svc::ArbitrationType::WaitIfLessThan: - return WaitIfLessThan(addr, value, false, timeout); + R_RETURN(WaitIfLessThan(addr, value, false, timeout)); case Svc::ArbitrationType::DecrementAndWaitIfLessThan: - return WaitIfLessThan(addr, value, true, timeout); + R_RETURN(WaitIfLessThan(addr, value, true, timeout)); case Svc::ArbitrationType::WaitIfEqual: - return WaitIfEqual(addr, value, timeout); + R_RETURN(WaitIfEqual(addr, value, timeout)); + default: + UNREACHABLE(); } - ASSERT(false); - return ResultUnknown; } private: - [[nodiscard]] Result Signal(VAddr addr, s32 count); - [[nodiscard]] Result SignalAndIncrementIfEqual(VAddr addr, s32 value, s32 count); - [[nodiscard]] Result SignalAndModifyByWaitingCountIfEqual(VAddr addr, s32 value, s32 count); - [[nodiscard]] Result WaitIfLessThan(VAddr addr, s32 value, bool decrement, s64 timeout); - [[nodiscard]] Result WaitIfEqual(VAddr addr, s32 value, s64 timeout); + Result Signal(VAddr addr, s32 count); + Result SignalAndIncrementIfEqual(VAddr addr, s32 value, s32 count); + Result SignalAndModifyByWaitingCountIfEqual(VAddr addr, s32 value, s32 count); + Result WaitIfLessThan(VAddr addr, s32 value, bool decrement, s64 timeout); + Result WaitIfEqual(VAddr addr, s32 value, s64 timeout); - ThreadTree thread_tree; - - Core::System& system; - KernelCore& kernel; +private: + ThreadTree m_tree; + Core::System& m_system; + KernelCore& m_kernel; }; } // namespace Kernel diff --git a/src/core/hle/kernel/k_address_space_info.cpp b/src/core/hle/kernel/k_address_space_info.cpp index 97972ebae..c36eb5dc4 100644 --- a/src/core/hle/kernel/k_address_space_info.cpp +++ b/src/core/hle/kernel/k_address_space_info.cpp @@ -44,11 +44,11 @@ const KAddressSpaceInfo& GetAddressSpaceInfo(size_t width, KAddressSpaceInfo::Ty } // namespace -uintptr_t KAddressSpaceInfo::GetAddressSpaceStart(size_t width, KAddressSpaceInfo::Type type) { +std::size_t KAddressSpaceInfo::GetAddressSpaceStart(size_t width, KAddressSpaceInfo::Type type) { return GetAddressSpaceInfo(width, type).address; } -size_t KAddressSpaceInfo::GetAddressSpaceSize(size_t width, KAddressSpaceInfo::Type type) { +std::size_t KAddressSpaceInfo::GetAddressSpaceSize(size_t width, KAddressSpaceInfo::Type type) { return GetAddressSpaceInfo(width, type).size; } diff --git a/src/core/hle/kernel/k_address_space_info.h b/src/core/hle/kernel/k_address_space_info.h index 69e9d77f2..9a26f6b90 100644 --- a/src/core/hle/kernel/k_address_space_info.h +++ b/src/core/hle/kernel/k_address_space_info.h @@ -18,7 +18,7 @@ struct KAddressSpaceInfo final { Count, }; - static u64 GetAddressSpaceStart(std::size_t width, Type type); + static std::size_t GetAddressSpaceStart(std::size_t width, Type type); static std::size_t GetAddressSpaceSize(std::size_t width, Type type); const std::size_t bit_width{}; diff --git a/src/core/hle/kernel/k_affinity_mask.h b/src/core/hle/kernel/k_affinity_mask.h index b58716e90..07a5a822c 100644 --- a/src/core/hle/kernel/k_affinity_mask.h +++ b/src/core/hle/kernel/k_affinity_mask.h @@ -13,40 +13,40 @@ class KAffinityMask { public: constexpr KAffinityMask() = default; - [[nodiscard]] constexpr u64 GetAffinityMask() const { - return this->mask; + constexpr u64 GetAffinityMask() const { + return m_mask; } constexpr void SetAffinityMask(u64 new_mask) { ASSERT((new_mask & ~AllowedAffinityMask) == 0); - this->mask = new_mask; + m_mask = new_mask; } - [[nodiscard]] constexpr bool GetAffinity(s32 core) const { - return (this->mask & GetCoreBit(core)) != 0; + constexpr bool GetAffinity(s32 core) const { + return (m_mask & GetCoreBit(core)) != 0; } constexpr void SetAffinity(s32 core, bool set) { if (set) { - this->mask |= GetCoreBit(core); + m_mask |= GetCoreBit(core); } else { - this->mask &= ~GetCoreBit(core); + m_mask &= ~GetCoreBit(core); } } constexpr void SetAll() { - this->mask = AllowedAffinityMask; + m_mask = AllowedAffinityMask; } private: - [[nodiscard]] static constexpr u64 GetCoreBit(s32 core) { + static constexpr u64 GetCoreBit(s32 core) { ASSERT(0 <= core && core < static_cast<s32>(Core::Hardware::NUM_CPU_CORES)); return (1ULL << core); } static constexpr u64 AllowedAffinityMask = (1ULL << Core::Hardware::NUM_CPU_CORES) - 1; - u64 mask{}; + u64 m_mask{}; }; } // namespace Kernel diff --git a/src/core/hle/kernel/k_auto_object.cpp b/src/core/hle/kernel/k_auto_object.cpp index 691af8ccb..0ae42c95c 100644 --- a/src/core/hle/kernel/k_auto_object.cpp +++ b/src/core/hle/kernel/k_auto_object.cpp @@ -12,11 +12,11 @@ KAutoObject* KAutoObject::Create(KAutoObject* obj) { } void KAutoObject::RegisterWithKernel() { - kernel.RegisterKernelObject(this); + m_kernel.RegisterKernelObject(this); } void KAutoObject::UnregisterWithKernel() { - kernel.UnregisterKernelObject(this); + m_kernel.UnregisterKernelObject(this); } } // namespace Kernel diff --git a/src/core/hle/kernel/k_auto_object.h b/src/core/hle/kernel/k_auto_object.h index e8118c2b8..9b71fe371 100644 --- a/src/core/hle/kernel/k_auto_object.h +++ b/src/core/hle/kernel/k_auto_object.h @@ -80,7 +80,7 @@ private: KERNEL_AUTOOBJECT_TRAITS_IMPL(KAutoObject, KAutoObject, const); public: - explicit KAutoObject(KernelCore& kernel_) : kernel(kernel_) { + explicit KAutoObject(KernelCore& kernel) : m_kernel(kernel) { RegisterWithKernel(); } virtual ~KAutoObject() = default; @@ -164,17 +164,12 @@ public: } } - const std::string& GetName() const { - return name; - } - private: void RegisterWithKernel(); void UnregisterWithKernel(); protected: - KernelCore& kernel; - std::string name; + KernelCore& m_kernel; private: std::atomic<u32> m_ref_count{}; @@ -184,7 +179,7 @@ class KAutoObjectWithListContainer; class KAutoObjectWithList : public KAutoObject, public boost::intrusive::set_base_hook<> { public: - explicit KAutoObjectWithList(KernelCore& kernel_) : KAutoObject(kernel_) {} + explicit KAutoObjectWithList(KernelCore& kernel) : KAutoObject(kernel) {} static int Compare(const KAutoObjectWithList& lhs, const KAutoObjectWithList& rhs) { const u64 lid = lhs.GetId(); @@ -200,7 +195,7 @@ public: } friend bool operator<(const KAutoObjectWithList& left, const KAutoObjectWithList& right) { - return &left < &right; + return KAutoObjectWithList::Compare(left, right) < 0; } public: @@ -208,10 +203,6 @@ public: return reinterpret_cast<u64>(this); } - virtual const std::string& GetName() const { - return name; - } - private: friend class KAutoObjectWithListContainer; }; diff --git a/src/core/hle/kernel/k_capabilities.cpp b/src/core/hle/kernel/k_capabilities.cpp index 2907cc6e3..90e4e8fb0 100644 --- a/src/core/hle/kernel/k_capabilities.cpp +++ b/src/core/hle/kernel/k_capabilities.cpp @@ -11,7 +11,7 @@ namespace Kernel { -Result KCapabilities::InitializeForKIP(std::span<const u32> kern_caps, KPageTable* page_table) { +Result KCapabilities::InitializeForKip(std::span<const u32> kern_caps, KPageTable* page_table) { // We're initializing an initial process. m_svc_access_flags.reset(); m_irq_access_flags.reset(); diff --git a/src/core/hle/kernel/k_capabilities.h b/src/core/hle/kernel/k_capabilities.h index cd96f8d23..de766c811 100644 --- a/src/core/hle/kernel/k_capabilities.h +++ b/src/core/hle/kernel/k_capabilities.h @@ -22,7 +22,7 @@ class KCapabilities { public: constexpr explicit KCapabilities() = default; - Result InitializeForKIP(std::span<const u32> kern_caps, KPageTable* page_table); + Result InitializeForKip(std::span<const u32> kern_caps, KPageTable* page_table); Result InitializeForUser(std::span<const u32> user_caps, KPageTable* page_table); static Result CheckCapabilities(KernelCore& kernel, std::span<const u32> user_caps); diff --git a/src/core/hle/kernel/k_client_port.cpp b/src/core/hle/kernel/k_client_port.cpp index c72a91a76..40e09e532 100644 --- a/src/core/hle/kernel/k_client_port.cpp +++ b/src/core/hle/kernel/k_client_port.cpp @@ -2,7 +2,6 @@ // SPDX-License-Identifier: GPL-2.0-or-later #include "common/scope_exit.h" -#include "core/hle/kernel/hle_ipc.h" #include "core/hle/kernel/k_client_port.h" #include "core/hle/kernel/k_port.h" #include "core/hle/kernel/k_scheduler.h" @@ -12,26 +11,21 @@ namespace Kernel { -KClientPort::KClientPort(KernelCore& kernel_) : KSynchronizationObject{kernel_} {} +KClientPort::KClientPort(KernelCore& kernel) : KSynchronizationObject{kernel} {} KClientPort::~KClientPort() = default; -void KClientPort::Initialize(KPort* parent_port_, s32 max_sessions_, std::string&& name_) { +void KClientPort::Initialize(KPort* parent, s32 max_sessions) { // Set member variables. - num_sessions = 0; - peak_sessions = 0; - parent = parent_port_; - max_sessions = max_sessions_; - name = std::move(name_); + m_num_sessions = 0; + m_peak_sessions = 0; + m_parent = parent; + m_max_sessions = max_sessions; } void KClientPort::OnSessionFinalized() { - KScopedSchedulerLock sl{kernel}; + KScopedSchedulerLock sl{m_kernel}; - // This might happen if a session was improperly used with this port. - ASSERT_MSG(num_sessions > 0, "num_sessions is invalid"); - - const auto prev = num_sessions--; - if (prev == max_sessions) { + if (const auto prev = m_num_sessions--; prev == m_max_sessions) { this->NotifyAvailable(); } } @@ -48,81 +42,81 @@ bool KClientPort::IsServerClosed() const { void KClientPort::Destroy() { // Note with our parent that we're closed. - parent->OnClientClosed(); + m_parent->OnClientClosed(); // Close our reference to our parent. - parent->Close(); + m_parent->Close(); } bool KClientPort::IsSignaled() const { - return num_sessions < max_sessions; + return m_num_sessions.load() < m_max_sessions; } Result KClientPort::CreateSession(KClientSession** out) { + // Declare the session we're going to allocate. + KSession* session{}; + // Reserve a new session from the resource limit. //! FIXME: we are reserving this from the wrong resource limit! - KScopedResourceReservation session_reservation(kernel.ApplicationProcess()->GetResourceLimit(), - LimitableResource::SessionCountMax); + KScopedResourceReservation session_reservation( + m_kernel.ApplicationProcess()->GetResourceLimit(), LimitableResource::SessionCountMax); R_UNLESS(session_reservation.Succeeded(), ResultLimitReached); + // Allocate a session normally. + session = KSession::Create(m_kernel); + + // Check that we successfully created a session. + R_UNLESS(session != nullptr, ResultOutOfResource); + // Update the session counts. { + ON_RESULT_FAILURE { + session->Close(); + }; + // Atomically increment the number of sessions. s32 new_sessions{}; { - const auto max = max_sessions; - auto cur_sessions = num_sessions.load(std::memory_order_acquire); + const auto max = m_max_sessions; + auto cur_sessions = m_num_sessions.load(std::memory_order_acquire); do { R_UNLESS(cur_sessions < max, ResultOutOfSessions); new_sessions = cur_sessions + 1; - } while (!num_sessions.compare_exchange_weak(cur_sessions, new_sessions, - std::memory_order_relaxed)); + } while (!m_num_sessions.compare_exchange_weak(cur_sessions, new_sessions, + std::memory_order_relaxed)); } // Atomically update the peak session tracking. { - auto peak = peak_sessions.load(std::memory_order_acquire); + auto peak = m_peak_sessions.load(std::memory_order_acquire); do { if (peak >= new_sessions) { break; } - } while (!peak_sessions.compare_exchange_weak(peak, new_sessions, - std::memory_order_relaxed)); + } while (!m_peak_sessions.compare_exchange_weak(peak, new_sessions, + std::memory_order_relaxed)); } } - // Create a new session. - KSession* session = KSession::Create(kernel); - if (session == nullptr) { - // Decrement the session count. - const auto prev = num_sessions--; - if (prev == max_sessions) { - this->NotifyAvailable(); - } - - return ResultOutOfResource; - } - // Initialize the session. - session->Initialize(this, parent->GetName()); + session->Initialize(this, m_parent->GetName()); // Commit the session reservation. session_reservation.Commit(); // Register the session. - KSession::Register(kernel, session); - auto session_guard = SCOPE_GUARD({ + KSession::Register(m_kernel, session); + ON_RESULT_FAILURE { session->GetClientSession().Close(); session->GetServerSession().Close(); - }); + }; // Enqueue the session with our parent. - R_TRY(parent->EnqueueSession(std::addressof(session->GetServerSession()))); + R_TRY(m_parent->EnqueueSession(std::addressof(session->GetServerSession()))); // We succeeded, so set the output. - session_guard.Cancel(); *out = std::addressof(session->GetClientSession()); - return ResultSuccess; + R_SUCCEED(); } } // namespace Kernel diff --git a/src/core/hle/kernel/k_client_port.h b/src/core/hle/kernel/k_client_port.h index 81046fb86..23db06ddf 100644 --- a/src/core/hle/kernel/k_client_port.h +++ b/src/core/hle/kernel/k_client_port.h @@ -4,7 +4,6 @@ #pragma once #include <memory> -#include <string> #include "common/common_types.h" #include "core/hle/kernel/k_synchronization_object.h" @@ -15,34 +14,33 @@ namespace Kernel { class KClientSession; class KernelCore; class KPort; -class SessionRequestManager; class KClientPort final : public KSynchronizationObject { KERNEL_AUTOOBJECT_TRAITS(KClientPort, KSynchronizationObject); public: - explicit KClientPort(KernelCore& kernel_); + explicit KClientPort(KernelCore& kernel); ~KClientPort() override; - void Initialize(KPort* parent_, s32 max_sessions_, std::string&& name_); + void Initialize(KPort* parent, s32 max_sessions); void OnSessionFinalized(); void OnServerClosed(); const KPort* GetParent() const { - return parent; + return m_parent; } KPort* GetParent() { - return parent; + return m_parent; } s32 GetNumSessions() const { - return num_sessions; + return m_num_sessions; } s32 GetPeakSessions() const { - return peak_sessions; + return m_peak_sessions; } s32 GetMaxSessions() const { - return max_sessions; + return m_max_sessions; } bool IsLight() const; @@ -55,10 +53,10 @@ public: Result CreateSession(KClientSession** out); private: - std::atomic<s32> num_sessions{}; - std::atomic<s32> peak_sessions{}; - s32 max_sessions{}; - KPort* parent{}; + std::atomic<s32> m_num_sessions{}; + std::atomic<s32> m_peak_sessions{}; + s32 m_max_sessions{}; + KPort* m_parent{}; }; } // namespace Kernel diff --git a/src/core/hle/kernel/k_client_session.cpp b/src/core/hle/kernel/k_client_session.cpp index b4197a8d5..d998b2be2 100644 --- a/src/core/hle/kernel/k_client_session.cpp +++ b/src/core/hle/kernel/k_client_session.cpp @@ -2,7 +2,6 @@ // SPDX-License-Identifier: GPL-2.0-or-later #include "common/scope_exit.h" -#include "core/hle/kernel/hle_ipc.h" #include "core/hle/kernel/k_client_session.h" #include "core/hle/kernel/k_server_session.h" #include "core/hle/kernel/k_session.h" @@ -13,28 +12,27 @@ namespace Kernel { static constexpr u32 MessageBufferSize = 0x100; -KClientSession::KClientSession(KernelCore& kernel_) - : KAutoObjectWithSlabHeapAndContainer{kernel_} {} +KClientSession::KClientSession(KernelCore& kernel) : KAutoObjectWithSlabHeapAndContainer{kernel} {} KClientSession::~KClientSession() = default; void KClientSession::Destroy() { - parent->OnClientClosed(); - parent->Close(); + m_parent->OnClientClosed(); + m_parent->Close(); } void KClientSession::OnServerClosed() {} Result KClientSession::SendSyncRequest() { // Create a session request. - KSessionRequest* request = KSessionRequest::Create(kernel); + KSessionRequest* request = KSessionRequest::Create(m_kernel); R_UNLESS(request != nullptr, ResultOutOfResource); SCOPE_EXIT({ request->Close(); }); // Initialize the request. - request->Initialize(nullptr, GetCurrentThread(kernel).GetTLSAddress(), MessageBufferSize); + request->Initialize(nullptr, GetCurrentThread(m_kernel).GetTlsAddress(), MessageBufferSize); // Send the request. - return parent->GetServerSession().OnRequest(request); + R_RETURN(m_parent->GetServerSession().OnRequest(request)); } } // namespace Kernel diff --git a/src/core/hle/kernel/k_client_session.h b/src/core/hle/kernel/k_client_session.h index b4a19c546..9b62e55e4 100644 --- a/src/core/hle/kernel/k_client_session.h +++ b/src/core/hle/kernel/k_client_session.h @@ -30,20 +30,19 @@ class KClientSession final KERNEL_AUTOOBJECT_TRAITS(KClientSession, KAutoObject); public: - explicit KClientSession(KernelCore& kernel_); + explicit KClientSession(KernelCore& kernel); ~KClientSession() override; - void Initialize(KSession* parent_session_, std::string&& name_) { + void Initialize(KSession* parent) { // Set member variables. - parent = parent_session_; - name = std::move(name_); + m_parent = parent; } void Destroy() override; - static void PostDestroy([[maybe_unused]] uintptr_t arg) {} + static void PostDestroy(uintptr_t arg) {} KSession* GetParent() const { - return parent; + return m_parent; } Result SendSyncRequest(); @@ -51,7 +50,7 @@ public: void OnServerClosed(); private: - KSession* parent{}; + KSession* m_parent{}; }; } // namespace Kernel diff --git a/src/core/hle/kernel/k_code_memory.cpp b/src/core/hle/kernel/k_code_memory.cpp index 6c44a9e99..89df6b5d8 100644 --- a/src/core/hle/kernel/k_code_memory.cpp +++ b/src/core/hle/kernel/k_code_memory.cpp @@ -16,18 +16,18 @@ namespace Kernel { -KCodeMemory::KCodeMemory(KernelCore& kernel_) - : KAutoObjectWithSlabHeapAndContainer{kernel_}, m_lock(kernel_) {} +KCodeMemory::KCodeMemory(KernelCore& kernel) + : KAutoObjectWithSlabHeapAndContainer{kernel}, m_lock(kernel) {} Result KCodeMemory::Initialize(Core::DeviceMemory& device_memory, VAddr addr, size_t size) { // Set members. - m_owner = GetCurrentProcessPointer(kernel); + m_owner = GetCurrentProcessPointer(m_kernel); // Get the owner page table. auto& page_table = m_owner->PageTable(); // Construct the page group. - m_page_group.emplace(kernel, page_table.GetBlockInfoManager()); + m_page_group.emplace(m_kernel, page_table.GetBlockInfoManager()); // Lock the memory. R_TRY(page_table.LockForCodeMemory(std::addressof(*m_page_group), addr, size)) @@ -45,7 +45,7 @@ Result KCodeMemory::Initialize(Core::DeviceMemory& device_memory, VAddr addr, si m_is_mapped = false; // We succeeded. - return ResultSuccess; + R_SUCCEED(); } void KCodeMemory::Finalize() { @@ -74,13 +74,13 @@ Result KCodeMemory::Map(VAddr address, size_t size) { R_UNLESS(!m_is_mapped, ResultInvalidState); // Map the memory. - R_TRY(GetCurrentProcess(kernel).PageTable().MapPageGroup( + R_TRY(GetCurrentProcess(m_kernel).PageTable().MapPageGroup( address, *m_page_group, KMemoryState::CodeOut, KMemoryPermission::UserReadWrite)); // Mark ourselves as mapped. m_is_mapped = true; - return ResultSuccess; + R_SUCCEED(); } Result KCodeMemory::Unmap(VAddr address, size_t size) { @@ -91,13 +91,13 @@ Result KCodeMemory::Unmap(VAddr address, size_t size) { KScopedLightLock lk(m_lock); // Unmap the memory. - R_TRY(GetCurrentProcess(kernel).PageTable().UnmapPageGroup(address, *m_page_group, - KMemoryState::CodeOut)); + R_TRY(GetCurrentProcess(m_kernel).PageTable().UnmapPageGroup(address, *m_page_group, + KMemoryState::CodeOut)); // Mark ourselves as unmapped. m_is_mapped = false; - return ResultSuccess; + R_SUCCEED(); } Result KCodeMemory::MapToOwner(VAddr address, size_t size, Svc::MemoryPermission perm) { @@ -131,7 +131,7 @@ Result KCodeMemory::MapToOwner(VAddr address, size_t size, Svc::MemoryPermission // Mark ourselves as mapped. m_is_owner_mapped = true; - return ResultSuccess; + R_SUCCEED(); } Result KCodeMemory::UnmapFromOwner(VAddr address, size_t size) { @@ -147,7 +147,7 @@ Result KCodeMemory::UnmapFromOwner(VAddr address, size_t size) { // Mark ourselves as unmapped. m_is_owner_mapped = false; - return ResultSuccess; + R_SUCCEED(); } } // namespace Kernel diff --git a/src/core/hle/kernel/k_code_memory.h b/src/core/hle/kernel/k_code_memory.h index 5b260b385..23cbb283b 100644 --- a/src/core/hle/kernel/k_code_memory.h +++ b/src/core/hle/kernel/k_code_memory.h @@ -29,7 +29,7 @@ class KCodeMemory final KERNEL_AUTOOBJECT_TRAITS(KCodeMemory, KAutoObject); public: - explicit KCodeMemory(KernelCore& kernel_); + explicit KCodeMemory(KernelCore& kernel); Result Initialize(Core::DeviceMemory& device_memory, VAddr address, size_t size); void Finalize() override; @@ -42,7 +42,7 @@ public: bool IsInitialized() const override { return m_is_initialized; } - static void PostDestroy([[maybe_unused]] uintptr_t arg) {} + static void PostDestroy(uintptr_t arg) {} KProcess* GetOwner() const override { return m_owner; diff --git a/src/core/hle/kernel/k_condition_variable.cpp b/src/core/hle/kernel/k_condition_variable.cpp index f40cf92b1..58b8609d8 100644 --- a/src/core/hle/kernel/k_condition_variable.cpp +++ b/src/core/hle/kernel/k_condition_variable.cpp @@ -4,7 +4,6 @@ #include "core/arm/exclusive_monitor.h" #include "core/core.h" #include "core/hle/kernel/k_condition_variable.h" -#include "core/hle/kernel/k_linked_list.h" #include "core/hle/kernel/k_process.h" #include "core/hle/kernel/k_scheduler.h" #include "core/hle/kernel/k_scoped_scheduler_lock_and_sleep.h" @@ -58,8 +57,8 @@ bool UpdateLockAtomic(Core::System& system, u32* out, VAddr address, u32 if_zero class ThreadQueueImplForKConditionVariableWaitForAddress final : public KThreadQueue { public: - explicit ThreadQueueImplForKConditionVariableWaitForAddress(KernelCore& kernel_) - : KThreadQueue(kernel_) {} + explicit ThreadQueueImplForKConditionVariableWaitForAddress(KernelCore& kernel) + : KThreadQueue(kernel) {} void CancelWait(KThread* waiting_thread, Result wait_result, bool cancel_timer_task) override { // Remove the thread as a waiter from its owner. @@ -76,8 +75,8 @@ private: public: explicit ThreadQueueImplForKConditionVariableWaitConditionVariable( - KernelCore& kernel_, KConditionVariable::ThreadTree* t) - : KThreadQueue(kernel_), m_tree(t) {} + KernelCore& kernel, KConditionVariable::ThreadTree* t) + : KThreadQueue(kernel), m_tree(t) {} void CancelWait(KThread* waiting_thread, Result wait_result, bool cancel_timer_task) override { // Remove the thread as a waiter from its owner. @@ -98,17 +97,17 @@ public: } // namespace -KConditionVariable::KConditionVariable(Core::System& system_) - : system{system_}, kernel{system.Kernel()} {} +KConditionVariable::KConditionVariable(Core::System& system) + : m_system{system}, m_kernel{system.Kernel()} {} KConditionVariable::~KConditionVariable() = default; Result KConditionVariable::SignalToAddress(VAddr addr) { - KThread* owner_thread = GetCurrentThreadPointer(kernel); + KThread* owner_thread = GetCurrentThreadPointer(m_kernel); // Signal the address. { - KScopedSchedulerLock sl(kernel); + KScopedSchedulerLock sl(m_kernel); // Remove waiter thread. bool has_waiters{}; @@ -129,7 +128,7 @@ Result KConditionVariable::SignalToAddress(VAddr addr) { // Write the value to userspace. Result result{ResultSuccess}; - if (WriteToUser(system, addr, std::addressof(next_value))) [[likely]] { + if (WriteToUser(m_system, addr, std::addressof(next_value))) [[likely]] { result = ResultSuccess; } else { result = ResultInvalidCurrentMemory; @@ -145,26 +144,27 @@ Result KConditionVariable::SignalToAddress(VAddr addr) { } Result KConditionVariable::WaitForAddress(Handle handle, VAddr addr, u32 value) { - KThread* cur_thread = GetCurrentThreadPointer(kernel); - ThreadQueueImplForKConditionVariableWaitForAddress wait_queue(kernel); + KThread* cur_thread = GetCurrentThreadPointer(m_kernel); + ThreadQueueImplForKConditionVariableWaitForAddress wait_queue(m_kernel); // Wait for the address. KThread* owner_thread{}; { - KScopedSchedulerLock sl(kernel); + KScopedSchedulerLock sl(m_kernel); // Check if the thread should terminate. R_UNLESS(!cur_thread->IsTerminationRequested(), ResultTerminationRequested); // Read the tag from userspace. u32 test_tag{}; - R_UNLESS(ReadFromUser(system, std::addressof(test_tag), addr), ResultInvalidCurrentMemory); + R_UNLESS(ReadFromUser(m_system, std::addressof(test_tag), addr), + ResultInvalidCurrentMemory); // If the tag isn't the handle (with wait mask), we're done. R_SUCCEED_IF(test_tag != (handle | Svc::HandleWaitMask)); // Get the lock owner thread. - owner_thread = GetCurrentProcess(kernel) + owner_thread = GetCurrentProcess(m_kernel) .GetHandleTable() .GetObjectWithoutPseudoHandle<KThread>(handle) .ReleasePointerUnsafe(); @@ -177,19 +177,18 @@ Result KConditionVariable::WaitForAddress(Handle handle, VAddr addr, u32 value) // Begin waiting. cur_thread->BeginWait(std::addressof(wait_queue)); cur_thread->SetWaitReasonForDebugging(ThreadWaitReasonForDebugging::ConditionVar); - cur_thread->SetMutexWaitAddressForDebugging(addr); } // Close our reference to the owner thread, now that the wait is over. owner_thread->Close(); // Get the wait result. - return cur_thread->GetWaitResult(); + R_RETURN(cur_thread->GetWaitResult()); } void KConditionVariable::SignalImpl(KThread* thread) { // Check pre-conditions. - ASSERT(kernel.GlobalSchedulerContext().IsLocked()); + ASSERT(KScheduler::IsSchedulerLockedByCurrentThread(m_kernel)); // Update the tag. VAddr address = thread->GetAddressKey(); @@ -204,7 +203,7 @@ void KConditionVariable::SignalImpl(KThread* thread) { // TODO(bunnei): We should call CanAccessAtomic(..) here. can_access = true; if (can_access) [[likely]] { - UpdateLockAtomic(system, std::addressof(prev_tag), address, own_tag, + UpdateLockAtomic(m_system, std::addressof(prev_tag), address, own_tag, Svc::HandleWaitMask); } } @@ -215,7 +214,7 @@ void KConditionVariable::SignalImpl(KThread* thread) { thread->EndWait(ResultSuccess); } else { // Get the previous owner. - KThread* owner_thread = GetCurrentProcess(kernel) + KThread* owner_thread = GetCurrentProcess(m_kernel) .GetHandleTable() .GetObjectWithoutPseudoHandle<KThread>( static_cast<Handle>(prev_tag & ~Svc::HandleWaitMask)) @@ -240,14 +239,14 @@ void KConditionVariable::Signal(u64 cv_key, s32 count) { // Perform signaling. s32 num_waiters{}; { - KScopedSchedulerLock sl(kernel); + KScopedSchedulerLock sl(m_kernel); - auto it = thread_tree.nfind_key({cv_key, -1}); - while ((it != thread_tree.end()) && (count <= 0 || num_waiters < count) && + auto it = m_tree.nfind_key({cv_key, -1}); + while ((it != m_tree.end()) && (count <= 0 || num_waiters < count) && (it->GetConditionVariableKey() == cv_key)) { KThread* target_thread = std::addressof(*it); - it = thread_tree.erase(it); + it = m_tree.erase(it); target_thread->ClearConditionVariable(); this->SignalImpl(target_thread); @@ -256,26 +255,27 @@ void KConditionVariable::Signal(u64 cv_key, s32 count) { } // If we have no waiters, clear the has waiter flag. - if (it == thread_tree.end() || it->GetConditionVariableKey() != cv_key) { + if (it == m_tree.end() || it->GetConditionVariableKey() != cv_key) { const u32 has_waiter_flag{}; - WriteToUser(system, cv_key, std::addressof(has_waiter_flag)); + WriteToUser(m_system, cv_key, std::addressof(has_waiter_flag)); } } } Result KConditionVariable::Wait(VAddr addr, u64 key, u32 value, s64 timeout) { // Prepare to wait. - KThread* cur_thread = GetCurrentThreadPointer(kernel); - ThreadQueueImplForKConditionVariableWaitConditionVariable wait_queue( - kernel, std::addressof(thread_tree)); + KThread* cur_thread = GetCurrentThreadPointer(m_kernel); + KHardwareTimer* timer{}; + ThreadQueueImplForKConditionVariableWaitConditionVariable wait_queue(m_kernel, + std::addressof(m_tree)); { - KScopedSchedulerLockAndSleep slp(kernel, cur_thread, timeout); + KScopedSchedulerLockAndSleep slp(m_kernel, std::addressof(timer), cur_thread, timeout); // Check that the thread isn't terminating. if (cur_thread->IsTerminationRequested()) { slp.CancelSleep(); - return ResultTerminationRequested; + R_THROW(ResultTerminationRequested); } // Update the value and process for the next owner. @@ -301,14 +301,14 @@ Result KConditionVariable::Wait(VAddr addr, u64 key, u32 value, s64 timeout) { // Write to the cv key. { const u32 has_waiter_flag = 1; - WriteToUser(system, key, std::addressof(has_waiter_flag)); - // TODO(bunnei): We should call DataMemoryBarrier(..) here. + WriteToUser(m_system, key, std::addressof(has_waiter_flag)); + std::atomic_thread_fence(std::memory_order_seq_cst); } // Write the value to userspace. - if (!WriteToUser(system, addr, std::addressof(next_value))) { + if (!WriteToUser(m_system, addr, std::addressof(next_value))) { slp.CancelSleep(); - return ResultInvalidCurrentMemory; + R_THROW(ResultInvalidCurrentMemory); } } @@ -316,17 +316,17 @@ Result KConditionVariable::Wait(VAddr addr, u64 key, u32 value, s64 timeout) { R_UNLESS(timeout != 0, ResultTimedOut); // Update condition variable tracking. - cur_thread->SetConditionVariable(std::addressof(thread_tree), addr, key, value); - thread_tree.insert(*cur_thread); + cur_thread->SetConditionVariable(std::addressof(m_tree), addr, key, value); + m_tree.insert(*cur_thread); // Begin waiting. + wait_queue.SetHardwareTimer(timer); cur_thread->BeginWait(std::addressof(wait_queue)); cur_thread->SetWaitReasonForDebugging(ThreadWaitReasonForDebugging::ConditionVar); - cur_thread->SetMutexWaitAddressForDebugging(addr); } // Get the wait result. - return cur_thread->GetWaitResult(); + R_RETURN(cur_thread->GetWaitResult()); } } // namespace Kernel diff --git a/src/core/hle/kernel/k_condition_variable.h b/src/core/hle/kernel/k_condition_variable.h index fad4ed011..fbd2c1fc0 100644 --- a/src/core/hle/kernel/k_condition_variable.h +++ b/src/core/hle/kernel/k_condition_variable.h @@ -21,36 +21,36 @@ class KConditionVariable { public: using ThreadTree = typename KThread::ConditionVariableThreadTreeType; - explicit KConditionVariable(Core::System& system_); + explicit KConditionVariable(Core::System& system); ~KConditionVariable(); // Arbitration - [[nodiscard]] Result SignalToAddress(VAddr addr); - [[nodiscard]] Result WaitForAddress(Handle handle, VAddr addr, u32 value); + Result SignalToAddress(VAddr addr); + Result WaitForAddress(Handle handle, VAddr addr, u32 value); // Condition variable void Signal(u64 cv_key, s32 count); - [[nodiscard]] Result Wait(VAddr addr, u64 key, u32 value, s64 timeout); + Result Wait(VAddr addr, u64 key, u32 value, s64 timeout); private: void SignalImpl(KThread* thread); - ThreadTree thread_tree; - - Core::System& system; - KernelCore& kernel; +private: + Core::System& m_system; + KernelCore& m_kernel; + ThreadTree m_tree{}; }; -inline void BeforeUpdatePriority(const KernelCore& kernel, KConditionVariable::ThreadTree* tree, +inline void BeforeUpdatePriority(KernelCore& kernel, KConditionVariable::ThreadTree* tree, KThread* thread) { - ASSERT(kernel.GlobalSchedulerContext().IsLocked()); + ASSERT(KScheduler::IsSchedulerLockedByCurrentThread(kernel)); tree->erase(tree->iterator_to(*thread)); } -inline void AfterUpdatePriority(const KernelCore& kernel, KConditionVariable::ThreadTree* tree, +inline void AfterUpdatePriority(KernelCore& kernel, KConditionVariable::ThreadTree* tree, KThread* thread) { - ASSERT(kernel.GlobalSchedulerContext().IsLocked()); + ASSERT(KScheduler::IsSchedulerLockedByCurrentThread(kernel)); tree->insert(*thread); } diff --git a/src/core/hle/kernel/k_debug.h b/src/core/hle/kernel/k_debug.h index e3a0689c8..2290e3bca 100644 --- a/src/core/hle/kernel/k_debug.h +++ b/src/core/hle/kernel/k_debug.h @@ -12,9 +12,9 @@ class KDebug final : public KAutoObjectWithSlabHeapAndContainer<KDebug, KAutoObj KERNEL_AUTOOBJECT_TRAITS(KDebug, KAutoObject); public: - explicit KDebug(KernelCore& kernel_) : KAutoObjectWithSlabHeapAndContainer{kernel_} {} + explicit KDebug(KernelCore& kernel) : KAutoObjectWithSlabHeapAndContainer{kernel} {} - static void PostDestroy([[maybe_unused]] uintptr_t arg) {} + static void PostDestroy(uintptr_t arg) {} }; } // namespace Kernel diff --git a/src/core/hle/kernel/k_device_address_space.cpp b/src/core/hle/kernel/k_device_address_space.cpp index 27659ea3b..a2fc4fe1f 100644 --- a/src/core/hle/kernel/k_device_address_space.cpp +++ b/src/core/hle/kernel/k_device_address_space.cpp @@ -9,8 +9,8 @@ namespace Kernel { -KDeviceAddressSpace::KDeviceAddressSpace(KernelCore& kernel_) - : KAutoObjectWithSlabHeapAndContainer(kernel_), m_lock(kernel_), m_is_initialized(false) {} +KDeviceAddressSpace::KDeviceAddressSpace(KernelCore& kernel) + : KAutoObjectWithSlabHeapAndContainer(kernel), m_lock(kernel), m_is_initialized(false) {} KDeviceAddressSpace::~KDeviceAddressSpace() = default; void KDeviceAddressSpace::Initialize() { diff --git a/src/core/hle/kernel/k_device_address_space.h b/src/core/hle/kernel/k_device_address_space.h index 4709df995..b4a014c38 100644 --- a/src/core/hle/kernel/k_device_address_space.h +++ b/src/core/hle/kernel/k_device_address_space.h @@ -21,9 +21,9 @@ public: ~KDeviceAddressSpace(); Result Initialize(u64 address, u64 size); - void Finalize(); + void Finalize() override; - bool IsInitialized() const { + bool IsInitialized() const override { return m_is_initialized; } static void PostDestroy(uintptr_t arg) {} diff --git a/src/core/hle/kernel/k_event.cpp b/src/core/hle/kernel/k_event.cpp index d973853ab..d92b491f8 100644 --- a/src/core/hle/kernel/k_event.cpp +++ b/src/core/hle/kernel/k_event.cpp @@ -7,8 +7,8 @@ namespace Kernel { -KEvent::KEvent(KernelCore& kernel_) - : KAutoObjectWithSlabHeapAndContainer{kernel_}, m_readable_event{kernel_} {} +KEvent::KEvent(KernelCore& kernel) + : KAutoObjectWithSlabHeapAndContainer{kernel}, m_readable_event{kernel} {} KEvent::~KEvent() = default; @@ -36,7 +36,7 @@ void KEvent::Finalize() { } Result KEvent::Signal() { - KScopedSchedulerLock sl{kernel}; + KScopedSchedulerLock sl{m_kernel}; R_SUCCEED_IF(m_readable_event_destroyed); @@ -44,7 +44,7 @@ Result KEvent::Signal() { } Result KEvent::Clear() { - KScopedSchedulerLock sl{kernel}; + KScopedSchedulerLock sl{m_kernel}; R_SUCCEED_IF(m_readable_event_destroyed); diff --git a/src/core/hle/kernel/k_event.h b/src/core/hle/kernel/k_event.h index 48ce7d9a0..f522b0a84 100644 --- a/src/core/hle/kernel/k_event.h +++ b/src/core/hle/kernel/k_event.h @@ -16,7 +16,7 @@ class KEvent final : public KAutoObjectWithSlabHeapAndContainer<KEvent, KAutoObj KERNEL_AUTOOBJECT_TRAITS(KEvent, KAutoObject); public: - explicit KEvent(KernelCore& kernel_); + explicit KEvent(KernelCore& kernel); ~KEvent() override; void Initialize(KProcess* owner); diff --git a/src/core/hle/kernel/k_light_condition_variable.cpp b/src/core/hle/kernel/k_light_condition_variable.cpp index cade99cfd..6d5a815aa 100644 --- a/src/core/hle/kernel/k_light_condition_variable.cpp +++ b/src/core/hle/kernel/k_light_condition_variable.cpp @@ -13,9 +13,9 @@ namespace { class ThreadQueueImplForKLightConditionVariable final : public KThreadQueue { public: - ThreadQueueImplForKLightConditionVariable(KernelCore& kernel_, KThread::WaiterList* wl, + ThreadQueueImplForKLightConditionVariable(KernelCore& kernel, KThread::WaiterList* wl, bool term) - : KThreadQueue(kernel_), m_wait_list(wl), m_allow_terminating_thread(term) {} + : KThreadQueue(kernel), m_wait_list(wl), m_allow_terminating_thread(term) {} void CancelWait(KThread* waiting_thread, Result wait_result, bool cancel_timer_task) override { // Only process waits if we're allowed to. @@ -39,14 +39,15 @@ private: void KLightConditionVariable::Wait(KLightLock* lock, s64 timeout, bool allow_terminating_thread) { // Create thread queue. - KThread* owner = GetCurrentThreadPointer(kernel); + KThread* owner = GetCurrentThreadPointer(m_kernel); + KHardwareTimer* timer{}; - ThreadQueueImplForKLightConditionVariable wait_queue(kernel, std::addressof(wait_list), + ThreadQueueImplForKLightConditionVariable wait_queue(m_kernel, std::addressof(m_wait_list), allow_terminating_thread); // Sleep the thread. { - KScopedSchedulerLockAndSleep lk(kernel, owner, timeout); + KScopedSchedulerLockAndSleep lk(m_kernel, std::addressof(timer), owner, timeout); if (!allow_terminating_thread && owner->IsTerminationRequested()) { lk.CancelSleep(); @@ -56,9 +57,10 @@ void KLightConditionVariable::Wait(KLightLock* lock, s64 timeout, bool allow_ter lock->Unlock(); // Add the thread to the queue. - wait_list.push_back(*owner); + m_wait_list.push_back(*owner); // Begin waiting. + wait_queue.SetHardwareTimer(timer); owner->BeginWait(std::addressof(wait_queue)); } @@ -67,10 +69,10 @@ void KLightConditionVariable::Wait(KLightLock* lock, s64 timeout, bool allow_ter } void KLightConditionVariable::Broadcast() { - KScopedSchedulerLock lk(kernel); + KScopedSchedulerLock lk(m_kernel); // Signal all threads. - for (auto it = wait_list.begin(); it != wait_list.end(); it = wait_list.erase(it)) { + for (auto it = m_wait_list.begin(); it != m_wait_list.end(); it = m_wait_list.erase(it)) { it->EndWait(ResultSuccess); } } diff --git a/src/core/hle/kernel/k_light_condition_variable.h b/src/core/hle/kernel/k_light_condition_variable.h index 3cabd6b4f..ab612426d 100644 --- a/src/core/hle/kernel/k_light_condition_variable.h +++ b/src/core/hle/kernel/k_light_condition_variable.h @@ -13,13 +13,13 @@ class KLightLock; class KLightConditionVariable { public: - explicit KLightConditionVariable(KernelCore& kernel_) : kernel{kernel_} {} + explicit KLightConditionVariable(KernelCore& kernel) : m_kernel{kernel} {} void Wait(KLightLock* lock, s64 timeout = -1, bool allow_terminating_thread = true); void Broadcast(); private: - KernelCore& kernel; - KThread::WaiterList wait_list{}; + KernelCore& m_kernel; + KThread::WaiterList m_wait_list{}; }; } // namespace Kernel diff --git a/src/core/hle/kernel/k_light_lock.cpp b/src/core/hle/kernel/k_light_lock.cpp index 14cb615da..e87ee8b65 100644 --- a/src/core/hle/kernel/k_light_lock.cpp +++ b/src/core/hle/kernel/k_light_lock.cpp @@ -13,7 +13,7 @@ namespace { class ThreadQueueImplForKLightLock final : public KThreadQueue { public: - explicit ThreadQueueImplForKLightLock(KernelCore& kernel_) : KThreadQueue(kernel_) {} + explicit ThreadQueueImplForKLightLock(KernelCore& kernel) : KThreadQueue(kernel) {} void CancelWait(KThread* waiting_thread, Result wait_result, bool cancel_timer_task) override { // Remove the thread as a waiter from its owner. @@ -29,13 +29,13 @@ public: } // namespace void KLightLock::Lock() { - const uintptr_t cur_thread = reinterpret_cast<uintptr_t>(GetCurrentThreadPointer(kernel)); + const uintptr_t cur_thread = reinterpret_cast<uintptr_t>(GetCurrentThreadPointer(m_kernel)); while (true) { - uintptr_t old_tag = tag.load(std::memory_order_relaxed); + uintptr_t old_tag = m_tag.load(std::memory_order_relaxed); - while (!tag.compare_exchange_weak(old_tag, (old_tag == 0) ? cur_thread : (old_tag | 1), - std::memory_order_acquire)) { + while (!m_tag.compare_exchange_weak(old_tag, (old_tag == 0) ? cur_thread : (old_tag | 1), + std::memory_order_acquire)) { } if (old_tag == 0 || this->LockSlowPath(old_tag | 1, cur_thread)) { @@ -45,30 +45,30 @@ void KLightLock::Lock() { } void KLightLock::Unlock() { - const uintptr_t cur_thread = reinterpret_cast<uintptr_t>(GetCurrentThreadPointer(kernel)); + const uintptr_t cur_thread = reinterpret_cast<uintptr_t>(GetCurrentThreadPointer(m_kernel)); uintptr_t expected = cur_thread; - if (!tag.compare_exchange_strong(expected, 0, std::memory_order_release)) { + if (!m_tag.compare_exchange_strong(expected, 0, std::memory_order_release)) { this->UnlockSlowPath(cur_thread); } } bool KLightLock::LockSlowPath(uintptr_t _owner, uintptr_t _cur_thread) { KThread* cur_thread = reinterpret_cast<KThread*>(_cur_thread); - ThreadQueueImplForKLightLock wait_queue(kernel); + ThreadQueueImplForKLightLock wait_queue(m_kernel); // Pend the current thread waiting on the owner thread. { - KScopedSchedulerLock sl{kernel}; + KScopedSchedulerLock sl{m_kernel}; // Ensure we actually have locking to do. - if (tag.load(std::memory_order_relaxed) != _owner) { + if (m_tag.load(std::memory_order_relaxed) != _owner) { return false; } // Add the current thread as a waiter on the owner. KThread* owner_thread = reinterpret_cast<KThread*>(_owner & ~1ULL); - cur_thread->SetKernelAddressKey(reinterpret_cast<uintptr_t>(std::addressof(tag))); + cur_thread->SetKernelAddressKey(reinterpret_cast<uintptr_t>(std::addressof(m_tag))); owner_thread->AddWaiter(cur_thread); // Begin waiting to hold the lock. @@ -87,12 +87,12 @@ void KLightLock::UnlockSlowPath(uintptr_t _cur_thread) { // Unlock. { - KScopedSchedulerLock sl(kernel); + KScopedSchedulerLock sl(m_kernel); // Get the next owner. bool has_waiters; KThread* next_owner = owner_thread->RemoveKernelWaiterByKey( - std::addressof(has_waiters), reinterpret_cast<uintptr_t>(std::addressof(tag))); + std::addressof(has_waiters), reinterpret_cast<uintptr_t>(std::addressof(m_tag))); // Pass the lock to the next owner. uintptr_t next_tag = 0; @@ -114,12 +114,13 @@ void KLightLock::UnlockSlowPath(uintptr_t _cur_thread) { } // Write the new tag value. - tag.store(next_tag, std::memory_order_release); + m_tag.store(next_tag, std::memory_order_release); } } bool KLightLock::IsLockedByCurrentThread() const { - return (tag | 1ULL) == (reinterpret_cast<uintptr_t>(GetCurrentThreadPointer(kernel)) | 1ULL); + return (m_tag.load() | 1ULL) == + (reinterpret_cast<uintptr_t>(GetCurrentThreadPointer(m_kernel)) | 1ULL); } } // namespace Kernel diff --git a/src/core/hle/kernel/k_light_lock.h b/src/core/hle/kernel/k_light_lock.h index 7edd950c0..626f57596 100644 --- a/src/core/hle/kernel/k_light_lock.h +++ b/src/core/hle/kernel/k_light_lock.h @@ -13,7 +13,7 @@ class KernelCore; class KLightLock { public: - explicit KLightLock(KernelCore& kernel_) : kernel{kernel_} {} + explicit KLightLock(KernelCore& kernel) : m_kernel{kernel} {} void Lock(); @@ -24,14 +24,14 @@ public: void UnlockSlowPath(uintptr_t cur_thread); bool IsLocked() const { - return tag != 0; + return m_tag.load() != 0; } bool IsLockedByCurrentThread() const; private: - std::atomic<uintptr_t> tag{}; - KernelCore& kernel; + std::atomic<uintptr_t> m_tag{}; + KernelCore& m_kernel; }; using KScopedLightLock = KScopedLock<KLightLock>; diff --git a/src/core/hle/kernel/k_linked_list.h b/src/core/hle/kernel/k_linked_list.h deleted file mode 100644 index 29ebd16b7..000000000 --- a/src/core/hle/kernel/k_linked_list.h +++ /dev/null @@ -1,238 +0,0 @@ -// SPDX-FileCopyrightText: Copyright 2021 yuzu Emulator Project -// SPDX-License-Identifier: GPL-2.0-or-later - -#pragma once - -#include <boost/intrusive/list.hpp> - -#include "common/assert.h" -#include "core/hle/kernel/slab_helpers.h" - -namespace Kernel { - -class KernelCore; - -class KLinkedListNode : public boost::intrusive::list_base_hook<>, - public KSlabAllocated<KLinkedListNode> { - -public: - explicit KLinkedListNode(KernelCore&) {} - KLinkedListNode() = default; - - void Initialize(void* it) { - m_item = it; - } - - void* GetItem() const { - return m_item; - } - -private: - void* m_item = nullptr; -}; - -template <typename T> -class KLinkedList : private boost::intrusive::list<KLinkedListNode> { -private: - using BaseList = boost::intrusive::list<KLinkedListNode>; - -public: - template <bool Const> - class Iterator; - - using value_type = T; - using size_type = size_t; - using difference_type = ptrdiff_t; - using pointer = value_type*; - using const_pointer = const value_type*; - using reference = value_type&; - using const_reference = const value_type&; - using iterator = Iterator<false>; - using const_iterator = Iterator<true>; - using reverse_iterator = std::reverse_iterator<iterator>; - using const_reverse_iterator = std::reverse_iterator<const_iterator>; - - template <bool Const> - class Iterator { - private: - using BaseIterator = BaseList::iterator; - friend class KLinkedList; - - public: - using iterator_category = std::bidirectional_iterator_tag; - using value_type = typename KLinkedList::value_type; - using difference_type = typename KLinkedList::difference_type; - using pointer = std::conditional_t<Const, KLinkedList::const_pointer, KLinkedList::pointer>; - using reference = - std::conditional_t<Const, KLinkedList::const_reference, KLinkedList::reference>; - - public: - explicit Iterator(BaseIterator it) : m_base_it(it) {} - - pointer GetItem() const { - return static_cast<pointer>(m_base_it->GetItem()); - } - - bool operator==(const Iterator& rhs) const { - return m_base_it == rhs.m_base_it; - } - - bool operator!=(const Iterator& rhs) const { - return !(*this == rhs); - } - - pointer operator->() const { - return this->GetItem(); - } - - reference operator*() const { - return *this->GetItem(); - } - - Iterator& operator++() { - ++m_base_it; - return *this; - } - - Iterator& operator--() { - --m_base_it; - return *this; - } - - Iterator operator++(int) { - const Iterator it{*this}; - ++(*this); - return it; - } - - Iterator operator--(int) { - const Iterator it{*this}; - --(*this); - return it; - } - - operator Iterator<true>() const { - return Iterator<true>(m_base_it); - } - - private: - BaseIterator m_base_it; - }; - -public: - constexpr KLinkedList(KernelCore& kernel_) : BaseList(), kernel{kernel_} {} - - ~KLinkedList() { - // Erase all elements. - for (auto it = begin(); it != end(); it = erase(it)) { - } - - // Ensure we succeeded. - ASSERT(this->empty()); - } - - // Iterator accessors. - iterator begin() { - return iterator(BaseList::begin()); - } - - const_iterator begin() const { - return const_iterator(BaseList::begin()); - } - - iterator end() { - return iterator(BaseList::end()); - } - - const_iterator end() const { - return const_iterator(BaseList::end()); - } - - const_iterator cbegin() const { - return this->begin(); - } - - const_iterator cend() const { - return this->end(); - } - - reverse_iterator rbegin() { - return reverse_iterator(this->end()); - } - - const_reverse_iterator rbegin() const { - return const_reverse_iterator(this->end()); - } - - reverse_iterator rend() { - return reverse_iterator(this->begin()); - } - - const_reverse_iterator rend() const { - return const_reverse_iterator(this->begin()); - } - - const_reverse_iterator crbegin() const { - return this->rbegin(); - } - - const_reverse_iterator crend() const { - return this->rend(); - } - - // Content management. - using BaseList::empty; - using BaseList::size; - - reference back() { - return *(--this->end()); - } - - const_reference back() const { - return *(--this->end()); - } - - reference front() { - return *this->begin(); - } - - const_reference front() const { - return *this->begin(); - } - - iterator insert(const_iterator pos, reference ref) { - KLinkedListNode* new_node = KLinkedListNode::Allocate(kernel); - ASSERT(new_node != nullptr); - new_node->Initialize(std::addressof(ref)); - return iterator(BaseList::insert(pos.m_base_it, *new_node)); - } - - void push_back(reference ref) { - this->insert(this->end(), ref); - } - - void push_front(reference ref) { - this->insert(this->begin(), ref); - } - - void pop_back() { - this->erase(--this->end()); - } - - void pop_front() { - this->erase(this->begin()); - } - - iterator erase(const iterator pos) { - KLinkedListNode* freed_node = std::addressof(*pos.m_base_it); - iterator ret = iterator(BaseList::erase(pos.m_base_it)); - KLinkedListNode::Free(kernel, freed_node); - - return ret; - } - -private: - KernelCore& kernel; -}; - -} // namespace Kernel diff --git a/src/core/hle/kernel/k_memory_block.h b/src/core/hle/kernel/k_memory_block.h index 87ca65592..e01929da6 100644 --- a/src/core/hle/kernel/k_memory_block.h +++ b/src/core/hle/kernel/k_memory_block.h @@ -471,8 +471,8 @@ public: m_disable_merge_attribute & KMemoryBlockDisableMergeAttribute::AllRight); } - constexpr void UpdateDeviceDisableMergeStateForShareLeft( - [[maybe_unused]] KMemoryPermission new_perm, bool left, [[maybe_unused]] bool right) { + constexpr void UpdateDeviceDisableMergeStateForShareLeft(KMemoryPermission new_perm, bool left, + bool right) { // New permission/right aren't used. if (left) { m_disable_merge_attribute = static_cast<KMemoryBlockDisableMergeAttribute>( @@ -482,8 +482,8 @@ public: } } - constexpr void UpdateDeviceDisableMergeStateForShareRight( - [[maybe_unused]] KMemoryPermission new_perm, [[maybe_unused]] bool left, bool right) { + constexpr void UpdateDeviceDisableMergeStateForShareRight(KMemoryPermission new_perm, bool left, + bool right) { // New permission/left aren't used. if (right) { m_disable_merge_attribute = static_cast<KMemoryBlockDisableMergeAttribute>( @@ -499,8 +499,7 @@ public: this->UpdateDeviceDisableMergeStateForShareRight(new_perm, left, right); } - constexpr void ShareToDevice([[maybe_unused]] KMemoryPermission new_perm, bool left, - bool right) { + constexpr void ShareToDevice(KMemoryPermission new_perm, bool left, bool right) { // New permission isn't used. // We must either be shared or have a zero lock count. @@ -516,8 +515,8 @@ public: this->UpdateDeviceDisableMergeStateForShare(new_perm, left, right); } - constexpr void UpdateDeviceDisableMergeStateForUnshareLeft( - [[maybe_unused]] KMemoryPermission new_perm, bool left, [[maybe_unused]] bool right) { + constexpr void UpdateDeviceDisableMergeStateForUnshareLeft(KMemoryPermission new_perm, + bool left, bool right) { // New permission/right aren't used. if (left) { @@ -536,8 +535,8 @@ public: } } - constexpr void UpdateDeviceDisableMergeStateForUnshareRight( - [[maybe_unused]] KMemoryPermission new_perm, [[maybe_unused]] bool left, bool right) { + constexpr void UpdateDeviceDisableMergeStateForUnshareRight(KMemoryPermission new_perm, + bool left, bool right) { // New permission/left aren't used. if (right) { @@ -556,8 +555,7 @@ public: this->UpdateDeviceDisableMergeStateForUnshareRight(new_perm, left, right); } - constexpr void UnshareToDevice([[maybe_unused]] KMemoryPermission new_perm, bool left, - bool right) { + constexpr void UnshareToDevice(KMemoryPermission new_perm, bool left, bool right) { // New permission isn't used. // We must be shared. @@ -575,8 +573,7 @@ public: this->UpdateDeviceDisableMergeStateForUnshare(new_perm, left, right); } - constexpr void UnshareToDeviceRight([[maybe_unused]] KMemoryPermission new_perm, bool left, - bool right) { + constexpr void UnshareToDeviceRight(KMemoryPermission new_perm, bool left, bool right) { // New permission isn't used. // We must be shared. @@ -594,7 +591,7 @@ public: this->UpdateDeviceDisableMergeStateForUnshareRight(new_perm, left, right); } - constexpr void LockForIpc(KMemoryPermission new_perm, bool left, [[maybe_unused]] bool right) { + constexpr void LockForIpc(KMemoryPermission new_perm, bool left, bool right) { // We must either be locked or have a zero lock count. ASSERT((m_attribute & KMemoryAttribute::IpcLocked) == KMemoryAttribute::IpcLocked || m_ipc_lock_count == 0); @@ -626,8 +623,7 @@ public: } } - constexpr void UnlockForIpc([[maybe_unused]] KMemoryPermission new_perm, bool left, - [[maybe_unused]] bool right) { + constexpr void UnlockForIpc(KMemoryPermission new_perm, bool left, bool right) { // New permission isn't used. // We must be locked. diff --git a/src/core/hle/kernel/k_memory_layout.cpp b/src/core/hle/kernel/k_memory_layout.cpp index 72c3ee4b7..9ff751119 100644 --- a/src/core/hle/kernel/k_memory_layout.cpp +++ b/src/core/hle/kernel/k_memory_layout.cpp @@ -18,11 +18,11 @@ KMemoryRegion* AllocateRegion(KMemoryRegionAllocator& memory_region_allocator, A } // namespace -KMemoryRegionTree::KMemoryRegionTree(KMemoryRegionAllocator& memory_region_allocator_) - : memory_region_allocator{memory_region_allocator_} {} +KMemoryRegionTree::KMemoryRegionTree(KMemoryRegionAllocator& memory_region_allocator) + : m_memory_region_allocator{memory_region_allocator} {} void KMemoryRegionTree::InsertDirectly(u64 address, u64 last_address, u32 attr, u32 type_id) { - this->insert(*AllocateRegion(memory_region_allocator, address, last_address, attr, type_id)); + this->insert(*AllocateRegion(m_memory_region_allocator, address, last_address, attr, type_id)); } bool KMemoryRegionTree::Insert(u64 address, size_t size, u32 type_id, u32 new_attr, u32 old_attr) { @@ -69,7 +69,7 @@ bool KMemoryRegionTree::Insert(u64 address, size_t size, u32 type_id, u32 new_at const u64 new_pair = (old_pair != std::numeric_limits<u64>::max()) ? old_pair + (address - old_address) : old_pair; - this->insert(*AllocateRegion(memory_region_allocator, address, inserted_region_last, + this->insert(*AllocateRegion(m_memory_region_allocator, address, inserted_region_last, new_pair, new_attr, type_id)); } @@ -78,7 +78,7 @@ bool KMemoryRegionTree::Insert(u64 address, size_t size, u32 type_id, u32 new_at const u64 after_pair = (old_pair != std::numeric_limits<u64>::max()) ? old_pair + (inserted_region_end - old_address) : old_pair; - this->insert(*AllocateRegion(memory_region_allocator, inserted_region_end, old_last, + this->insert(*AllocateRegion(m_memory_region_allocator, inserted_region_end, old_last, after_pair, old_attr, old_type)); } @@ -126,14 +126,15 @@ VAddr KMemoryRegionTree::GetRandomAlignedRegion(size_t size, size_t alignment, u } KMemoryLayout::KMemoryLayout() - : virtual_tree{memory_region_allocator}, physical_tree{memory_region_allocator}, - virtual_linear_tree{memory_region_allocator}, physical_linear_tree{memory_region_allocator} {} + : m_virtual_tree{m_memory_region_allocator}, m_physical_tree{m_memory_region_allocator}, + m_virtual_linear_tree{m_memory_region_allocator}, m_physical_linear_tree{ + m_memory_region_allocator} {} void KMemoryLayout::InitializeLinearMemoryRegionTrees(PAddr aligned_linear_phys_start, VAddr linear_virtual_start) { // Set static differences. - linear_phys_to_virt_diff = linear_virtual_start - aligned_linear_phys_start; - linear_virt_to_phys_diff = aligned_linear_phys_start - linear_virtual_start; + m_linear_phys_to_virt_diff = linear_virtual_start - aligned_linear_phys_start; + m_linear_virt_to_phys_diff = aligned_linear_phys_start - linear_virtual_start; // Initialize linear trees. for (auto& region : GetPhysicalMemoryRegionTree()) { diff --git a/src/core/hle/kernel/k_memory_layout.h b/src/core/hle/kernel/k_memory_layout.h index 17fa1a6ed..551b7a0e4 100644 --- a/src/core/hle/kernel/k_memory_layout.h +++ b/src/core/hle/kernel/k_memory_layout.h @@ -80,35 +80,35 @@ public: KMemoryLayout(); KMemoryRegionTree& GetVirtualMemoryRegionTree() { - return virtual_tree; + return m_virtual_tree; } const KMemoryRegionTree& GetVirtualMemoryRegionTree() const { - return virtual_tree; + return m_virtual_tree; } KMemoryRegionTree& GetPhysicalMemoryRegionTree() { - return physical_tree; + return m_physical_tree; } const KMemoryRegionTree& GetPhysicalMemoryRegionTree() const { - return physical_tree; + return m_physical_tree; } KMemoryRegionTree& GetVirtualLinearMemoryRegionTree() { - return virtual_linear_tree; + return m_virtual_linear_tree; } const KMemoryRegionTree& GetVirtualLinearMemoryRegionTree() const { - return virtual_linear_tree; + return m_virtual_linear_tree; } KMemoryRegionTree& GetPhysicalLinearMemoryRegionTree() { - return physical_linear_tree; + return m_physical_linear_tree; } const KMemoryRegionTree& GetPhysicalLinearMemoryRegionTree() const { - return physical_linear_tree; + return m_physical_linear_tree; } VAddr GetLinearVirtualAddress(PAddr address) const { - return address + linear_phys_to_virt_diff; + return address + m_linear_phys_to_virt_diff; } PAddr GetLinearPhysicalAddress(VAddr address) const { - return address + linear_virt_to_phys_diff; + return address + m_linear_virt_to_phys_diff; } const KMemoryRegion* FindVirtual(VAddr address) const { @@ -391,13 +391,13 @@ private: } private: - u64 linear_phys_to_virt_diff{}; - u64 linear_virt_to_phys_diff{}; - KMemoryRegionAllocator memory_region_allocator; - KMemoryRegionTree virtual_tree; - KMemoryRegionTree physical_tree; - KMemoryRegionTree virtual_linear_tree; - KMemoryRegionTree physical_linear_tree; + u64 m_linear_phys_to_virt_diff{}; + u64 m_linear_virt_to_phys_diff{}; + KMemoryRegionAllocator m_memory_region_allocator; + KMemoryRegionTree m_virtual_tree; + KMemoryRegionTree m_physical_tree; + KMemoryRegionTree m_virtual_linear_tree; + KMemoryRegionTree m_physical_linear_tree; }; namespace Init { diff --git a/src/core/hle/kernel/k_memory_region.h b/src/core/hle/kernel/k_memory_region.h index 5037e657f..cfe86fb82 100644 --- a/src/core/hle/kernel/k_memory_region.h +++ b/src/core/hle/kernel/k_memory_region.h @@ -21,15 +21,15 @@ public: YUZU_NON_MOVEABLE(KMemoryRegion); constexpr KMemoryRegion() = default; - constexpr KMemoryRegion(u64 address_, u64 last_address_) - : address{address_}, last_address{last_address_} {} - constexpr KMemoryRegion(u64 address_, u64 last_address_, u64 pair_address_, u32 attributes_, - u32 type_id_) - : address(address_), last_address(last_address_), pair_address(pair_address_), - attributes(attributes_), type_id(type_id_) {} - constexpr KMemoryRegion(u64 address_, u64 last_address_, u32 attributes_, u32 type_id_) - : KMemoryRegion(address_, last_address_, std::numeric_limits<u64>::max(), attributes_, - type_id_) {} + constexpr KMemoryRegion(u64 address, u64 last_address) + : m_address{address}, m_last_address{last_address} {} + constexpr KMemoryRegion(u64 address, u64 last_address, u64 pair_address, u32 attributes, + u32 type_id) + : m_address(address), m_last_address(last_address), m_pair_address(pair_address), + m_attributes(attributes), m_type_id(type_id) {} + constexpr KMemoryRegion(u64 address, u64 last_address, u32 attributes, u32 type_id) + : KMemoryRegion(address, last_address, std::numeric_limits<u64>::max(), attributes, + type_id) {} ~KMemoryRegion() = default; @@ -44,15 +44,15 @@ public: } constexpr u64 GetAddress() const { - return address; + return m_address; } constexpr u64 GetPairAddress() const { - return pair_address; + return m_pair_address; } constexpr u64 GetLastAddress() const { - return last_address; + return m_last_address; } constexpr u64 GetEndAddress() const { @@ -64,16 +64,16 @@ public: } constexpr u32 GetAttributes() const { - return attributes; + return m_attributes; } constexpr u32 GetType() const { - return type_id; + return m_type_id; } constexpr void SetType(u32 type) { ASSERT(this->CanDerive(type)); - type_id = type; + m_type_id = type; } constexpr bool Contains(u64 addr) const { @@ -94,27 +94,27 @@ public: } constexpr void SetPairAddress(u64 a) { - pair_address = a; + m_pair_address = a; } constexpr void SetTypeAttribute(u32 attr) { - type_id |= attr; + m_type_id |= attr; } private: constexpr void Reset(u64 a, u64 la, u64 p, u32 r, u32 t) { - address = a; - pair_address = p; - last_address = la; - attributes = r; - type_id = t; - } - - u64 address{}; - u64 last_address{}; - u64 pair_address{}; - u32 attributes{}; - u32 type_id{}; + m_address = a; + m_pair_address = p; + m_last_address = la; + m_attributes = r; + m_type_id = t; + } + + u64 m_address{}; + u64 m_last_address{}; + u64 m_pair_address{}; + u32 m_attributes{}; + u32 m_type_id{}; }; class KMemoryRegionTree final { @@ -322,7 +322,7 @@ public: private: TreeType m_tree{}; - KMemoryRegionAllocator& memory_region_allocator; + KMemoryRegionAllocator& m_memory_region_allocator; }; class KMemoryRegionAllocator final { @@ -338,18 +338,18 @@ public: template <typename... Args> KMemoryRegion* Allocate(Args&&... args) { // Ensure we stay within the bounds of our heap. - ASSERT(this->num_regions < MaxMemoryRegions); + ASSERT(m_num_regions < MaxMemoryRegions); // Create the new region. - KMemoryRegion* region = std::addressof(this->region_heap[this->num_regions++]); - new (region) KMemoryRegion(std::forward<Args>(args)...); + KMemoryRegion* region = std::addressof(m_region_heap[m_num_regions++]); + std::construct_at(region, std::forward<Args>(args)...); return region; } private: - std::array<KMemoryRegion, MaxMemoryRegions> region_heap{}; - size_t num_regions{}; + std::array<KMemoryRegion, MaxMemoryRegions> m_region_heap{}; + size_t m_num_regions{}; }; } // namespace Kernel diff --git a/src/core/hle/kernel/k_object_name.h b/src/core/hle/kernel/k_object_name.h index b7f943134..2d97fc777 100644 --- a/src/core/hle/kernel/k_object_name.h +++ b/src/core/hle/kernel/k_object_name.h @@ -41,7 +41,7 @@ public: // Check that the object is closed. R_UNLESS(derived->IsServerClosed(), ResultInvalidState); - return Delete(kernel, obj.GetPointerUnsafe(), name); + R_RETURN(Delete(kernel, obj.GetPointerUnsafe(), name)); } template <typename Derived> diff --git a/src/core/hle/kernel/k_page_buffer.h b/src/core/hle/kernel/k_page_buffer.h index cfedaae61..b7a3ccb4a 100644 --- a/src/core/hle/kernel/k_page_buffer.h +++ b/src/core/hle/kernel/k_page_buffer.h @@ -29,7 +29,7 @@ public: static KPageBuffer* FromPhysicalAddress(Core::System& system, PAddr phys_addr); private: - [[maybe_unused]] alignas(PageSize) std::array<u8, PageSize> m_buffer{}; + alignas(PageSize) std::array<u8, PageSize> m_buffer{}; }; static_assert(sizeof(KPageBuffer) == KPageBufferSlabHeap::BufferSize); diff --git a/src/core/hle/kernel/k_page_table.h b/src/core/hle/kernel/k_page_table.h index 367dab613..5c5356338 100644 --- a/src/core/hle/kernel/k_page_table.h +++ b/src/core/hle/kernel/k_page_table.h @@ -484,7 +484,7 @@ private: } PageLinkedList* GetPageList() { - return &m_ll; + return std::addressof(m_ll); } }; diff --git a/src/core/hle/kernel/k_page_table_slab_heap.h b/src/core/hle/kernel/k_page_table_slab_heap.h index a9543cbd0..9a8d77316 100644 --- a/src/core/hle/kernel/k_page_table_slab_heap.h +++ b/src/core/hle/kernel/k_page_table_slab_heap.h @@ -20,7 +20,8 @@ public: PageTablePage() = default; private: - std::array<u8, PageSize> m_buffer{}; + // Initializer intentionally skipped + std::array<u8, PageSize> m_buffer; }; static_assert(sizeof(PageTablePage) == PageSize); diff --git a/src/core/hle/kernel/k_port.cpp b/src/core/hle/kernel/k_port.cpp index 77d00ae2c..1621ca1d3 100644 --- a/src/core/hle/kernel/k_port.cpp +++ b/src/core/hle/kernel/k_port.cpp @@ -1,63 +1,61 @@ // SPDX-FileCopyrightText: Copyright 2021 yuzu Emulator Project // SPDX-License-Identifier: GPL-2.0-or-later -#include "core/hle/kernel/hle_ipc.h" #include "core/hle/kernel/k_port.h" #include "core/hle/kernel/k_scheduler.h" #include "core/hle/kernel/svc_results.h" namespace Kernel { -KPort::KPort(KernelCore& kernel_) - : KAutoObjectWithSlabHeapAndContainer{kernel_}, server{kernel_}, client{kernel_} {} +KPort::KPort(KernelCore& kernel) + : KAutoObjectWithSlabHeapAndContainer{kernel}, m_server{kernel}, m_client{kernel} {} KPort::~KPort() = default; -void KPort::Initialize(s32 max_sessions_, bool is_light_, const std::string& name_) { +void KPort::Initialize(s32 max_sessions, bool is_light, uintptr_t name) { // Open a new reference count to the initialized port. - Open(); + this->Open(); // Create and initialize our server/client pair. - KAutoObject::Create(std::addressof(server)); - KAutoObject::Create(std::addressof(client)); - server.Initialize(this, name_ + ":Server"); - client.Initialize(this, max_sessions_, name_ + ":Client"); + KAutoObject::Create(std::addressof(m_server)); + KAutoObject::Create(std::addressof(m_client)); + m_server.Initialize(this); + m_client.Initialize(this, max_sessions); // Set our member variables. - is_light = is_light_; - name = name_; - state = State::Normal; + m_is_light = is_light; + m_name = name; + m_state = State::Normal; } void KPort::OnClientClosed() { - KScopedSchedulerLock sl{kernel}; + KScopedSchedulerLock sl{m_kernel}; - if (state == State::Normal) { - state = State::ClientClosed; + if (m_state == State::Normal) { + m_state = State::ClientClosed; } } void KPort::OnServerClosed() { - KScopedSchedulerLock sl{kernel}; + KScopedSchedulerLock sl{m_kernel}; - if (state == State::Normal) { - state = State::ServerClosed; + if (m_state == State::Normal) { + m_state = State::ServerClosed; } } bool KPort::IsServerClosed() const { - KScopedSchedulerLock sl{kernel}; - return state == State::ServerClosed; + KScopedSchedulerLock sl{m_kernel}; + return m_state == State::ServerClosed; } Result KPort::EnqueueSession(KServerSession* session) { - KScopedSchedulerLock sl{kernel}; + KScopedSchedulerLock sl{m_kernel}; - R_UNLESS(state == State::Normal, ResultPortClosed); + R_UNLESS(m_state == State::Normal, ResultPortClosed); - server.EnqueueSession(session); - - return ResultSuccess; + m_server.EnqueueSession(session); + R_SUCCEED(); } } // namespace Kernel diff --git a/src/core/hle/kernel/k_port.h b/src/core/hle/kernel/k_port.h index 0cfc16dab..991be27ab 100644 --- a/src/core/hle/kernel/k_port.h +++ b/src/core/hle/kernel/k_port.h @@ -19,17 +19,20 @@ class KPort final : public KAutoObjectWithSlabHeapAndContainer<KPort, KAutoObjec KERNEL_AUTOOBJECT_TRAITS(KPort, KAutoObject); public: - explicit KPort(KernelCore& kernel_); + explicit KPort(KernelCore& kernel); ~KPort() override; - static void PostDestroy([[maybe_unused]] uintptr_t arg) {} + static void PostDestroy(uintptr_t arg) {} - void Initialize(s32 max_sessions_, bool is_light_, const std::string& name_); + void Initialize(s32 max_sessions, bool is_light, uintptr_t name); void OnClientClosed(); void OnServerClosed(); + uintptr_t GetName() const { + return m_name; + } bool IsLight() const { - return is_light; + return m_is_light; } bool IsServerClosed() const; @@ -37,16 +40,16 @@ public: Result EnqueueSession(KServerSession* session); KClientPort& GetClientPort() { - return client; + return m_client; } KServerPort& GetServerPort() { - return server; + return m_server; } const KClientPort& GetClientPort() const { - return client; + return m_client; } const KServerPort& GetServerPort() const { - return server; + return m_server; } private: @@ -57,10 +60,11 @@ private: ServerClosed = 3, }; - KServerPort server; - KClientPort client; - State state{State::Invalid}; - bool is_light{}; + KServerPort m_server; + KClientPort m_client; + uintptr_t m_name; + State m_state{State::Invalid}; + bool m_is_light{}; }; } // namespace Kernel diff --git a/src/core/hle/kernel/k_priority_queue.h b/src/core/hle/kernel/k_priority_queue.h index 645c5b531..26677ec65 100644 --- a/src/core/hle/kernel/k_priority_queue.h +++ b/src/core/hle/kernel/k_priority_queue.h @@ -77,11 +77,11 @@ private: public: class KPerCoreQueue { private: - std::array<Entry, NumCores> root{}; + std::array<Entry, NumCores> m_root{}; public: constexpr KPerCoreQueue() { - for (auto& per_core_root : root) { + for (auto& per_core_root : m_root) { per_core_root.Initialize(); } } @@ -91,15 +91,15 @@ public: Entry& member_entry = member->GetPriorityQueueEntry(core); // Get the entry associated with the end of the queue. - Member* tail = this->root[core].GetPrev(); + Member* tail = m_root[core].GetPrev(); Entry& tail_entry = - (tail != nullptr) ? tail->GetPriorityQueueEntry(core) : this->root[core]; + (tail != nullptr) ? tail->GetPriorityQueueEntry(core) : m_root[core]; // Link the entries. member_entry.SetPrev(tail); member_entry.SetNext(nullptr); tail_entry.SetNext(member); - this->root[core].SetPrev(member); + m_root[core].SetPrev(member); return tail == nullptr; } @@ -109,15 +109,15 @@ public: Entry& member_entry = member->GetPriorityQueueEntry(core); // Get the entry associated with the front of the queue. - Member* head = this->root[core].GetNext(); + Member* head = m_root[core].GetNext(); Entry& head_entry = - (head != nullptr) ? head->GetPriorityQueueEntry(core) : this->root[core]; + (head != nullptr) ? head->GetPriorityQueueEntry(core) : m_root[core]; // Link the entries. member_entry.SetPrev(nullptr); member_entry.SetNext(head); head_entry.SetPrev(member); - this->root[core].SetNext(member); + m_root[core].SetNext(member); return (head == nullptr); } @@ -130,9 +130,9 @@ public: Member* prev = member_entry.GetPrev(); Member* next = member_entry.GetNext(); Entry& prev_entry = - (prev != nullptr) ? prev->GetPriorityQueueEntry(core) : this->root[core]; + (prev != nullptr) ? prev->GetPriorityQueueEntry(core) : m_root[core]; Entry& next_entry = - (next != nullptr) ? next->GetPriorityQueueEntry(core) : this->root[core]; + (next != nullptr) ? next->GetPriorityQueueEntry(core) : m_root[core]; // Unlink. prev_entry.SetNext(next); @@ -142,7 +142,7 @@ public: } constexpr Member* GetFront(s32 core) const { - return this->root[core].GetNext(); + return m_root[core].GetNext(); } }; @@ -158,8 +158,8 @@ public: return; } - if (this->queues[priority].PushBack(core, member)) { - this->available_priorities[core].SetBit(priority); + if (m_queues[priority].PushBack(core, member)) { + m_available_priorities[core].SetBit(priority); } } @@ -171,8 +171,8 @@ public: return; } - if (this->queues[priority].PushFront(core, member)) { - this->available_priorities[core].SetBit(priority); + if (m_queues[priority].PushFront(core, member)) { + m_available_priorities[core].SetBit(priority); } } @@ -184,18 +184,17 @@ public: return; } - if (this->queues[priority].Remove(core, member)) { - this->available_priorities[core].ClearBit(priority); + if (m_queues[priority].Remove(core, member)) { + m_available_priorities[core].ClearBit(priority); } } constexpr Member* GetFront(s32 core) const { ASSERT(IsValidCore(core)); - const s32 priority = - static_cast<s32>(this->available_priorities[core].CountLeadingZero()); + const s32 priority = static_cast<s32>(m_available_priorities[core].CountLeadingZero()); if (priority <= LowestPriority) { - return this->queues[priority].GetFront(core); + return m_queues[priority].GetFront(core); } else { return nullptr; } @@ -206,7 +205,7 @@ public: ASSERT(IsValidPriority(priority)); if (priority <= LowestPriority) { - return this->queues[priority].GetFront(core); + return m_queues[priority].GetFront(core); } else { return nullptr; } @@ -218,9 +217,9 @@ public: Member* next = member->GetPriorityQueueEntry(core).GetNext(); if (next == nullptr) { const s32 priority = static_cast<s32>( - this->available_priorities[core].GetNextSet(member->GetPriority())); + m_available_priorities[core].GetNextSet(member->GetPriority())); if (priority <= LowestPriority) { - next = this->queues[priority].GetFront(core); + next = m_queues[priority].GetFront(core); } } return next; @@ -231,8 +230,8 @@ public: ASSERT(IsValidPriority(priority)); if (priority <= LowestPriority) { - this->queues[priority].Remove(core, member); - this->queues[priority].PushFront(core, member); + m_queues[priority].Remove(core, member); + m_queues[priority].PushFront(core, member); } } @@ -241,29 +240,29 @@ public: ASSERT(IsValidPriority(priority)); if (priority <= LowestPriority) { - this->queues[priority].Remove(core, member); - this->queues[priority].PushBack(core, member); - return this->queues[priority].GetFront(core); + m_queues[priority].Remove(core, member); + m_queues[priority].PushBack(core, member); + return m_queues[priority].GetFront(core); } else { return nullptr; } } private: - std::array<KPerCoreQueue, NumPriority> queues{}; - std::array<Common::BitSet64<NumPriority>, NumCores> available_priorities{}; + std::array<KPerCoreQueue, NumPriority> m_queues{}; + std::array<Common::BitSet64<NumPriority>, NumCores> m_available_priorities{}; }; private: - KPriorityQueueImpl scheduled_queue; - KPriorityQueueImpl suggested_queue; + KPriorityQueueImpl m_scheduled_queue; + KPriorityQueueImpl m_suggested_queue; private: - constexpr void ClearAffinityBit(u64& affinity, s32 core) { + static constexpr void ClearAffinityBit(u64& affinity, s32 core) { affinity &= ~(UINT64_C(1) << core); } - constexpr s32 GetNextCore(u64& affinity) { + static constexpr s32 GetNextCore(u64& affinity) { const s32 core = std::countr_zero(affinity); ClearAffinityBit(affinity, core); return core; @@ -275,13 +274,13 @@ private: // Push onto the scheduled queue for its core, if we can. u64 affinity = member->GetAffinityMask().GetAffinityMask(); if (const s32 core = member->GetActiveCore(); core >= 0) { - this->scheduled_queue.PushBack(priority, core, member); + m_scheduled_queue.PushBack(priority, core, member); ClearAffinityBit(affinity, core); } // And suggest the thread for all other cores. while (affinity) { - this->suggested_queue.PushBack(priority, GetNextCore(affinity), member); + m_suggested_queue.PushBack(priority, GetNextCore(affinity), member); } } @@ -291,14 +290,14 @@ private: // Push onto the scheduled queue for its core, if we can. u64 affinity = member->GetAffinityMask().GetAffinityMask(); if (const s32 core = member->GetActiveCore(); core >= 0) { - this->scheduled_queue.PushFront(priority, core, member); + m_scheduled_queue.PushFront(priority, core, member); ClearAffinityBit(affinity, core); } // And suggest the thread for all other cores. // Note: Nintendo pushes onto the back of the suggested queue, not the front. while (affinity) { - this->suggested_queue.PushBack(priority, GetNextCore(affinity), member); + m_suggested_queue.PushBack(priority, GetNextCore(affinity), member); } } @@ -308,13 +307,13 @@ private: // Remove from the scheduled queue for its core. u64 affinity = member->GetAffinityMask().GetAffinityMask(); if (const s32 core = member->GetActiveCore(); core >= 0) { - this->scheduled_queue.Remove(priority, core, member); + m_scheduled_queue.Remove(priority, core, member); ClearAffinityBit(affinity, core); } // Remove from the suggested queue for all other cores. while (affinity) { - this->suggested_queue.Remove(priority, GetNextCore(affinity), member); + m_suggested_queue.Remove(priority, GetNextCore(affinity), member); } } @@ -323,27 +322,27 @@ public: // Getters. constexpr Member* GetScheduledFront(s32 core) const { - return this->scheduled_queue.GetFront(core); + return m_scheduled_queue.GetFront(core); } constexpr Member* GetScheduledFront(s32 core, s32 priority) const { - return this->scheduled_queue.GetFront(priority, core); + return m_scheduled_queue.GetFront(priority, core); } constexpr Member* GetSuggestedFront(s32 core) const { - return this->suggested_queue.GetFront(core); + return m_suggested_queue.GetFront(core); } constexpr Member* GetSuggestedFront(s32 core, s32 priority) const { - return this->suggested_queue.GetFront(priority, core); + return m_suggested_queue.GetFront(priority, core); } constexpr Member* GetScheduledNext(s32 core, const Member* member) const { - return this->scheduled_queue.GetNext(core, member); + return m_scheduled_queue.GetNext(core, member); } constexpr Member* GetSuggestedNext(s32 core, const Member* member) const { - return this->suggested_queue.GetNext(core, member); + return m_suggested_queue.GetNext(core, member); } constexpr Member* GetSamePriorityNext(s32 core, const Member* member) const { @@ -375,7 +374,7 @@ public: return; } - this->scheduled_queue.MoveToFront(member->GetPriority(), member->GetActiveCore(), member); + m_scheduled_queue.MoveToFront(member->GetPriority(), member->GetActiveCore(), member); } constexpr KThread* MoveToScheduledBack(Member* member) { @@ -384,8 +383,7 @@ public: return {}; } - return this->scheduled_queue.MoveToBack(member->GetPriority(), member->GetActiveCore(), - member); + return m_scheduled_queue.MoveToBack(member->GetPriority(), member->GetActiveCore(), member); } // First class fancy operations. @@ -425,9 +423,9 @@ public: for (s32 core = 0; core < static_cast<s32>(NumCores); core++) { if (prev_affinity.GetAffinity(core)) { if (core == prev_core) { - this->scheduled_queue.Remove(priority, core, member); + m_scheduled_queue.Remove(priority, core, member); } else { - this->suggested_queue.Remove(priority, core, member); + m_suggested_queue.Remove(priority, core, member); } } } @@ -436,9 +434,9 @@ public: for (s32 core = 0; core < static_cast<s32>(NumCores); core++) { if (new_affinity.GetAffinity(core)) { if (core == new_core) { - this->scheduled_queue.PushBack(priority, core, member); + m_scheduled_queue.PushBack(priority, core, member); } else { - this->suggested_queue.PushBack(priority, core, member); + m_suggested_queue.PushBack(priority, core, member); } } } @@ -458,22 +456,22 @@ public: if (prev_core != new_core) { // Remove from the scheduled queue for the previous core. if (prev_core >= 0) { - this->scheduled_queue.Remove(priority, prev_core, member); + m_scheduled_queue.Remove(priority, prev_core, member); } // Remove from the suggested queue and add to the scheduled queue for the new core. if (new_core >= 0) { - this->suggested_queue.Remove(priority, new_core, member); + m_suggested_queue.Remove(priority, new_core, member); if (to_front) { - this->scheduled_queue.PushFront(priority, new_core, member); + m_scheduled_queue.PushFront(priority, new_core, member); } else { - this->scheduled_queue.PushBack(priority, new_core, member); + m_scheduled_queue.PushBack(priority, new_core, member); } } // Add to the suggested queue for the previous core. if (prev_core >= 0) { - this->suggested_queue.PushBack(priority, prev_core, member); + m_suggested_queue.PushBack(priority, prev_core, member); } } } diff --git a/src/core/hle/kernel/k_process.cpp b/src/core/hle/kernel/k_process.cpp index d44f6e921..9d18f4049 100644 --- a/src/core/hle/kernel/k_process.cpp +++ b/src/core/hle/kernel/k_process.cpp @@ -44,14 +44,14 @@ void SetupMainThread(Core::System& system, KProcess& owner_process, u32 priority SCOPE_EXIT({ thread->Close(); }); ASSERT(KThread::InitializeUserThread(system, thread, entry_point, 0, stack_top, priority, - owner_process.GetIdealCoreId(), &owner_process) + owner_process.GetIdealCoreId(), + std::addressof(owner_process)) .IsSuccess()); // Register 1 must be a handle to the main thread Handle thread_handle{}; - owner_process.GetHandleTable().Add(&thread_handle, thread); + owner_process.GetHandleTable().Add(std::addressof(thread_handle), thread); - thread->SetName("main"); thread->GetContext32().cpu_registers[0] = 0; thread->GetContext64().cpu_registers[0] = 0; thread->GetContext32().cpu_registers[1] = thread_handle; @@ -71,32 +71,32 @@ Result KProcess::Initialize(KProcess* process, Core::System& system, std::string auto& kernel = system.Kernel(); process->name = std::move(process_name); - process->resource_limit = res_limit; - process->system_resource_address = 0; - process->state = State::Created; - process->program_id = 0; - process->process_id = type == ProcessType::KernelInternal ? kernel.CreateNewKernelProcessID() - : kernel.CreateNewUserProcessID(); - process->capabilities.InitializeForMetadatalessProcess(); - process->is_initialized = true; + process->m_resource_limit = res_limit; + process->m_system_resource_address = 0; + process->m_state = State::Created; + process->m_program_id = 0; + process->m_process_id = type == ProcessType::KernelInternal ? kernel.CreateNewKernelProcessID() + : kernel.CreateNewUserProcessID(); + process->m_capabilities.InitializeForMetadatalessProcess(); + process->m_is_initialized = true; std::mt19937 rng(Settings::values.rng_seed.GetValue().value_or(std::time(nullptr))); std::uniform_int_distribution<u64> distribution; - std::generate(process->random_entropy.begin(), process->random_entropy.end(), + std::generate(process->m_random_entropy.begin(), process->m_random_entropy.end(), [&] { return distribution(rng); }); kernel.AppendNewProcess(process); // Clear remaining fields. - process->num_running_threads = 0; - process->is_signaled = false; - process->exception_thread = nullptr; - process->is_suspended = false; - process->schedule_count = 0; - process->is_handle_table_initialized = false; + process->m_num_running_threads = 0; + process->m_is_signaled = false; + process->m_exception_thread = nullptr; + process->m_is_suspended = false; + process->m_schedule_count = 0; + process->m_is_handle_table_initialized = false; // Open a reference to the resource limit. - process->resource_limit->Open(); + process->m_resource_limit->Open(); R_SUCCEED(); } @@ -106,65 +106,65 @@ void KProcess::DoWorkerTaskImpl() { } KResourceLimit* KProcess::GetResourceLimit() const { - return resource_limit; + return m_resource_limit; } void KProcess::IncrementRunningThreadCount() { - ASSERT(num_running_threads.load() >= 0); - ++num_running_threads; + ASSERT(m_num_running_threads.load() >= 0); + ++m_num_running_threads; } void KProcess::DecrementRunningThreadCount() { - ASSERT(num_running_threads.load() > 0); + ASSERT(m_num_running_threads.load() > 0); - if (const auto prev = num_running_threads--; prev == 1) { + if (const auto prev = m_num_running_threads--; prev == 1) { // TODO(bunnei): Process termination to be implemented when multiprocess is supported. } } u64 KProcess::GetTotalPhysicalMemoryAvailable() { - const u64 capacity{resource_limit->GetFreeValue(LimitableResource::PhysicalMemoryMax) + - page_table.GetNormalMemorySize() + GetSystemResourceSize() + image_size + - main_thread_stack_size}; - if (const auto pool_size = kernel.MemoryManager().GetSize(KMemoryManager::Pool::Application); + const u64 capacity{m_resource_limit->GetFreeValue(LimitableResource::PhysicalMemoryMax) + + m_page_table.GetNormalMemorySize() + GetSystemResourceSize() + m_image_size + + m_main_thread_stack_size}; + if (const auto pool_size = m_kernel.MemoryManager().GetSize(KMemoryManager::Pool::Application); capacity != pool_size) { LOG_WARNING(Kernel, "capacity {} != application pool size {}", capacity, pool_size); } - if (capacity < memory_usage_capacity) { + if (capacity < m_memory_usage_capacity) { return capacity; } - return memory_usage_capacity; + return m_memory_usage_capacity; } u64 KProcess::GetTotalPhysicalMemoryAvailableWithoutSystemResource() { - return GetTotalPhysicalMemoryAvailable() - GetSystemResourceSize(); + return this->GetTotalPhysicalMemoryAvailable() - this->GetSystemResourceSize(); } u64 KProcess::GetTotalPhysicalMemoryUsed() { - return image_size + main_thread_stack_size + page_table.GetNormalMemorySize() + - GetSystemResourceSize(); + return m_image_size + m_main_thread_stack_size + m_page_table.GetNormalMemorySize() + + this->GetSystemResourceSize(); } u64 KProcess::GetTotalPhysicalMemoryUsedWithoutSystemResource() { - return GetTotalPhysicalMemoryUsed() - GetSystemResourceUsage(); + return this->GetTotalPhysicalMemoryUsed() - this->GetSystemResourceUsage(); } bool KProcess::ReleaseUserException(KThread* thread) { - KScopedSchedulerLock sl{kernel}; + KScopedSchedulerLock sl{m_kernel}; - if (exception_thread == thread) { - exception_thread = nullptr; + if (m_exception_thread == thread) { + m_exception_thread = nullptr; // Remove waiter thread. bool has_waiters{}; if (KThread* next = thread->RemoveKernelWaiterByKey( std::addressof(has_waiters), - reinterpret_cast<uintptr_t>(std::addressof(exception_thread))); + reinterpret_cast<uintptr_t>(std::addressof(m_exception_thread))); next != nullptr) { next->EndWait(ResultSuccess); } - KScheduler::SetSchedulerUpdateNeeded(kernel); + KScheduler::SetSchedulerUpdateNeeded(m_kernel); return true; } else { @@ -173,72 +173,72 @@ bool KProcess::ReleaseUserException(KThread* thread) { } void KProcess::PinCurrentThread(s32 core_id) { - ASSERT(kernel.GlobalSchedulerContext().IsLocked()); + ASSERT(KScheduler::IsSchedulerLockedByCurrentThread(m_kernel)); // Get the current thread. KThread* cur_thread = - kernel.Scheduler(static_cast<std::size_t>(core_id)).GetSchedulerCurrentThread(); + m_kernel.Scheduler(static_cast<std::size_t>(core_id)).GetSchedulerCurrentThread(); // If the thread isn't terminated, pin it. if (!cur_thread->IsTerminationRequested()) { // Pin it. - PinThread(core_id, cur_thread); + this->PinThread(core_id, cur_thread); cur_thread->Pin(core_id); // An update is needed. - KScheduler::SetSchedulerUpdateNeeded(kernel); + KScheduler::SetSchedulerUpdateNeeded(m_kernel); } } void KProcess::UnpinCurrentThread(s32 core_id) { - ASSERT(kernel.GlobalSchedulerContext().IsLocked()); + ASSERT(KScheduler::IsSchedulerLockedByCurrentThread(m_kernel)); // Get the current thread. KThread* cur_thread = - kernel.Scheduler(static_cast<std::size_t>(core_id)).GetSchedulerCurrentThread(); + m_kernel.Scheduler(static_cast<std::size_t>(core_id)).GetSchedulerCurrentThread(); // Unpin it. cur_thread->Unpin(); - UnpinThread(core_id, cur_thread); + this->UnpinThread(core_id, cur_thread); // An update is needed. - KScheduler::SetSchedulerUpdateNeeded(kernel); + KScheduler::SetSchedulerUpdateNeeded(m_kernel); } void KProcess::UnpinThread(KThread* thread) { - ASSERT(kernel.GlobalSchedulerContext().IsLocked()); + ASSERT(KScheduler::IsSchedulerLockedByCurrentThread(m_kernel)); // Get the thread's core id. const auto core_id = thread->GetActiveCore(); // Unpin it. - UnpinThread(core_id, thread); + this->UnpinThread(core_id, thread); thread->Unpin(); // An update is needed. - KScheduler::SetSchedulerUpdateNeeded(kernel); + KScheduler::SetSchedulerUpdateNeeded(m_kernel); } Result KProcess::AddSharedMemory(KSharedMemory* shmem, [[maybe_unused]] VAddr address, [[maybe_unused]] size_t size) { // Lock ourselves, to prevent concurrent access. - KScopedLightLock lk(state_lock); + KScopedLightLock lk(m_state_lock); // Try to find an existing info for the memory. KSharedMemoryInfo* shemen_info = nullptr; const auto iter = std::find_if( - shared_memory_list.begin(), shared_memory_list.end(), + m_shared_memory_list.begin(), m_shared_memory_list.end(), [shmem](const KSharedMemoryInfo* info) { return info->GetSharedMemory() == shmem; }); - if (iter != shared_memory_list.end()) { + if (iter != m_shared_memory_list.end()) { shemen_info = *iter; } if (shemen_info == nullptr) { - shemen_info = KSharedMemoryInfo::Allocate(kernel); + shemen_info = KSharedMemoryInfo::Allocate(m_kernel); R_UNLESS(shemen_info != nullptr, ResultOutOfMemory); shemen_info->Initialize(shmem); - shared_memory_list.push_back(shemen_info); + m_shared_memory_list.push_back(shemen_info); } // Open a reference to the shared memory and its info. @@ -251,21 +251,21 @@ Result KProcess::AddSharedMemory(KSharedMemory* shmem, [[maybe_unused]] VAddr ad void KProcess::RemoveSharedMemory(KSharedMemory* shmem, [[maybe_unused]] VAddr address, [[maybe_unused]] size_t size) { // Lock ourselves, to prevent concurrent access. - KScopedLightLock lk(state_lock); + KScopedLightLock lk(m_state_lock); KSharedMemoryInfo* shemen_info = nullptr; const auto iter = std::find_if( - shared_memory_list.begin(), shared_memory_list.end(), + m_shared_memory_list.begin(), m_shared_memory_list.end(), [shmem](const KSharedMemoryInfo* info) { return info->GetSharedMemory() == shmem; }); - if (iter != shared_memory_list.end()) { + if (iter != m_shared_memory_list.end()) { shemen_info = *iter; } ASSERT(shemen_info != nullptr); if (shemen_info->Close()) { - shared_memory_list.erase(iter); - KSharedMemoryInfo::Free(kernel, shemen_info); + m_shared_memory_list.erase(iter); + KSharedMemoryInfo::Free(m_kernel, shemen_info); } // Close a reference to the shared memory. @@ -273,22 +273,22 @@ void KProcess::RemoveSharedMemory(KSharedMemory* shmem, [[maybe_unused]] VAddr a } void KProcess::RegisterThread(KThread* thread) { - KScopedLightLock lk{list_lock}; + KScopedLightLock lk{m_list_lock}; - thread_list.push_back(thread); + m_thread_list.push_back(thread); } void KProcess::UnregisterThread(KThread* thread) { - KScopedLightLock lk{list_lock}; + KScopedLightLock lk{m_list_lock}; - thread_list.remove(thread); + m_thread_list.remove(thread); } u64 KProcess::GetFreeThreadCount() const { - if (resource_limit != nullptr) { + if (m_resource_limit != nullptr) { const auto current_value = - resource_limit->GetCurrentValue(LimitableResource::ThreadCountMax); - const auto limit_value = resource_limit->GetLimitValue(LimitableResource::ThreadCountMax); + m_resource_limit->GetCurrentValue(LimitableResource::ThreadCountMax); + const auto limit_value = m_resource_limit->GetLimitValue(LimitableResource::ThreadCountMax); return limit_value - current_value; } else { return 0; @@ -297,84 +297,85 @@ u64 KProcess::GetFreeThreadCount() const { Result KProcess::Reset() { // Lock the process and the scheduler. - KScopedLightLock lk(state_lock); - KScopedSchedulerLock sl{kernel}; + KScopedLightLock lk(m_state_lock); + KScopedSchedulerLock sl{m_kernel}; // Validate that we're in a state that we can reset. - R_UNLESS(state != State::Terminated, ResultInvalidState); - R_UNLESS(is_signaled, ResultInvalidState); + R_UNLESS(m_state != State::Terminated, ResultInvalidState); + R_UNLESS(m_is_signaled, ResultInvalidState); // Clear signaled. - is_signaled = false; + m_is_signaled = false; R_SUCCEED(); } Result KProcess::SetActivity(ProcessActivity activity) { // Lock ourselves and the scheduler. - KScopedLightLock lk{state_lock}; - KScopedLightLock list_lk{list_lock}; - KScopedSchedulerLock sl{kernel}; + KScopedLightLock lk{m_state_lock}; + KScopedLightLock list_lk{m_list_lock}; + KScopedSchedulerLock sl{m_kernel}; // Validate our state. - R_UNLESS(state != State::Terminating, ResultInvalidState); - R_UNLESS(state != State::Terminated, ResultInvalidState); + R_UNLESS(m_state != State::Terminating, ResultInvalidState); + R_UNLESS(m_state != State::Terminated, ResultInvalidState); // Either pause or resume. if (activity == ProcessActivity::Paused) { // Verify that we're not suspended. - R_UNLESS(!is_suspended, ResultInvalidState); + R_UNLESS(!m_is_suspended, ResultInvalidState); // Suspend all threads. - for (auto* thread : GetThreadList()) { + for (auto* thread : this->GetThreadList()) { thread->RequestSuspend(SuspendType::Process); } // Set ourselves as suspended. - SetSuspended(true); + this->SetSuspended(true); } else { ASSERT(activity == ProcessActivity::Runnable); // Verify that we're suspended. - R_UNLESS(is_suspended, ResultInvalidState); + R_UNLESS(m_is_suspended, ResultInvalidState); // Resume all threads. - for (auto* thread : GetThreadList()) { + for (auto* thread : this->GetThreadList()) { thread->Resume(SuspendType::Process); } // Set ourselves as resumed. - SetSuspended(false); + this->SetSuspended(false); } R_SUCCEED(); } Result KProcess::LoadFromMetadata(const FileSys::ProgramMetadata& metadata, std::size_t code_size) { - program_id = metadata.GetTitleID(); - ideal_core = metadata.GetMainThreadCore(); - is_64bit_process = metadata.Is64BitProgram(); - system_resource_size = metadata.GetSystemResourceSize(); - image_size = code_size; + m_program_id = metadata.GetTitleID(); + m_ideal_core = metadata.GetMainThreadCore(); + m_is_64bit_process = metadata.Is64BitProgram(); + m_system_resource_size = metadata.GetSystemResourceSize(); + m_image_size = code_size; KScopedResourceReservation memory_reservation( - resource_limit, LimitableResource::PhysicalMemoryMax, code_size + system_resource_size); + m_resource_limit, LimitableResource::PhysicalMemoryMax, code_size + m_system_resource_size); if (!memory_reservation.Succeeded()) { LOG_ERROR(Kernel, "Could not reserve process memory requirements of size {:X} bytes", - code_size + system_resource_size); + code_size + m_system_resource_size); R_RETURN(ResultLimitReached); } - // Initialize proces address space - if (const Result result{page_table.InitializeForProcess( + // Initialize process address space + if (const Result result{m_page_table.InitializeForProcess( metadata.GetAddressSpaceType(), false, false, false, KMemoryManager::Pool::Application, - 0x8000000, code_size, &kernel.GetAppSystemResource(), resource_limit)}; + 0x8000000, code_size, std::addressof(m_kernel.GetAppSystemResource()), + m_resource_limit)}; result.IsError()) { R_RETURN(result); } // Map process code region - if (const Result result{page_table.MapProcessCode(page_table.GetCodeRegionStart(), - code_size / PageSize, KMemoryState::Code, - KMemoryPermission::None)}; + if (const Result result{m_page_table.MapProcessCode(m_page_table.GetCodeRegionStart(), + code_size / PageSize, KMemoryState::Code, + KMemoryPermission::None)}; result.IsError()) { R_RETURN(result); } @@ -382,7 +383,7 @@ Result KProcess::LoadFromMetadata(const FileSys::ProgramMetadata& metadata, std: // Initialize process capabilities const auto& caps{metadata.GetKernelCapabilities()}; if (const Result result{ - capabilities.InitializeForUserProcess(caps.data(), caps.size(), page_table)}; + m_capabilities.InitializeForUserProcess(caps.data(), caps.size(), m_page_table)}; result.IsError()) { R_RETURN(result); } @@ -392,12 +393,14 @@ Result KProcess::LoadFromMetadata(const FileSys::ProgramMetadata& metadata, std: case FileSys::ProgramAddressSpaceType::Is32Bit: case FileSys::ProgramAddressSpaceType::Is36Bit: case FileSys::ProgramAddressSpaceType::Is39Bit: - memory_usage_capacity = page_table.GetHeapRegionEnd() - page_table.GetHeapRegionStart(); + m_memory_usage_capacity = + m_page_table.GetHeapRegionEnd() - m_page_table.GetHeapRegionStart(); break; case FileSys::ProgramAddressSpaceType::Is32BitNoMap: - memory_usage_capacity = page_table.GetHeapRegionEnd() - page_table.GetHeapRegionStart() + - page_table.GetAliasRegionEnd() - page_table.GetAliasRegionStart(); + m_memory_usage_capacity = + m_page_table.GetHeapRegionEnd() - m_page_table.GetHeapRegionStart() + + m_page_table.GetAliasRegionEnd() - m_page_table.GetAliasRegionStart(); break; default: @@ -406,33 +409,34 @@ Result KProcess::LoadFromMetadata(const FileSys::ProgramMetadata& metadata, std: } // Create TLS region - R_TRY(this->CreateThreadLocalRegion(std::addressof(plr_address))); + R_TRY(this->CreateThreadLocalRegion(std::addressof(m_plr_address))); memory_reservation.Commit(); - R_RETURN(handle_table.Initialize(capabilities.GetHandleTableSize())); + R_RETURN(m_handle_table.Initialize(m_capabilities.GetHandleTableSize())); } void KProcess::Run(s32 main_thread_priority, u64 stack_size) { - ASSERT(AllocateMainThreadStack(stack_size) == ResultSuccess); - resource_limit->Reserve(LimitableResource::ThreadCountMax, 1); + ASSERT(this->AllocateMainThreadStack(stack_size) == ResultSuccess); + m_resource_limit->Reserve(LimitableResource::ThreadCountMax, 1); - const std::size_t heap_capacity{memory_usage_capacity - (main_thread_stack_size + image_size)}; - ASSERT(!page_table.SetMaxHeapSize(heap_capacity).IsError()); + const std::size_t heap_capacity{m_memory_usage_capacity - + (m_main_thread_stack_size + m_image_size)}; + ASSERT(!m_page_table.SetMaxHeapSize(heap_capacity).IsError()); - ChangeState(State::Running); + this->ChangeState(State::Running); - SetupMainThread(kernel.System(), *this, main_thread_priority, main_thread_stack_top); + SetupMainThread(m_kernel.System(), *this, main_thread_priority, m_main_thread_stack_top); } void KProcess::PrepareForTermination() { - ChangeState(State::Terminating); + this->ChangeState(State::Terminating); const auto stop_threads = [this](const std::vector<KThread*>& in_thread_list) { for (auto* thread : in_thread_list) { if (thread->GetOwnerProcess() != this) continue; - if (thread == GetCurrentThreadPointer(kernel)) + if (thread == GetCurrentThreadPointer(m_kernel)) continue; // TODO(Subv): When are the other running/ready threads terminated? @@ -443,24 +447,24 @@ void KProcess::PrepareForTermination() { } }; - stop_threads(kernel.System().GlobalSchedulerContext().GetThreadList()); + stop_threads(m_kernel.System().GlobalSchedulerContext().GetThreadList()); - this->DeleteThreadLocalRegion(plr_address); - plr_address = 0; + this->DeleteThreadLocalRegion(m_plr_address); + m_plr_address = 0; - if (resource_limit) { - resource_limit->Release(LimitableResource::PhysicalMemoryMax, - main_thread_stack_size + image_size); + if (m_resource_limit) { + m_resource_limit->Release(LimitableResource::PhysicalMemoryMax, + m_main_thread_stack_size + m_image_size); } - ChangeState(State::Terminated); + this->ChangeState(State::Terminated); } void KProcess::Finalize() { // Free all shared memory infos. { - auto it = shared_memory_list.begin(); - while (it != shared_memory_list.end()) { + auto it = m_shared_memory_list.begin(); + while (it != m_shared_memory_list.end()) { KSharedMemoryInfo* info = *it; KSharedMemory* shmem = info->GetSharedMemory(); @@ -470,22 +474,22 @@ void KProcess::Finalize() { shmem->Close(); - it = shared_memory_list.erase(it); - KSharedMemoryInfo::Free(kernel, info); + it = m_shared_memory_list.erase(it); + KSharedMemoryInfo::Free(m_kernel, info); } } // Release memory to the resource limit. - if (resource_limit != nullptr) { - resource_limit->Close(); - resource_limit = nullptr; + if (m_resource_limit != nullptr) { + m_resource_limit->Close(); + m_resource_limit = nullptr; } // Finalize the page table. - page_table.Finalize(); + m_page_table.Finalize(); // Perform inherited finalization. - KAutoObjectWithSlabHeapAndContainer<KProcess, KWorkerTask>::Finalize(); + KSynchronizationObject::Finalize(); } Result KProcess::CreateThreadLocalRegion(VAddr* out) { @@ -494,16 +498,16 @@ Result KProcess::CreateThreadLocalRegion(VAddr* out) { // See if we can get a region from a partially used TLP. { - KScopedSchedulerLock sl{kernel}; + KScopedSchedulerLock sl{m_kernel}; - if (auto it = partially_used_tlp_tree.begin(); it != partially_used_tlp_tree.end()) { + if (auto it = m_partially_used_tlp_tree.begin(); it != m_partially_used_tlp_tree.end()) { tlr = it->Reserve(); ASSERT(tlr != 0); if (it->IsAllUsed()) { tlp = std::addressof(*it); - partially_used_tlp_tree.erase(it); - fully_used_tlp_tree.insert(*tlp); + m_partially_used_tlp_tree.erase(it); + m_fully_used_tlp_tree.insert(*tlp); } *out = tlr; @@ -512,12 +516,12 @@ Result KProcess::CreateThreadLocalRegion(VAddr* out) { } // Allocate a new page. - tlp = KThreadLocalPage::Allocate(kernel); + tlp = KThreadLocalPage::Allocate(m_kernel); R_UNLESS(tlp != nullptr, ResultOutOfMemory); - auto tlp_guard = SCOPE_GUARD({ KThreadLocalPage::Free(kernel, tlp); }); + auto tlp_guard = SCOPE_GUARD({ KThreadLocalPage::Free(m_kernel, tlp); }); // Initialize the new page. - R_TRY(tlp->Initialize(kernel, this)); + R_TRY(tlp->Initialize(m_kernel, this)); // Reserve a TLR. tlr = tlp->Reserve(); @@ -525,11 +529,11 @@ Result KProcess::CreateThreadLocalRegion(VAddr* out) { // Insert into our tree. { - KScopedSchedulerLock sl{kernel}; + KScopedSchedulerLock sl{m_kernel}; if (tlp->IsAllUsed()) { - fully_used_tlp_tree.insert(*tlp); + m_fully_used_tlp_tree.insert(*tlp); } else { - partially_used_tlp_tree.insert(*tlp); + m_partially_used_tlp_tree.insert(*tlp); } } @@ -544,25 +548,25 @@ Result KProcess::DeleteThreadLocalRegion(VAddr addr) { // Release the region. { - KScopedSchedulerLock sl{kernel}; + KScopedSchedulerLock sl{m_kernel}; // Try to find the page in the partially used list. - auto it = partially_used_tlp_tree.find_key(Common::AlignDown(addr, PageSize)); - if (it == partially_used_tlp_tree.end()) { + auto it = m_partially_used_tlp_tree.find_key(Common::AlignDown(addr, PageSize)); + if (it == m_partially_used_tlp_tree.end()) { // If we don't find it, it has to be in the fully used list. - it = fully_used_tlp_tree.find_key(Common::AlignDown(addr, PageSize)); - R_UNLESS(it != fully_used_tlp_tree.end(), ResultInvalidAddress); + it = m_fully_used_tlp_tree.find_key(Common::AlignDown(addr, PageSize)); + R_UNLESS(it != m_fully_used_tlp_tree.end(), ResultInvalidAddress); // Release the region. it->Release(addr); // Move the page out of the fully used list. KThreadLocalPage* tlp = std::addressof(*it); - fully_used_tlp_tree.erase(it); + m_fully_used_tlp_tree.erase(it); if (tlp->IsAllFree()) { page_to_free = tlp; } else { - partially_used_tlp_tree.insert(*tlp); + m_partially_used_tlp_tree.insert(*tlp); } } else { // Release the region. @@ -571,7 +575,7 @@ Result KProcess::DeleteThreadLocalRegion(VAddr addr) { // Handle the all-free case. KThreadLocalPage* tlp = std::addressof(*it); if (tlp->IsAllFree()) { - partially_used_tlp_tree.erase(it); + m_partially_used_tlp_tree.erase(it); page_to_free = tlp; } } @@ -581,7 +585,7 @@ Result KProcess::DeleteThreadLocalRegion(VAddr addr) { if (page_to_free != nullptr) { page_to_free->Finalize(); - KThreadLocalPage::Free(kernel, page_to_free); + KThreadLocalPage::Free(m_kernel, page_to_free); } R_SUCCEED(); @@ -589,11 +593,11 @@ Result KProcess::DeleteThreadLocalRegion(VAddr addr) { bool KProcess::InsertWatchpoint(Core::System& system, VAddr addr, u64 size, DebugWatchpointType type) { - const auto watch{std::find_if(watchpoints.begin(), watchpoints.end(), [&](const auto& wp) { + const auto watch{std::find_if(m_watchpoints.begin(), m_watchpoints.end(), [&](const auto& wp) { return wp.type == DebugWatchpointType::None; })}; - if (watch == watchpoints.end()) { + if (watch == m_watchpoints.end()) { return false; } @@ -602,7 +606,7 @@ bool KProcess::InsertWatchpoint(Core::System& system, VAddr addr, u64 size, watch->type = type; for (VAddr page = Common::AlignDown(addr, PageSize); page < addr + size; page += PageSize) { - debug_page_refcounts[page]++; + m_debug_page_refcounts[page]++; system.Memory().MarkRegionDebug(page, PageSize, true); } @@ -611,11 +615,11 @@ bool KProcess::InsertWatchpoint(Core::System& system, VAddr addr, u64 size, bool KProcess::RemoveWatchpoint(Core::System& system, VAddr addr, u64 size, DebugWatchpointType type) { - const auto watch{std::find_if(watchpoints.begin(), watchpoints.end(), [&](const auto& wp) { + const auto watch{std::find_if(m_watchpoints.begin(), m_watchpoints.end(), [&](const auto& wp) { return wp.start_address == addr && wp.end_address == addr + size && wp.type == type; })}; - if (watch == watchpoints.end()) { + if (watch == m_watchpoints.end()) { return false; } @@ -624,8 +628,8 @@ bool KProcess::RemoveWatchpoint(Core::System& system, VAddr addr, u64 size, watch->type = DebugWatchpointType::None; for (VAddr page = Common::AlignDown(addr, PageSize); page < addr + size; page += PageSize) { - debug_page_refcounts[page]--; - if (!debug_page_refcounts[page]) { + m_debug_page_refcounts[page]--; + if (!m_debug_page_refcounts[page]) { system.Memory().MarkRegionDebug(page, PageSize, false); } } @@ -636,11 +640,11 @@ bool KProcess::RemoveWatchpoint(Core::System& system, VAddr addr, u64 size, void KProcess::LoadModule(CodeSet code_set, VAddr base_addr) { const auto ReprotectSegment = [&](const CodeSet::Segment& segment, Svc::MemoryPermission permission) { - page_table.SetProcessMemoryPermission(segment.addr + base_addr, segment.size, permission); + m_page_table.SetProcessMemoryPermission(segment.addr + base_addr, segment.size, permission); }; - kernel.System().Memory().WriteBlock(*this, base_addr, code_set.memory.data(), - code_set.memory.size()); + m_kernel.System().Memory().WriteBlock(*this, base_addr, code_set.memory.data(), + code_set.memory.size()); ReprotectSegment(code_set.CodeSegment(), Svc::MemoryPermission::ReadExecute); ReprotectSegment(code_set.RODataSegment(), Svc::MemoryPermission::Read); @@ -648,35 +652,35 @@ void KProcess::LoadModule(CodeSet code_set, VAddr base_addr) { } bool KProcess::IsSignaled() const { - ASSERT(kernel.GlobalSchedulerContext().IsLocked()); - return is_signaled; + ASSERT(KScheduler::IsSchedulerLockedByCurrentThread(m_kernel)); + return m_is_signaled; } -KProcess::KProcess(KernelCore& kernel_) - : KAutoObjectWithSlabHeapAndContainer{kernel_}, page_table{kernel_.System()}, - handle_table{kernel_}, address_arbiter{kernel_.System()}, condition_var{kernel_.System()}, - state_lock{kernel_}, list_lock{kernel_} {} +KProcess::KProcess(KernelCore& kernel) + : KAutoObjectWithSlabHeapAndContainer{kernel}, m_page_table{m_kernel.System()}, + m_handle_table{m_kernel}, m_address_arbiter{m_kernel.System()}, + m_condition_var{m_kernel.System()}, m_state_lock{m_kernel}, m_list_lock{m_kernel} {} KProcess::~KProcess() = default; void KProcess::ChangeState(State new_state) { - if (state == new_state) { + if (m_state == new_state) { return; } - state = new_state; - is_signaled = true; - NotifyAvailable(); + m_state = new_state; + m_is_signaled = true; + this->NotifyAvailable(); } Result KProcess::AllocateMainThreadStack(std::size_t stack_size) { // Ensure that we haven't already allocated stack. - ASSERT(main_thread_stack_size == 0); + ASSERT(m_main_thread_stack_size == 0); // Ensure that we're allocating a valid stack. stack_size = Common::AlignUp(stack_size, PageSize); // R_UNLESS(stack_size + image_size <= m_max_process_memory, ResultOutOfMemory); - R_UNLESS(stack_size + image_size >= image_size, ResultOutOfMemory); + R_UNLESS(stack_size + m_image_size >= m_image_size, ResultOutOfMemory); // Place a tentative reservation of memory for our new stack. KScopedResourceReservation mem_reservation(this, Svc::LimitableResource::PhysicalMemoryMax, @@ -686,11 +690,11 @@ Result KProcess::AllocateMainThreadStack(std::size_t stack_size) { // Allocate and map our stack. if (stack_size) { KProcessAddress stack_bottom; - R_TRY(page_table.MapPages(std::addressof(stack_bottom), stack_size / PageSize, - KMemoryState::Stack, KMemoryPermission::UserReadWrite)); + R_TRY(m_page_table.MapPages(std::addressof(stack_bottom), stack_size / PageSize, + KMemoryState::Stack, KMemoryPermission::UserReadWrite)); - main_thread_stack_top = stack_bottom + stack_size; - main_thread_stack_size = stack_size; + m_main_thread_stack_top = stack_bottom + stack_size; + m_main_thread_stack_size = stack_size; } // We succeeded! Commit our memory reservation. diff --git a/src/core/hle/kernel/k_process.h b/src/core/hle/kernel/k_process.h index 09bf2f1d0..7b7a971b8 100644 --- a/src/core/hle/kernel/k_process.h +++ b/src/core/hle/kernel/k_process.h @@ -68,7 +68,7 @@ class KProcess final : public KAutoObjectWithSlabHeapAndContainer<KProcess, KWor KERNEL_AUTOOBJECT_TRAITS(KProcess, KSynchronizationObject); public: - explicit KProcess(KernelCore& kernel_); + explicit KProcess(KernelCore& kernel); ~KProcess() override; enum class State { @@ -107,66 +107,76 @@ public: /// Gets a reference to the process' page table. KPageTable& PageTable() { - return page_table; + return m_page_table; } /// Gets const a reference to the process' page table. const KPageTable& PageTable() const { - return page_table; + return m_page_table; + } + + /// Gets a reference to the process' page table. + KPageTable& GetPageTable() { + return m_page_table; + } + + /// Gets const a reference to the process' page table. + const KPageTable& GetPageTable() const { + return m_page_table; } /// Gets a reference to the process' handle table. KHandleTable& GetHandleTable() { - return handle_table; + return m_handle_table; } /// Gets a const reference to the process' handle table. const KHandleTable& GetHandleTable() const { - return handle_table; + return m_handle_table; } Result SignalToAddress(VAddr address) { - return condition_var.SignalToAddress(address); + return m_condition_var.SignalToAddress(address); } Result WaitForAddress(Handle handle, VAddr address, u32 tag) { - return condition_var.WaitForAddress(handle, address, tag); + return m_condition_var.WaitForAddress(handle, address, tag); } void SignalConditionVariable(u64 cv_key, int32_t count) { - return condition_var.Signal(cv_key, count); + return m_condition_var.Signal(cv_key, count); } Result WaitConditionVariable(VAddr address, u64 cv_key, u32 tag, s64 ns) { - R_RETURN(condition_var.Wait(address, cv_key, tag, ns)); + R_RETURN(m_condition_var.Wait(address, cv_key, tag, ns)); } Result SignalAddressArbiter(VAddr address, Svc::SignalType signal_type, s32 value, s32 count) { - R_RETURN(address_arbiter.SignalToAddress(address, signal_type, value, count)); + R_RETURN(m_address_arbiter.SignalToAddress(address, signal_type, value, count)); } Result WaitAddressArbiter(VAddr address, Svc::ArbitrationType arb_type, s32 value, s64 timeout) { - R_RETURN(address_arbiter.WaitForAddress(address, arb_type, value, timeout)); + R_RETURN(m_address_arbiter.WaitForAddress(address, arb_type, value, timeout)); } VAddr GetProcessLocalRegionAddress() const { - return plr_address; + return m_plr_address; } /// Gets the current status of the process State GetState() const { - return state; + return m_state; } /// Gets the unique ID that identifies this particular process. - u64 GetProcessID() const { - return process_id; + u64 GetProcessId() const { + return m_process_id; } /// Gets the program ID corresponding to this process. - u64 GetProgramID() const { - return program_id; + u64 GetProgramId() const { + return m_program_id; } /// Gets the resource limit descriptor for this process @@ -174,7 +184,7 @@ public: /// Gets the ideal CPU core ID for this process u8 GetIdealCoreId() const { - return ideal_core; + return m_ideal_core; } /// Checks if the specified thread priority is valid. @@ -184,17 +194,17 @@ public: /// Gets the bitmask of allowed cores that this process' threads can run on. u64 GetCoreMask() const { - return capabilities.GetCoreMask(); + return m_capabilities.GetCoreMask(); } /// Gets the bitmask of allowed thread priorities. u64 GetPriorityMask() const { - return capabilities.GetPriorityMask(); + return m_capabilities.GetPriorityMask(); } /// Gets the amount of secure memory to allocate for memory management. u32 GetSystemResourceSize() const { - return system_resource_size; + return m_system_resource_size; } /// Gets the amount of secure memory currently in use for memory management. @@ -214,67 +224,67 @@ public: /// Whether this process is an AArch64 or AArch32 process. bool Is64BitProcess() const { - return is_64bit_process; + return m_is_64bit_process; } - [[nodiscard]] bool IsSuspended() const { - return is_suspended; + bool IsSuspended() const { + return m_is_suspended; } void SetSuspended(bool suspended) { - is_suspended = suspended; + m_is_suspended = suspended; } /// Gets the total running time of the process instance in ticks. u64 GetCPUTimeTicks() const { - return total_process_running_time_ticks; + return m_total_process_running_time_ticks; } /// Updates the total running time, adding the given ticks to it. void UpdateCPUTimeTicks(u64 ticks) { - total_process_running_time_ticks += ticks; + m_total_process_running_time_ticks += ticks; } - /// Gets the process schedule count, used for thread yelding + /// Gets the process schedule count, used for thread yielding s64 GetScheduledCount() const { - return schedule_count; + return m_schedule_count; } /// Increments the process schedule count, used for thread yielding. void IncrementScheduledCount() { - ++schedule_count; + ++m_schedule_count; } void IncrementRunningThreadCount(); void DecrementRunningThreadCount(); void SetRunningThread(s32 core, KThread* thread, u64 idle_count) { - running_threads[core] = thread; - running_thread_idle_counts[core] = idle_count; + m_running_threads[core] = thread; + m_running_thread_idle_counts[core] = idle_count; } void ClearRunningThread(KThread* thread) { - for (size_t i = 0; i < running_threads.size(); ++i) { - if (running_threads[i] == thread) { - running_threads[i] = nullptr; + for (size_t i = 0; i < m_running_threads.size(); ++i) { + if (m_running_threads[i] == thread) { + m_running_threads[i] = nullptr; } } } [[nodiscard]] KThread* GetRunningThread(s32 core) const { - return running_threads[core]; + return m_running_threads[core]; } bool ReleaseUserException(KThread* thread); [[nodiscard]] KThread* GetPinnedThread(s32 core_id) const { ASSERT(0 <= core_id && core_id < static_cast<s32>(Core::Hardware::NUM_CPU_CORES)); - return pinned_threads[core_id]; + return m_pinned_threads[core_id]; } /// Gets 8 bytes of random data for svcGetInfo RandomEntropy u64 GetRandomEntropy(std::size_t index) const { - return random_entropy.at(index); + return m_random_entropy.at(index); } /// Retrieves the total physical memory available to this process in bytes. @@ -293,7 +303,7 @@ public: /// Gets the list of all threads created with this process as their owner. std::list<KThread*>& GetThreadList() { - return thread_list; + return m_thread_list; } /// Registers a thread as being created under this process, @@ -310,10 +320,10 @@ public: /// Clears the signaled state of the process if and only if it's signaled. /// /// @pre The process must not be already terminated. If this is called on a - /// terminated process, then ERR_INVALID_STATE will be returned. + /// terminated process, then ResultInvalidState will be returned. /// /// @pre The process must be in a signaled state. If this is called on a - /// process instance that is not signaled, ERR_INVALID_STATE will be + /// process instance that is not signaled, ResultInvalidState will be /// returned. Result Reset(); @@ -345,15 +355,15 @@ public: void LoadModule(CodeSet code_set, VAddr base_addr); bool IsInitialized() const override { - return is_initialized; + return m_is_initialized; } - static void PostDestroy([[maybe_unused]] uintptr_t arg) {} + static void PostDestroy(uintptr_t arg) {} void Finalize() override; u64 GetId() const override { - return GetProcessID(); + return GetProcessId(); } bool IsSignaled() const override; @@ -367,7 +377,7 @@ public: void UnpinThread(KThread* thread); KLightLock& GetStateLock() { - return state_lock; + return m_state_lock; } Result AddSharedMemory(KSharedMemory* shmem, VAddr address, size_t size); @@ -392,30 +402,34 @@ public: bool RemoveWatchpoint(Core::System& system, VAddr addr, u64 size, DebugWatchpointType type); const std::array<DebugWatchpoint, Core::Hardware::NUM_WATCHPOINTS>& GetWatchpoints() const { - return watchpoints; + return m_watchpoints; + } + + const std::string& GetName() { + return name; } private: void PinThread(s32 core_id, KThread* thread) { ASSERT(0 <= core_id && core_id < static_cast<s32>(Core::Hardware::NUM_CPU_CORES)); ASSERT(thread != nullptr); - ASSERT(pinned_threads[core_id] == nullptr); - pinned_threads[core_id] = thread; + ASSERT(m_pinned_threads[core_id] == nullptr); + m_pinned_threads[core_id] = thread; } void UnpinThread(s32 core_id, KThread* thread) { ASSERT(0 <= core_id && core_id < static_cast<s32>(Core::Hardware::NUM_CPU_CORES)); ASSERT(thread != nullptr); - ASSERT(pinned_threads[core_id] == thread); - pinned_threads[core_id] = nullptr; + ASSERT(m_pinned_threads[core_id] == thread); + m_pinned_threads[core_id] = nullptr; } void FinalizeHandleTable() { // Finalize the table. - handle_table.Finalize(); + m_handle_table.Finalize(); // Note that the table is finalized. - is_handle_table_initialized = false; + m_is_handle_table_initialized = false; } void ChangeState(State new_state); @@ -424,105 +438,107 @@ private: Result AllocateMainThreadStack(std::size_t stack_size); /// Memory manager for this process - KPageTable page_table; + KPageTable m_page_table; /// Current status of the process - State state{}; + State m_state{}; /// The ID of this process - u64 process_id = 0; + u64 m_process_id = 0; /// Title ID corresponding to the process - u64 program_id = 0; + u64 m_program_id = 0; /// Specifies additional memory to be reserved for the process's memory management by the /// system. When this is non-zero, secure memory is allocated and used for page table allocation /// instead of using the normal global page tables/memory block management. - u32 system_resource_size = 0; + u32 m_system_resource_size = 0; /// Resource limit descriptor for this process - KResourceLimit* resource_limit{}; + KResourceLimit* m_resource_limit{}; - VAddr system_resource_address{}; + VAddr m_system_resource_address{}; /// The ideal CPU core for this process, threads are scheduled on this core by default. - u8 ideal_core = 0; + u8 m_ideal_core = 0; /// Contains the parsed process capability descriptors. - ProcessCapabilities capabilities; + ProcessCapabilities m_capabilities; /// Whether or not this process is AArch64, or AArch32. /// By default, we currently assume this is true, unless otherwise /// specified by metadata provided to the process during loading. - bool is_64bit_process = true; + bool m_is_64bit_process = true; /// Total running time for the process in ticks. - std::atomic<u64> total_process_running_time_ticks = 0; + std::atomic<u64> m_total_process_running_time_ticks = 0; /// Per-process handle table for storing created object handles in. - KHandleTable handle_table; + KHandleTable m_handle_table; /// Per-process address arbiter. - KAddressArbiter address_arbiter; + KAddressArbiter m_address_arbiter; /// The per-process mutex lock instance used for handling various /// forms of services, such as lock arbitration, and condition /// variable related facilities. - KConditionVariable condition_var; + KConditionVariable m_condition_var; /// Address indicating the location of the process' dedicated TLS region. - VAddr plr_address = 0; + VAddr m_plr_address = 0; /// Random values for svcGetInfo RandomEntropy - std::array<u64, RANDOM_ENTROPY_SIZE> random_entropy{}; + std::array<u64, RANDOM_ENTROPY_SIZE> m_random_entropy{}; /// List of threads that are running with this process as their owner. - std::list<KThread*> thread_list; + std::list<KThread*> m_thread_list; /// List of shared memory that are running with this process as their owner. - std::list<KSharedMemoryInfo*> shared_memory_list; + std::list<KSharedMemoryInfo*> m_shared_memory_list; /// Address of the top of the main thread's stack - VAddr main_thread_stack_top{}; + VAddr m_main_thread_stack_top{}; /// Size of the main thread's stack - std::size_t main_thread_stack_size{}; + std::size_t m_main_thread_stack_size{}; /// Memory usage capacity for the process - std::size_t memory_usage_capacity{}; + std::size_t m_memory_usage_capacity{}; /// Process total image size - std::size_t image_size{}; + std::size_t m_image_size{}; /// Schedule count of this process - s64 schedule_count{}; + s64 m_schedule_count{}; + + size_t m_memory_release_hint{}; - size_t memory_release_hint{}; + std::string name{}; - bool is_signaled{}; - bool is_suspended{}; - bool is_immortal{}; - bool is_handle_table_initialized{}; - bool is_initialized{}; + bool m_is_signaled{}; + bool m_is_suspended{}; + bool m_is_immortal{}; + bool m_is_handle_table_initialized{}; + bool m_is_initialized{}; - std::atomic<u16> num_running_threads{}; + std::atomic<u16> m_num_running_threads{}; - std::array<KThread*, Core::Hardware::NUM_CPU_CORES> running_threads{}; - std::array<u64, Core::Hardware::NUM_CPU_CORES> running_thread_idle_counts{}; - std::array<KThread*, Core::Hardware::NUM_CPU_CORES> pinned_threads{}; - std::array<DebugWatchpoint, Core::Hardware::NUM_WATCHPOINTS> watchpoints{}; - std::map<VAddr, u64> debug_page_refcounts; + std::array<KThread*, Core::Hardware::NUM_CPU_CORES> m_running_threads{}; + std::array<u64, Core::Hardware::NUM_CPU_CORES> m_running_thread_idle_counts{}; + std::array<KThread*, Core::Hardware::NUM_CPU_CORES> m_pinned_threads{}; + std::array<DebugWatchpoint, Core::Hardware::NUM_WATCHPOINTS> m_watchpoints{}; + std::map<VAddr, u64> m_debug_page_refcounts; - KThread* exception_thread{}; + KThread* m_exception_thread{}; - KLightLock state_lock; - KLightLock list_lock; + KLightLock m_state_lock; + KLightLock m_list_lock; using TLPTree = Common::IntrusiveRedBlackTreeBaseTraits<KThreadLocalPage>::TreeType<KThreadLocalPage>; using TLPIterator = TLPTree::iterator; - TLPTree fully_used_tlp_tree; - TLPTree partially_used_tlp_tree; + TLPTree m_fully_used_tlp_tree; + TLPTree m_partially_used_tlp_tree; }; } // namespace Kernel diff --git a/src/core/hle/kernel/k_readable_event.cpp b/src/core/hle/kernel/k_readable_event.cpp index 5c942d47c..c30662666 100644 --- a/src/core/hle/kernel/k_readable_event.cpp +++ b/src/core/hle/kernel/k_readable_event.cpp @@ -11,7 +11,7 @@ namespace Kernel { -KReadableEvent::KReadableEvent(KernelCore& kernel_) : KSynchronizationObject{kernel_} {} +KReadableEvent::KReadableEvent(KernelCore& kernel) : KSynchronizationObject{kernel} {} KReadableEvent::~KReadableEvent() = default; @@ -25,7 +25,7 @@ void KReadableEvent::Initialize(KEvent* parent) { } bool KReadableEvent::IsSignaled() const { - ASSERT(KScheduler::IsSchedulerLockedByCurrentThread(kernel)); + ASSERT(KScheduler::IsSchedulerLockedByCurrentThread(m_kernel)); return m_is_signaled; } @@ -33,7 +33,7 @@ bool KReadableEvent::IsSignaled() const { void KReadableEvent::Destroy() { if (m_parent) { { - KScopedSchedulerLock sl{kernel}; + KScopedSchedulerLock sl{m_kernel}; m_parent->OnReadableEventDestroyed(); } m_parent->Close(); @@ -41,31 +41,29 @@ void KReadableEvent::Destroy() { } Result KReadableEvent::Signal() { - KScopedSchedulerLock lk{kernel}; + KScopedSchedulerLock lk{m_kernel}; if (!m_is_signaled) { m_is_signaled = true; this->NotifyAvailable(); } - return ResultSuccess; + R_SUCCEED(); } Result KReadableEvent::Clear() { this->Reset(); - return ResultSuccess; + R_SUCCEED(); } Result KReadableEvent::Reset() { - KScopedSchedulerLock lk{kernel}; + KScopedSchedulerLock lk{m_kernel}; - if (!m_is_signaled) { - return ResultInvalidState; - } + R_UNLESS(m_is_signaled, ResultInvalidState); m_is_signaled = false; - return ResultSuccess; + R_SUCCEED(); } } // namespace Kernel diff --git a/src/core/hle/kernel/k_readable_event.h b/src/core/hle/kernel/k_readable_event.h index 743f96bf5..d2ec36323 100644 --- a/src/core/hle/kernel/k_readable_event.h +++ b/src/core/hle/kernel/k_readable_event.h @@ -17,7 +17,7 @@ class KReadableEvent : public KSynchronizationObject { KERNEL_AUTOOBJECT_TRAITS(KReadableEvent, KSynchronizationObject); public: - explicit KReadableEvent(KernelCore& kernel_); + explicit KReadableEvent(KernelCore& kernel); ~KReadableEvent() override; void Initialize(KEvent* parent); diff --git a/src/core/hle/kernel/k_resource_limit.cpp b/src/core/hle/kernel/k_resource_limit.cpp index b9d22b414..fcee26a29 100644 --- a/src/core/hle/kernel/k_resource_limit.cpp +++ b/src/core/hle/kernel/k_resource_limit.cpp @@ -2,6 +2,7 @@ // SPDX-License-Identifier: GPL-2.0-or-later #include "common/assert.h" +#include "common/overflow.h" #include "core/core.h" #include "core/core_timing.h" #include "core/hle/kernel/k_resource_limit.h" @@ -10,12 +11,12 @@ namespace Kernel { constexpr s64 DefaultTimeout = 10000000000; // 10 seconds -KResourceLimit::KResourceLimit(KernelCore& kernel_) - : KAutoObjectWithSlabHeapAndContainer{kernel_}, lock{kernel_}, cond_var{kernel_} {} +KResourceLimit::KResourceLimit(KernelCore& kernel) + : KAutoObjectWithSlabHeapAndContainer{kernel}, m_lock{m_kernel}, m_cond_var{m_kernel} {} KResourceLimit::~KResourceLimit() = default; -void KResourceLimit::Initialize(const Core::Timing::CoreTiming* core_timing_) { - core_timing = core_timing_; +void KResourceLimit::Initialize(const Core::Timing::CoreTiming* core_timing) { + m_core_timing = core_timing; } void KResourceLimit::Finalize() {} @@ -24,11 +25,11 @@ s64 KResourceLimit::GetLimitValue(LimitableResource which) const { const auto index = static_cast<std::size_t>(which); s64 value{}; { - KScopedLightLock lk{lock}; - value = limit_values[index]; + KScopedLightLock lk{m_lock}; + value = m_limit_values[index]; ASSERT(value >= 0); - ASSERT(current_values[index] <= limit_values[index]); - ASSERT(current_hints[index] <= current_values[index]); + ASSERT(m_current_values[index] <= m_limit_values[index]); + ASSERT(m_current_hints[index] <= m_current_values[index]); } return value; } @@ -37,11 +38,11 @@ s64 KResourceLimit::GetCurrentValue(LimitableResource which) const { const auto index = static_cast<std::size_t>(which); s64 value{}; { - KScopedLightLock lk{lock}; - value = current_values[index]; + KScopedLightLock lk{m_lock}; + value = m_current_values[index]; ASSERT(value >= 0); - ASSERT(current_values[index] <= limit_values[index]); - ASSERT(current_hints[index] <= current_values[index]); + ASSERT(m_current_values[index] <= m_limit_values[index]); + ASSERT(m_current_hints[index] <= m_current_values[index]); } return value; } @@ -50,11 +51,11 @@ s64 KResourceLimit::GetPeakValue(LimitableResource which) const { const auto index = static_cast<std::size_t>(which); s64 value{}; { - KScopedLightLock lk{lock}; - value = peak_values[index]; + KScopedLightLock lk{m_lock}; + value = m_peak_values[index]; ASSERT(value >= 0); - ASSERT(current_values[index] <= limit_values[index]); - ASSERT(current_hints[index] <= current_values[index]); + ASSERT(m_current_values[index] <= m_limit_values[index]); + ASSERT(m_current_hints[index] <= m_current_values[index]); } return value; } @@ -63,11 +64,11 @@ s64 KResourceLimit::GetFreeValue(LimitableResource which) const { const auto index = static_cast<std::size_t>(which); s64 value{}; { - KScopedLightLock lk(lock); - ASSERT(current_values[index] >= 0); - ASSERT(current_values[index] <= limit_values[index]); - ASSERT(current_hints[index] <= current_values[index]); - value = limit_values[index] - current_values[index]; + KScopedLightLock lk(m_lock); + ASSERT(m_current_values[index] >= 0); + ASSERT(m_current_values[index] <= m_limit_values[index]); + ASSERT(m_current_hints[index] <= m_current_values[index]); + value = m_limit_values[index] - m_current_values[index]; } return value; @@ -75,51 +76,51 @@ s64 KResourceLimit::GetFreeValue(LimitableResource which) const { Result KResourceLimit::SetLimitValue(LimitableResource which, s64 value) { const auto index = static_cast<std::size_t>(which); - KScopedLightLock lk(lock); - R_UNLESS(current_values[index] <= value, ResultInvalidState); + KScopedLightLock lk(m_lock); + R_UNLESS(m_current_values[index] <= value, ResultInvalidState); - limit_values[index] = value; - peak_values[index] = current_values[index]; + m_limit_values[index] = value; + m_peak_values[index] = m_current_values[index]; - return ResultSuccess; + R_SUCCEED(); } bool KResourceLimit::Reserve(LimitableResource which, s64 value) { - return Reserve(which, value, core_timing->GetGlobalTimeNs().count() + DefaultTimeout); + return Reserve(which, value, m_core_timing->GetGlobalTimeNs().count() + DefaultTimeout); } bool KResourceLimit::Reserve(LimitableResource which, s64 value, s64 timeout) { ASSERT(value >= 0); const auto index = static_cast<std::size_t>(which); - KScopedLightLock lk(lock); + KScopedLightLock lk(m_lock); - ASSERT(current_hints[index] <= current_values[index]); - if (current_hints[index] >= limit_values[index]) { + ASSERT(m_current_hints[index] <= m_current_values[index]); + if (m_current_hints[index] >= m_limit_values[index]) { return false; } // Loop until we reserve or run out of time. while (true) { - ASSERT(current_values[index] <= limit_values[index]); - ASSERT(current_hints[index] <= current_values[index]); + ASSERT(m_current_values[index] <= m_limit_values[index]); + ASSERT(m_current_hints[index] <= m_current_values[index]); // If we would overflow, don't allow to succeed. - if (current_values[index] + value <= current_values[index]) { + if (Common::WrappingAdd(m_current_values[index], value) <= m_current_values[index]) { break; } - if (current_values[index] + value <= limit_values[index]) { - current_values[index] += value; - current_hints[index] += value; - peak_values[index] = std::max(peak_values[index], current_values[index]); + if (m_current_values[index] + value <= m_limit_values[index]) { + m_current_values[index] += value; + m_current_hints[index] += value; + m_peak_values[index] = std::max(m_peak_values[index], m_current_values[index]); return true; } - if (current_hints[index] + value <= limit_values[index] && - (timeout < 0 || core_timing->GetGlobalTimeNs().count() < timeout)) { - waiter_count++; - cond_var.Wait(&lock, timeout, false); - waiter_count--; + if (m_current_hints[index] + value <= m_limit_values[index] && + (timeout < 0 || m_core_timing->GetGlobalTimeNs().count() < timeout)) { + m_waiter_count++; + m_cond_var.Wait(std::addressof(m_lock), timeout, false); + m_waiter_count--; } else { break; } @@ -137,23 +138,23 @@ void KResourceLimit::Release(LimitableResource which, s64 value, s64 hint) { ASSERT(hint >= 0); const auto index = static_cast<std::size_t>(which); - KScopedLightLock lk(lock); - ASSERT(current_values[index] <= limit_values[index]); - ASSERT(current_hints[index] <= current_values[index]); - ASSERT(value <= current_values[index]); - ASSERT(hint <= current_hints[index]); + KScopedLightLock lk(m_lock); + ASSERT(m_current_values[index] <= m_limit_values[index]); + ASSERT(m_current_hints[index] <= m_current_values[index]); + ASSERT(value <= m_current_values[index]); + ASSERT(hint <= m_current_hints[index]); - current_values[index] -= value; - current_hints[index] -= hint; + m_current_values[index] -= value; + m_current_hints[index] -= hint; - if (waiter_count != 0) { - cond_var.Broadcast(); + if (m_waiter_count != 0) { + m_cond_var.Broadcast(); } } KResourceLimit* CreateResourceLimitForProcess(Core::System& system, s64 physical_memory_size) { auto* resource_limit = KResourceLimit::Create(system.Kernel()); - resource_limit->Initialize(&system.CoreTiming()); + resource_limit->Initialize(std::addressof(system.CoreTiming())); // Initialize default resource limit values. // TODO(bunnei): These values are the system defaults, the limits for service processes are diff --git a/src/core/hle/kernel/k_resource_limit.h b/src/core/hle/kernel/k_resource_limit.h index 2573d1b7c..15e69af56 100644 --- a/src/core/hle/kernel/k_resource_limit.h +++ b/src/core/hle/kernel/k_resource_limit.h @@ -28,10 +28,10 @@ class KResourceLimit final KERNEL_AUTOOBJECT_TRAITS(KResourceLimit, KAutoObject); public: - explicit KResourceLimit(KernelCore& kernel_); + explicit KResourceLimit(KernelCore& kernel); ~KResourceLimit() override; - void Initialize(const Core::Timing::CoreTiming* core_timing_); + void Initialize(const Core::Timing::CoreTiming* core_timing); void Finalize() override; s64 GetLimitValue(LimitableResource which) const; @@ -46,18 +46,18 @@ public: void Release(LimitableResource which, s64 value); void Release(LimitableResource which, s64 value, s64 hint); - static void PostDestroy([[maybe_unused]] uintptr_t arg) {} + static void PostDestroy(uintptr_t arg) {} private: using ResourceArray = std::array<s64, static_cast<std::size_t>(LimitableResource::Count)>; - ResourceArray limit_values{}; - ResourceArray current_values{}; - ResourceArray current_hints{}; - ResourceArray peak_values{}; - mutable KLightLock lock; - s32 waiter_count{}; - KLightConditionVariable cond_var; - const Core::Timing::CoreTiming* core_timing{}; + ResourceArray m_limit_values{}; + ResourceArray m_current_values{}; + ResourceArray m_current_hints{}; + ResourceArray m_peak_values{}; + mutable KLightLock m_lock; + s32 m_waiter_count{}; + KLightConditionVariable m_cond_var; + const Core::Timing::CoreTiming* m_core_timing{}; }; KResourceLimit* CreateResourceLimitForProcess(Core::System& system, s64 physical_memory_size); diff --git a/src/core/hle/kernel/k_scheduler.cpp b/src/core/hle/kernel/k_scheduler.cpp index d6c214237..ecadf2916 100644 --- a/src/core/hle/kernel/k_scheduler.cpp +++ b/src/core/hle/kernel/k_scheduler.cpp @@ -27,7 +27,7 @@ static void IncrementScheduledCount(Kernel::KThread* thread) { } } -KScheduler::KScheduler(KernelCore& kernel_) : kernel{kernel_} { +KScheduler::KScheduler(KernelCore& kernel) : m_kernel{kernel} { m_switch_fiber = std::make_shared<Common::Fiber>([this] { while (true) { ScheduleImplFiber(); @@ -47,7 +47,7 @@ void KScheduler::SetInterruptTaskRunnable() { void KScheduler::RequestScheduleOnInterrupt() { m_state.needs_scheduling = true; - if (CanSchedule(kernel)) { + if (CanSchedule(m_kernel)) { ScheduleOnInterrupt(); } } @@ -97,50 +97,50 @@ u64 KScheduler::UpdateHighestPriorityThreads(KernelCore& kernel) { } void KScheduler::Schedule() { - ASSERT(GetCurrentThread(kernel).GetDisableDispatchCount() == 1); - ASSERT(m_core_id == GetCurrentCoreId(kernel)); + ASSERT(GetCurrentThread(m_kernel).GetDisableDispatchCount() == 1); + ASSERT(m_core_id == GetCurrentCoreId(m_kernel)); ScheduleImpl(); } void KScheduler::ScheduleOnInterrupt() { - GetCurrentThread(kernel).DisableDispatch(); + GetCurrentThread(m_kernel).DisableDispatch(); Schedule(); - GetCurrentThread(kernel).EnableDispatch(); + GetCurrentThread(m_kernel).EnableDispatch(); } void KScheduler::PreemptSingleCore() { - GetCurrentThread(kernel).DisableDispatch(); + GetCurrentThread(m_kernel).DisableDispatch(); - auto* thread = GetCurrentThreadPointer(kernel); - auto& previous_scheduler = kernel.Scheduler(thread->GetCurrentCore()); + auto* thread = GetCurrentThreadPointer(m_kernel); + auto& previous_scheduler = m_kernel.Scheduler(thread->GetCurrentCore()); previous_scheduler.Unload(thread); Common::Fiber::YieldTo(thread->GetHostContext(), *m_switch_fiber); - GetCurrentThread(kernel).EnableDispatch(); + GetCurrentThread(m_kernel).EnableDispatch(); } void KScheduler::RescheduleCurrentCore() { - ASSERT(!kernel.IsPhantomModeForSingleCore()); - ASSERT(GetCurrentThread(kernel).GetDisableDispatchCount() == 1); + ASSERT(!m_kernel.IsPhantomModeForSingleCore()); + ASSERT(GetCurrentThread(m_kernel).GetDisableDispatchCount() == 1); - GetCurrentThread(kernel).EnableDispatch(); + GetCurrentThread(m_kernel).EnableDispatch(); if (m_state.needs_scheduling.load()) { // Disable interrupts, and then check again if rescheduling is needed. // KScopedInterruptDisable intr_disable; - kernel.CurrentScheduler()->RescheduleCurrentCoreImpl(); + m_kernel.CurrentScheduler()->RescheduleCurrentCoreImpl(); } } void KScheduler::RescheduleCurrentCoreImpl() { // Check that scheduling is needed. if (m_state.needs_scheduling.load()) [[likely]] { - GetCurrentThread(kernel).DisableDispatch(); + GetCurrentThread(m_kernel).DisableDispatch(); Schedule(); - GetCurrentThread(kernel).EnableDispatch(); + GetCurrentThread(m_kernel).EnableDispatch(); } } @@ -149,18 +149,18 @@ void KScheduler::Initialize(KThread* main_thread, KThread* idle_thread, s32 core m_core_id = core_id; m_idle_thread = idle_thread; // m_state.idle_thread_stack = m_idle_thread->GetStackTop(); - // m_state.interrupt_task_manager = &kernel.GetInterruptTaskManager(); + // m_state.interrupt_task_manager = std::addressof(kernel.GetInterruptTaskManager()); // Insert the main thread into the priority queue. // { - // KScopedSchedulerLock lk{kernel}; - // GetPriorityQueue(kernel).PushBack(GetCurrentThreadPointer(kernel)); - // SetSchedulerUpdateNeeded(kernel); + // KScopedSchedulerLock lk{m_kernel}; + // GetPriorityQueue(m_kernel).PushBack(GetCurrentThreadPointer(m_kernel)); + // SetSchedulerUpdateNeeded(m_kernel); // } // Bind interrupt handler. // kernel.GetInterruptManager().BindHandler( - // GetSchedulerInterruptHandler(kernel), KInterruptName::Scheduler, m_core_id, + // GetSchedulerInterruptHandler(m_kernel), KInterruptName::Scheduler, m_core_id, // KInterruptController::PriorityLevel::Scheduler, false, false); // Set the current thread. @@ -168,7 +168,7 @@ void KScheduler::Initialize(KThread* main_thread, KThread* idle_thread, s32 core } void KScheduler::Activate() { - ASSERT(GetCurrentThread(kernel).GetDisableDispatchCount() == 1); + ASSERT(GetCurrentThread(m_kernel).GetDisableDispatchCount() == 1); // m_state.should_count_idle = KTargetSystem::IsDebugMode(); m_is_active = true; @@ -176,7 +176,7 @@ void KScheduler::Activate() { } void KScheduler::OnThreadStart() { - GetCurrentThread(kernel).EnableDispatch(); + GetCurrentThread(m_kernel).EnableDispatch(); } u64 KScheduler::UpdateHighestPriorityThread(KThread* highest_thread) { @@ -184,7 +184,7 @@ u64 KScheduler::UpdateHighestPriorityThread(KThread* highest_thread) { prev_highest_thread != highest_thread) [[likely]] { if (prev_highest_thread != nullptr) [[likely]] { IncrementScheduledCount(prev_highest_thread); - prev_highest_thread->SetLastScheduledTick(kernel.System().CoreTiming().GetCPUTicks()); + prev_highest_thread->SetLastScheduledTick(m_kernel.System().CoreTiming().GetCPUTicks()); } if (m_state.should_count_idle) { if (highest_thread != nullptr) [[likely]] { @@ -328,8 +328,8 @@ u64 KScheduler::UpdateHighestPriorityThreadsImpl(KernelCore& kernel) { } void KScheduler::SwitchThread(KThread* next_thread) { - KProcess* const cur_process = GetCurrentProcessPointer(kernel); - KThread* const cur_thread = GetCurrentThreadPointer(kernel); + KProcess* const cur_process = GetCurrentProcessPointer(m_kernel); + KThread* const cur_thread = GetCurrentThreadPointer(m_kernel); // We never want to schedule a null thread, so use the idle thread if we don't have a next. if (next_thread == nullptr) { @@ -351,7 +351,7 @@ void KScheduler::SwitchThread(KThread* next_thread) { // Update the CPU time tracking variables. const s64 prev_tick = m_last_context_switch_time; - const s64 cur_tick = kernel.System().CoreTiming().GetCPUTicks(); + const s64 cur_tick = m_kernel.System().CoreTiming().GetCPUTicks(); const s64 tick_diff = cur_tick - prev_tick; cur_thread->AddCpuTime(m_core_id, tick_diff); if (cur_process != nullptr) { @@ -375,7 +375,7 @@ void KScheduler::SwitchThread(KThread* next_thread) { // } // Set the new thread. - SetCurrentThread(kernel, next_thread); + SetCurrentThread(m_kernel, next_thread); m_current_thread = next_thread; // Set the new Thread Local region. @@ -388,7 +388,7 @@ void KScheduler::ScheduleImpl() { std::atomic_thread_fence(std::memory_order_seq_cst); // Load the appropriate thread pointers for scheduling. - KThread* const cur_thread{GetCurrentThreadPointer(kernel)}; + KThread* const cur_thread{GetCurrentThreadPointer(m_kernel)}; KThread* highest_priority_thread{m_state.highest_priority_thread}; // Check whether there are runnable interrupt tasks. @@ -411,7 +411,7 @@ void KScheduler::ScheduleImpl() { m_switch_cur_thread = cur_thread; m_switch_highest_priority_thread = highest_priority_thread; m_switch_from_schedule = true; - Common::Fiber::YieldTo(cur_thread->host_context, *m_switch_fiber); + Common::Fiber::YieldTo(cur_thread->m_host_context, *m_switch_fiber); // Returning from ScheduleImpl occurs after this thread has been scheduled again. } @@ -450,7 +450,7 @@ void KScheduler::ScheduleImplFiber() { // We want to try to lock the highest priority thread's context. // Try to take it. - while (!highest_priority_thread->context_guard.try_lock()) { + while (!highest_priority_thread->m_context_guard.try_lock()) { // The highest priority thread's context is already locked. // Check if we need scheduling. If we don't, we can retry directly. if (m_state.needs_scheduling.load(std::memory_order_seq_cst)) { @@ -468,7 +468,7 @@ void KScheduler::ScheduleImplFiber() { if (m_state.needs_scheduling.load(std::memory_order_seq_cst)) { // Our switch failed. // We should unlock the thread context, and then retry. - highest_priority_thread->context_guard.unlock(); + highest_priority_thread->m_context_guard.unlock(); goto retry; } else { break; @@ -489,30 +489,30 @@ void KScheduler::ScheduleImplFiber() { Reload(highest_priority_thread); // Reload the host thread. - Common::Fiber::YieldTo(m_switch_fiber, *highest_priority_thread->host_context); + Common::Fiber::YieldTo(m_switch_fiber, *highest_priority_thread->m_host_context); } void KScheduler::Unload(KThread* thread) { - auto& cpu_core = kernel.System().ArmInterface(m_core_id); + auto& cpu_core = m_kernel.System().ArmInterface(m_core_id); cpu_core.SaveContext(thread->GetContext32()); cpu_core.SaveContext(thread->GetContext64()); // Save the TPIDR_EL0 system register in case it was modified. - thread->SetTPIDR_EL0(cpu_core.GetTPIDR_EL0()); + thread->SetTpidrEl0(cpu_core.GetTPIDR_EL0()); cpu_core.ClearExclusiveState(); // Check if the thread is terminated by checking the DPC flags. if ((thread->GetStackParameters().dpc_flags & static_cast<u32>(DpcFlag::Terminated)) == 0) { // The thread isn't terminated, so we want to unlock it. - thread->context_guard.unlock(); + thread->m_context_guard.unlock(); } } void KScheduler::Reload(KThread* thread) { - auto& cpu_core = kernel.System().ArmInterface(m_core_id); + auto& cpu_core = m_kernel.System().ArmInterface(m_core_id); cpu_core.LoadContext(thread->GetContext32()); cpu_core.LoadContext(thread->GetContext64()); - cpu_core.SetTlsAddress(thread->GetTLSAddress()); - cpu_core.SetTPIDR_EL0(thread->GetTPIDR_EL0()); + cpu_core.SetTlsAddress(thread->GetTlsAddress()); + cpu_core.SetTPIDR_EL0(thread->GetTpidrEl0()); cpu_core.LoadWatchpointArray(thread->GetOwnerProcess()->GetWatchpoints()); cpu_core.ClearExclusiveState(); } @@ -891,7 +891,7 @@ void KScheduler::YieldToAnyThread(KernelCore& kernel) { void KScheduler::RescheduleOtherCores(u64 cores_needing_scheduling) { if (const u64 core_mask = cores_needing_scheduling & ~(1ULL << m_core_id); core_mask != 0) { - RescheduleCores(kernel, core_mask); + RescheduleCores(m_kernel, core_mask); } } diff --git a/src/core/hle/kernel/k_scheduler.h b/src/core/hle/kernel/k_scheduler.h index 534321d8d..d85a0c040 100644 --- a/src/core/hle/kernel/k_scheduler.h +++ b/src/core/hle/kernel/k_scheduler.h @@ -80,17 +80,17 @@ public: return GetCurrentThread(kernel).GetDisableDispatchCount() == 0; } static bool IsSchedulerLockedByCurrentThread(KernelCore& kernel) { - return kernel.GlobalSchedulerContext().scheduler_lock.IsLockedByCurrentThread(); + return kernel.GlobalSchedulerContext().m_scheduler_lock.IsLockedByCurrentThread(); } static bool IsSchedulerUpdateNeeded(KernelCore& kernel) { - return kernel.GlobalSchedulerContext().scheduler_update_needed; + return kernel.GlobalSchedulerContext().m_scheduler_update_needed; } static void SetSchedulerUpdateNeeded(KernelCore& kernel) { - kernel.GlobalSchedulerContext().scheduler_update_needed = true; + kernel.GlobalSchedulerContext().m_scheduler_update_needed = true; } static void ClearSchedulerUpdateNeeded(KernelCore& kernel) { - kernel.GlobalSchedulerContext().scheduler_update_needed = false; + kernel.GlobalSchedulerContext().m_scheduler_update_needed = false; } static void DisableScheduling(KernelCore& kernel); @@ -115,7 +115,7 @@ public: private: // Static private API. static KSchedulerPriorityQueue& GetPriorityQueue(KernelCore& kernel) { - return kernel.GlobalSchedulerContext().priority_queue; + return kernel.GlobalSchedulerContext().m_priority_queue; } static u64 UpdateHighestPriorityThreadsImpl(KernelCore& kernel); @@ -149,7 +149,7 @@ private: KInterruptTaskManager* interrupt_task_manager{nullptr}; }; - KernelCore& kernel; + KernelCore& m_kernel; SchedulingState m_state; bool m_is_active{false}; s32 m_core_id{0}; @@ -166,7 +166,7 @@ private: class KScopedSchedulerLock : public KScopedLock<KScheduler::LockType> { public: explicit KScopedSchedulerLock(KernelCore& kernel) - : KScopedLock(kernel.GlobalSchedulerContext().scheduler_lock) {} + : KScopedLock(kernel.GlobalSchedulerContext().m_scheduler_lock) {} ~KScopedSchedulerLock() = default; }; diff --git a/src/core/hle/kernel/k_scheduler_lock.h b/src/core/hle/kernel/k_scheduler_lock.h index 13463717f..caa1404f1 100644 --- a/src/core/hle/kernel/k_scheduler_lock.h +++ b/src/core/hle/kernel/k_scheduler_lock.h @@ -14,74 +14,67 @@ namespace Kernel { class KernelCore; +class GlobalSchedulerContext; template <typename SchedulerType> class KAbstractSchedulerLock { public: - explicit KAbstractSchedulerLock(KernelCore& kernel_) : kernel{kernel_} {} + explicit KAbstractSchedulerLock(KernelCore& kernel) : m_kernel{kernel} {} bool IsLockedByCurrentThread() const { - return owner_thread == GetCurrentThreadPointer(kernel); + return m_owner_thread == GetCurrentThreadPointer(m_kernel); } void Lock() { - // If we are shutting down the kernel, none of this is relevant anymore. - if (kernel.IsShuttingDown()) { - return; - } - - if (IsLockedByCurrentThread()) { + if (this->IsLockedByCurrentThread()) { // If we already own the lock, the lock count should be > 0. // For debug, ensure this is true. - ASSERT(lock_count > 0); + ASSERT(m_lock_count > 0); } else { // Otherwise, we want to disable scheduling and acquire the spinlock. - SchedulerType::DisableScheduling(kernel); - spin_lock.Lock(); + SchedulerType::DisableScheduling(m_kernel); + m_spin_lock.Lock(); - ASSERT(lock_count == 0); - ASSERT(owner_thread == nullptr); + ASSERT(m_lock_count == 0); + ASSERT(m_owner_thread == nullptr); // Take ownership of the lock. - owner_thread = GetCurrentThreadPointer(kernel); + m_owner_thread = GetCurrentThreadPointer(m_kernel); } // Increment the lock count. - lock_count++; + m_lock_count++; } void Unlock() { - // If we are shutting down the kernel, none of this is relevant anymore. - if (kernel.IsShuttingDown()) { - return; - } - - ASSERT(IsLockedByCurrentThread()); - ASSERT(lock_count > 0); + ASSERT(this->IsLockedByCurrentThread()); + ASSERT(m_lock_count > 0); // Release an instance of the lock. - if ((--lock_count) == 0) { + if ((--m_lock_count) == 0) { // Perform a memory barrier here. std::atomic_thread_fence(std::memory_order_seq_cst); // We're no longer going to hold the lock. Take note of what cores need scheduling. const u64 cores_needing_scheduling = - SchedulerType::UpdateHighestPriorityThreads(kernel); + SchedulerType::UpdateHighestPriorityThreads(m_kernel); // Note that we no longer hold the lock, and unlock the spinlock. - owner_thread = nullptr; - spin_lock.Unlock(); + m_owner_thread = nullptr; + m_spin_lock.Unlock(); // Enable scheduling, and perform a rescheduling operation. - SchedulerType::EnableScheduling(kernel, cores_needing_scheduling); + SchedulerType::EnableScheduling(m_kernel, cores_needing_scheduling); } } private: - KernelCore& kernel; - KAlignedSpinLock spin_lock{}; - s32 lock_count{}; - std::atomic<KThread*> owner_thread{}; + friend class GlobalSchedulerContext; + + KernelCore& m_kernel; + KAlignedSpinLock m_spin_lock{}; + s32 m_lock_count{}; + std::atomic<KThread*> m_owner_thread{}; }; } // namespace Kernel diff --git a/src/core/hle/kernel/k_scoped_lock.h b/src/core/hle/kernel/k_scoped_lock.h index 59b3e32ae..629a7d20d 100644 --- a/src/core/hle/kernel/k_scoped_lock.h +++ b/src/core/hle/kernel/k_scoped_lock.h @@ -4,6 +4,7 @@ #pragma once #include <concepts> +#include <memory> #include <type_traits> namespace Kernel { @@ -17,15 +18,15 @@ std::is_reference_v<T>&& requires(T& t) { template <typename T> requires KLockable<T> -class [[nodiscard]] KScopedLock { +class KScopedLock { public: - explicit KScopedLock(T* l) : lock_ptr(l) { - this->lock_ptr->Lock(); + explicit KScopedLock(T* l) : m_lock(*l) {} + explicit KScopedLock(T& l) : m_lock(l) { + m_lock.Lock(); } - explicit KScopedLock(T& l) : KScopedLock(std::addressof(l)) {} ~KScopedLock() { - this->lock_ptr->Unlock(); + m_lock.Unlock(); } KScopedLock(const KScopedLock&) = delete; @@ -35,7 +36,7 @@ public: KScopedLock& operator=(KScopedLock&&) = delete; private: - T* lock_ptr; + T& m_lock; }; } // namespace Kernel diff --git a/src/core/hle/kernel/k_scoped_resource_reservation.h b/src/core/hle/kernel/k_scoped_resource_reservation.h index 436bcf9fe..2cc464612 100644 --- a/src/core/hle/kernel/k_scoped_resource_reservation.h +++ b/src/core/hle/kernel/k_scoped_resource_reservation.h @@ -12,20 +12,20 @@ namespace Kernel { class KScopedResourceReservation { public: explicit KScopedResourceReservation(KResourceLimit* l, LimitableResource r, s64 v, s64 timeout) - : resource_limit(std::move(l)), value(v), resource(r) { - if (resource_limit && value) { - success = resource_limit->Reserve(resource, value, timeout); + : m_limit(l), m_value(v), m_resource(r) { + if (m_limit && m_value) { + m_succeeded = m_limit->Reserve(m_resource, m_value, timeout); } else { - success = true; + m_succeeded = true; } } explicit KScopedResourceReservation(KResourceLimit* l, LimitableResource r, s64 v = 1) - : resource_limit(std::move(l)), value(v), resource(r) { - if (resource_limit && value) { - success = resource_limit->Reserve(resource, value); + : m_limit(l), m_value(v), m_resource(r) { + if (m_limit && m_value) { + m_succeeded = m_limit->Reserve(m_resource, m_value); } else { - success = true; + m_succeeded = true; } } @@ -36,26 +36,26 @@ public: : KScopedResourceReservation(p->GetResourceLimit(), r, v) {} ~KScopedResourceReservation() noexcept { - if (resource_limit && value && success) { - // resource was not committed, release the reservation. - resource_limit->Release(resource, value); + if (m_limit && m_value && m_succeeded) { + // Resource was not committed, release the reservation. + m_limit->Release(m_resource, m_value); } } /// Commit the resource reservation, destruction of this object does not release the resource void Commit() { - resource_limit = nullptr; + m_limit = nullptr; } - [[nodiscard]] bool Succeeded() const { - return success; + bool Succeeded() const { + return m_succeeded; } private: - KResourceLimit* resource_limit{}; - s64 value; - LimitableResource resource; - bool success; + KResourceLimit* m_limit{}; + s64 m_value{}; + LimitableResource m_resource{}; + bool m_succeeded{}; }; } // namespace Kernel diff --git a/src/core/hle/kernel/k_scoped_scheduler_lock_and_sleep.h b/src/core/hle/kernel/k_scoped_scheduler_lock_and_sleep.h index 76db65a4d..c485022f5 100644 --- a/src/core/hle/kernel/k_scoped_scheduler_lock_and_sleep.h +++ b/src/core/hle/kernel/k_scoped_scheduler_lock_and_sleep.h @@ -11,32 +11,39 @@ namespace Kernel { -class [[nodiscard]] KScopedSchedulerLockAndSleep { +class KScopedSchedulerLockAndSleep { public: - explicit KScopedSchedulerLockAndSleep(KernelCore& kernel_, KThread* t, s64 timeout) - : kernel(kernel_), thread(t), timeout_tick(timeout) { + explicit KScopedSchedulerLockAndSleep(KernelCore& kernel, KHardwareTimer** out_timer, + KThread* thread, s64 timeout_tick) + : m_kernel(kernel), m_timeout_tick(timeout_tick), m_thread(thread), m_timer() { // Lock the scheduler. - kernel.GlobalSchedulerContext().scheduler_lock.Lock(); + kernel.GlobalSchedulerContext().m_scheduler_lock.Lock(); + + // Set our timer only if the time is positive. + m_timer = (timeout_tick > 0) ? std::addressof(kernel.HardwareTimer()) : nullptr; + + *out_timer = m_timer; } ~KScopedSchedulerLockAndSleep() { // Register the sleep. - if (timeout_tick > 0) { - kernel.HardwareTimer().RegisterTask(thread, timeout_tick); + if (m_timeout_tick > 0) { + m_timer->RegisterTask(m_thread, m_timeout_tick); } // Unlock the scheduler. - kernel.GlobalSchedulerContext().scheduler_lock.Unlock(); + m_kernel.GlobalSchedulerContext().m_scheduler_lock.Unlock(); } void CancelSleep() { - timeout_tick = 0; + m_timeout_tick = 0; } private: - KernelCore& kernel; - KThread* thread{}; - s64 timeout_tick{}; + KernelCore& m_kernel; + s64 m_timeout_tick{}; + KThread* m_thread{}; + KHardwareTimer* m_timer{}; }; } // namespace Kernel diff --git a/src/core/hle/kernel/k_server_port.cpp b/src/core/hle/kernel/k_server_port.cpp index 16968ba97..a29d34bc1 100644 --- a/src/core/hle/kernel/k_server_port.cpp +++ b/src/core/hle/kernel/k_server_port.cpp @@ -12,13 +12,12 @@ namespace Kernel { -KServerPort::KServerPort(KernelCore& kernel_) : KSynchronizationObject{kernel_} {} +KServerPort::KServerPort(KernelCore& kernel) : KSynchronizationObject{kernel} {} KServerPort::~KServerPort() = default; -void KServerPort::Initialize(KPort* parent_port_, std::string&& name_) { +void KServerPort::Initialize(KPort* parent) { // Set member variables. - parent = parent_port_; - name = std::move(name_); + m_parent = parent; } bool KServerPort::IsLight() const { @@ -36,10 +35,10 @@ void KServerPort::CleanupSessions() { // Get the last session in the list KServerSession* session = nullptr; { - KScopedSchedulerLock sl{kernel}; - if (!session_list.empty()) { - session = std::addressof(session_list.front()); - session_list.pop_front(); + KScopedSchedulerLock sl{m_kernel}; + if (!m_session_list.empty()) { + session = std::addressof(m_session_list.front()); + m_session_list.pop_front(); } } @@ -54,13 +53,13 @@ void KServerPort::CleanupSessions() { void KServerPort::Destroy() { // Note with our parent that we're closed. - parent->OnServerClosed(); + m_parent->OnServerClosed(); // Perform necessary cleanup of our session lists. this->CleanupSessions(); // Close our reference to our parent. - parent->Close(); + m_parent->Close(); } bool KServerPort::IsSignaled() const { @@ -68,18 +67,18 @@ bool KServerPort::IsSignaled() const { UNIMPLEMENTED(); return false; } else { - return !session_list.empty(); + return !m_session_list.empty(); } } void KServerPort::EnqueueSession(KServerSession* session) { ASSERT(!this->IsLight()); - KScopedSchedulerLock sl{kernel}; + KScopedSchedulerLock sl{m_kernel}; // Add the session to our queue. - session_list.push_back(*session); - if (session_list.size() == 1) { + m_session_list.push_back(*session); + if (m_session_list.size() == 1) { this->NotifyAvailable(); } } @@ -87,15 +86,15 @@ void KServerPort::EnqueueSession(KServerSession* session) { KServerSession* KServerPort::AcceptSession() { ASSERT(!this->IsLight()); - KScopedSchedulerLock sl{kernel}; + KScopedSchedulerLock sl{m_kernel}; // Return the first session in the list. - if (session_list.empty()) { + if (m_session_list.empty()) { return nullptr; } - KServerSession* session = std::addressof(session_list.front()); - session_list.pop_front(); + KServerSession* session = std::addressof(m_session_list.front()); + m_session_list.pop_front(); return session; } diff --git a/src/core/hle/kernel/k_server_port.h b/src/core/hle/kernel/k_server_port.h index 5fc7ee683..21c040e62 100644 --- a/src/core/hle/kernel/k_server_port.h +++ b/src/core/hle/kernel/k_server_port.h @@ -22,17 +22,17 @@ class KServerPort final : public KSynchronizationObject { KERNEL_AUTOOBJECT_TRAITS(KServerPort, KSynchronizationObject); public: - explicit KServerPort(KernelCore& kernel_); + explicit KServerPort(KernelCore& kernel); ~KServerPort() override; - void Initialize(KPort* parent_port_, std::string&& name_); + void Initialize(KPort* parent); - void EnqueueSession(KServerSession* pending_session); + void EnqueueSession(KServerSession* session); KServerSession* AcceptSession(); const KPort* GetParent() const { - return parent; + return m_parent; } bool IsLight() const; @@ -46,8 +46,8 @@ private: void CleanupSessions(); - SessionList session_list; - KPort* parent{}; + SessionList m_session_list{}; + KPort* m_parent{}; }; } // namespace Kernel diff --git a/src/core/hle/kernel/k_server_session.cpp b/src/core/hle/kernel/k_server_session.cpp index aa1941f01..2288ee435 100644 --- a/src/core/hle/kernel/k_server_session.cpp +++ b/src/core/hle/kernel/k_server_session.cpp @@ -10,8 +10,6 @@ #include "common/scope_exit.h" #include "core/core.h" #include "core/core_timing.h" -#include "core/hle/ipc_helpers.h" -#include "core/hle/kernel/hle_ipc.h" #include "core/hle/kernel/k_client_port.h" #include "core/hle/kernel/k_handle_table.h" #include "core/hle/kernel/k_process.h" @@ -22,29 +20,25 @@ #include "core/hle/kernel/k_thread.h" #include "core/hle/kernel/k_thread_queue.h" #include "core/hle/kernel/kernel.h" +#include "core/hle/service/hle_ipc.h" +#include "core/hle/service/ipc_helpers.h" #include "core/memory.h" namespace Kernel { using ThreadQueueImplForKServerSessionRequest = KThreadQueue; -KServerSession::KServerSession(KernelCore& kernel_) - : KSynchronizationObject{kernel_}, m_lock{kernel_} {} +KServerSession::KServerSession(KernelCore& kernel) + : KSynchronizationObject{kernel}, m_lock{m_kernel} {} KServerSession::~KServerSession() = default; -void KServerSession::Initialize(KSession* parent_session_, std::string&& name_) { - // Set member variables. - parent = parent_session_; - name = std::move(name_); -} - void KServerSession::Destroy() { - parent->OnServerClosed(); + m_parent->OnServerClosed(); this->CleanupRequests(); - parent->Close(); + m_parent->Close(); } void KServerSession::OnClientClosed() { @@ -62,7 +56,7 @@ void KServerSession::OnClientClosed() { // Get the next request. { - KScopedSchedulerLock sl{kernel}; + KScopedSchedulerLock sl{m_kernel}; if (m_current_request != nullptr && m_current_request != prev_request) { // Set the request, open a reference as we process it. @@ -121,7 +115,7 @@ void KServerSession::OnClientClosed() { // // Get the process and page table. // KProcess *client_process = thread->GetOwnerProcess(); - // auto &client_pt = client_process->GetPageTable(); + // auto& client_pt = client_process->GetPageTable(); // // Reply to the request. // ReplyAsyncError(client_process, request->GetAddress(), request->GetSize(), @@ -141,10 +135,10 @@ void KServerSession::OnClientClosed() { } bool KServerSession::IsSignaled() const { - ASSERT(KScheduler::IsSchedulerLockedByCurrentThread(kernel)); + ASSERT(KScheduler::IsSchedulerLockedByCurrentThread(m_kernel)); // If the client is closed, we're always signaled. - if (parent->IsClientClosed()) { + if (m_parent->IsClientClosed()) { return true; } @@ -154,17 +148,17 @@ bool KServerSession::IsSignaled() const { Result KServerSession::OnRequest(KSessionRequest* request) { // Create the wait queue. - ThreadQueueImplForKServerSessionRequest wait_queue{kernel}; + ThreadQueueImplForKServerSessionRequest wait_queue{m_kernel}; { // Lock the scheduler. - KScopedSchedulerLock sl{kernel}; + KScopedSchedulerLock sl{m_kernel}; // Ensure that we can handle new requests. - R_UNLESS(!parent->IsServerClosed(), ResultSessionClosed); + R_UNLESS(!m_parent->IsServerClosed(), ResultSessionClosed); // Check that we're not terminating. - R_UNLESS(!GetCurrentThread(kernel).IsTerminationRequested(), ResultTerminationRequested); + R_UNLESS(!GetCurrentThread(m_kernel).IsTerminationRequested(), ResultTerminationRequested); // Get whether we're empty. const bool was_empty = m_request_list.empty(); @@ -182,11 +176,11 @@ Result KServerSession::OnRequest(KSessionRequest* request) { R_SUCCEED_IF(request->GetEvent() != nullptr); // This is a synchronous request, so we should wait for our request to complete. - GetCurrentThread(kernel).SetWaitReasonForDebugging(ThreadWaitReasonForDebugging::IPC); - GetCurrentThread(kernel).BeginWait(&wait_queue); + GetCurrentThread(m_kernel).SetWaitReasonForDebugging(ThreadWaitReasonForDebugging::IPC); + GetCurrentThread(m_kernel).BeginWait(std::addressof(wait_queue)); } - return GetCurrentThread(kernel).GetWaitResult(); + return GetCurrentThread(m_kernel).GetWaitResult(); } Result KServerSession::SendReply(bool is_hle) { @@ -196,7 +190,7 @@ Result KServerSession::SendReply(bool is_hle) { // Get the request. KSessionRequest* request; { - KScopedSchedulerLock sl{kernel}; + KScopedSchedulerLock sl{m_kernel}; // Get the current request. request = m_current_request; @@ -219,7 +213,7 @@ Result KServerSession::SendReply(bool is_hle) { KEvent* event = request->GetEvent(); // Check whether we're closed. - const bool closed = (client_thread == nullptr || parent->IsClientClosed()); + const bool closed = (client_thread == nullptr || m_parent->IsClientClosed()); Result result = ResultSuccess; if (!closed) { @@ -228,11 +222,11 @@ Result KServerSession::SendReply(bool is_hle) { // HLE servers write directly to a pointer to the thread command buffer. Therefore // the reply has already been written in this case. } else { - Core::Memory::Memory& memory{kernel.System().Memory()}; - KThread* server_thread{GetCurrentThreadPointer(kernel)}; + Core::Memory::Memory& memory{m_kernel.System().Memory()}; + KThread* server_thread{GetCurrentThreadPointer(m_kernel)}; UNIMPLEMENTED_IF(server_thread->GetOwnerProcess() != client_thread->GetOwnerProcess()); - auto* src_msg_buffer = memory.GetPointer(server_thread->GetTLSAddress()); + auto* src_msg_buffer = memory.GetPointer(server_thread->GetTlsAddress()); auto* dst_msg_buffer = memory.GetPointer(client_message); std::memcpy(dst_msg_buffer, src_msg_buffer, client_buffer_size); } @@ -254,7 +248,7 @@ Result KServerSession::SendReply(bool is_hle) { if (event != nullptr) { // // Get the client process/page table. // KProcess *client_process = client_thread->GetOwnerProcess(); - // KPageTable *client_page_table = &client_process->PageTable(); + // KPageTable *client_page_table = std::addressof(client_process->PageTable()); // // If we need to, reply with an async error. // if (R_FAILED(client_result)) { @@ -270,7 +264,7 @@ Result KServerSession::SendReply(bool is_hle) { event->Signal(); } else { // End the client thread's wait. - KScopedSchedulerLock sl{kernel}; + KScopedSchedulerLock sl{m_kernel}; if (!client_thread->IsTerminationRequested()) { client_thread->EndWait(client_result); @@ -278,11 +272,11 @@ Result KServerSession::SendReply(bool is_hle) { } } - return result; + R_RETURN(result); } -Result KServerSession::ReceiveRequest(std::shared_ptr<HLERequestContext>* out_context, - std::weak_ptr<SessionRequestManager> manager) { +Result KServerSession::ReceiveRequest(std::shared_ptr<Service::HLERequestContext>* out_context, + std::weak_ptr<Service::SessionRequestManager> manager) { // Lock the session. KScopedLightLock lk{m_lock}; @@ -291,10 +285,10 @@ Result KServerSession::ReceiveRequest(std::shared_ptr<HLERequestContext>* out_co KThread* client_thread; { - KScopedSchedulerLock sl{kernel}; + KScopedSchedulerLock sl{m_kernel}; // Ensure that we can service the request. - R_UNLESS(!parent->IsClientClosed(), ResultSessionClosed); + R_UNLESS(!m_parent->IsClientClosed(), ResultSessionClosed); // Ensure we aren't already servicing a request. R_UNLESS(m_current_request == nullptr, ResultNotFound); @@ -303,7 +297,7 @@ Result KServerSession::ReceiveRequest(std::shared_ptr<HLERequestContext>* out_co R_UNLESS(!m_request_list.empty(), ResultNotFound); // Pop the first request from the list. - request = &m_request_list.front(); + request = std::addressof(m_request_list.front()); m_request_list.pop_front(); // Get the thread for the request. @@ -325,26 +319,27 @@ Result KServerSession::ReceiveRequest(std::shared_ptr<HLERequestContext>* out_co // bool recv_list_broken = false; // Receive the message. - Core::Memory::Memory& memory{kernel.System().Memory()}; + Core::Memory::Memory& memory{m_kernel.System().Memory()}; if (out_context != nullptr) { // HLE request. u32* cmd_buf{reinterpret_cast<u32*>(memory.GetPointer(client_message))}; - *out_context = std::make_shared<HLERequestContext>(kernel, memory, this, client_thread); + *out_context = + std::make_shared<Service::HLERequestContext>(m_kernel, memory, this, client_thread); (*out_context)->SetSessionRequestManager(manager); (*out_context) ->PopulateFromIncomingCommandBuffer(client_thread->GetOwnerProcess()->GetHandleTable(), cmd_buf); } else { - KThread* server_thread{GetCurrentThreadPointer(kernel)}; + KThread* server_thread{GetCurrentThreadPointer(m_kernel)}; UNIMPLEMENTED_IF(server_thread->GetOwnerProcess() != client_thread->GetOwnerProcess()); auto* src_msg_buffer = memory.GetPointer(client_message); - auto* dst_msg_buffer = memory.GetPointer(server_thread->GetTLSAddress()); + auto* dst_msg_buffer = memory.GetPointer(server_thread->GetTlsAddress()); std::memcpy(dst_msg_buffer, src_msg_buffer, client_buffer_size); } // We succeeded. - return ResultSuccess; + R_SUCCEED(); } void KServerSession::CleanupRequests() { @@ -355,7 +350,7 @@ void KServerSession::CleanupRequests() { // Get the next request. KSessionRequest* request = nullptr; { - KScopedSchedulerLock sl{kernel}; + KScopedSchedulerLock sl{m_kernel}; if (m_current_request) { // Choose the current request if we have one. @@ -363,7 +358,7 @@ void KServerSession::CleanupRequests() { m_current_request = nullptr; } else if (!m_request_list.empty()) { // Pop the request from the front of the list. - request = &m_request_list.front(); + request = std::addressof(m_request_list.front()); m_request_list.pop_front(); } } @@ -386,7 +381,8 @@ void KServerSession::CleanupRequests() { // KProcess *client_process = (client_thread != nullptr) ? // client_thread->GetOwnerProcess() : nullptr; // KProcessPageTable *client_page_table = (client_process != nullptr) ? - // &client_process->GetPageTable() : nullptr; + // std::addressof(client_process->GetPageTable()) + // : nullptr; // Cleanup the mappings. // Result result = CleanupMap(request, server_process, client_page_table); @@ -406,7 +402,7 @@ void KServerSession::CleanupRequests() { event->Signal(); } else { // End the client thread's wait. - KScopedSchedulerLock sl{kernel}; + KScopedSchedulerLock sl{m_kernel}; if (!client_thread->IsTerminationRequested()) { client_thread->EndWait(ResultSessionClosed); diff --git a/src/core/hle/kernel/k_server_session.h b/src/core/hle/kernel/k_server_session.h index 6e189af8b..5ee02f556 100644 --- a/src/core/hle/kernel/k_server_session.h +++ b/src/core/hle/kernel/k_server_session.h @@ -10,18 +10,20 @@ #include <boost/intrusive/list.hpp> -#include "core/hle/kernel/hle_ipc.h" #include "core/hle/kernel/k_light_lock.h" #include "core/hle/kernel/k_session_request.h" #include "core/hle/kernel/k_synchronization_object.h" #include "core/hle/result.h" +namespace Service { +class HLERequestContext; +class SessionRequestManager; +} // namespace Service + namespace Kernel { -class HLERequestContext; class KernelCore; class KSession; -class SessionRequestManager; class KThread; class KServerSession final : public KSynchronizationObject, @@ -31,19 +33,17 @@ class KServerSession final : public KSynchronizationObject, friend class ServiceThread; public: - explicit KServerSession(KernelCore& kernel_); + explicit KServerSession(KernelCore& kernel); ~KServerSession() override; void Destroy() override; - void Initialize(KSession* parent_session_, std::string&& name_); - - KSession* GetParent() { - return parent; + void Initialize(KSession* p) { + m_parent = p; } const KSession* GetParent() const { - return parent; + return m_parent; } bool IsSignaled() const override; @@ -52,8 +52,8 @@ public: /// TODO: flesh these out to match the real kernel Result OnRequest(KSessionRequest* request); Result SendReply(bool is_hle = false); - Result ReceiveRequest(std::shared_ptr<HLERequestContext>* out_context = nullptr, - std::weak_ptr<SessionRequestManager> manager = {}); + Result ReceiveRequest(std::shared_ptr<Service::HLERequestContext>* out_context = nullptr, + std::weak_ptr<Service::SessionRequestManager> manager = {}); Result SendReplyHLE() { return SendReply(true); @@ -64,10 +64,10 @@ private: void CleanupRequests(); /// KSession that owns this KServerSession - KSession* parent{}; + KSession* m_parent{}; /// List of threads which are pending a reply. - boost::intrusive::list<KSessionRequest> m_request_list; + boost::intrusive::list<KSessionRequest> m_request_list{}; KSessionRequest* m_current_request{}; KLightLock m_lock; diff --git a/src/core/hle/kernel/k_session.cpp b/src/core/hle/kernel/k_session.cpp index 7e677c028..44d7a8f02 100644 --- a/src/core/hle/kernel/k_session.cpp +++ b/src/core/hle/kernel/k_session.cpp @@ -9,69 +9,63 @@ namespace Kernel { -KSession::KSession(KernelCore& kernel_) - : KAutoObjectWithSlabHeapAndContainer{kernel_}, server{kernel_}, client{kernel_} {} +KSession::KSession(KernelCore& kernel) + : KAutoObjectWithSlabHeapAndContainer{kernel}, m_server{kernel}, m_client{kernel} {} KSession::~KSession() = default; -void KSession::Initialize(KClientPort* port_, const std::string& name_) { +void KSession::Initialize(KClientPort* client_port, uintptr_t name) { // Increment reference count. // Because reference count is one on creation, this will result // in a reference count of two. Thus, when both server and client are closed // this object will be destroyed. - Open(); + this->Open(); // Create our sub sessions. - KAutoObject::Create(std::addressof(server)); - KAutoObject::Create(std::addressof(client)); + KAutoObject::Create(std::addressof(m_server)); + KAutoObject::Create(std::addressof(m_client)); // Initialize our sub sessions. - server.Initialize(this, name_ + ":Server"); - client.Initialize(this, name_ + ":Client"); + m_server.Initialize(this); + m_client.Initialize(this); // Set state and name. - SetState(State::Normal); - name = name_; + this->SetState(State::Normal); + m_name = name; // Set our owner process. //! FIXME: this is the wrong process! - process = kernel.ApplicationProcess(); - process->Open(); + m_process = m_kernel.ApplicationProcess(); + m_process->Open(); // Set our port. - port = port_; - if (port != nullptr) { - port->Open(); + m_port = client_port; + if (m_port != nullptr) { + m_port->Open(); } // Mark initialized. - initialized = true; + m_initialized = true; } void KSession::Finalize() { - if (port == nullptr) { - return; + if (m_port != nullptr) { + m_port->OnSessionFinalized(); + m_port->Close(); } - - port->OnSessionFinalized(); - port->Close(); } void KSession::OnServerClosed() { - if (GetState() != State::Normal) { - return; + if (this->GetState() == State::Normal) { + this->SetState(State::ServerClosed); + m_client.OnServerClosed(); } - - SetState(State::ServerClosed); - client.OnServerClosed(); } void KSession::OnClientClosed() { - if (GetState() != State::Normal) { - return; + if (this->GetState() == State::Normal) { + SetState(State::ClientClosed); + m_server.OnClientClosed(); } - - SetState(State::ClientClosed); - server.OnClientClosed(); } void KSession::PostDestroy(uintptr_t arg) { diff --git a/src/core/hle/kernel/k_session.h b/src/core/hle/kernel/k_session.h index 93e5e6f71..f69bab088 100644 --- a/src/core/hle/kernel/k_session.h +++ b/src/core/hle/kernel/k_session.h @@ -18,19 +18,18 @@ class KSession final : public KAutoObjectWithSlabHeapAndContainer<KSession, KAut KERNEL_AUTOOBJECT_TRAITS(KSession, KAutoObject); public: - explicit KSession(KernelCore& kernel_); + explicit KSession(KernelCore& kernel); ~KSession() override; - void Initialize(KClientPort* port_, const std::string& name_); - + void Initialize(KClientPort* port, uintptr_t name); void Finalize() override; bool IsInitialized() const override { - return initialized; + return m_initialized; } uintptr_t GetPostDestroyArgument() const override { - return reinterpret_cast<uintptr_t>(process); + return reinterpret_cast<uintptr_t>(m_process); } static void PostDestroy(uintptr_t arg); @@ -48,27 +47,23 @@ public: } KClientSession& GetClientSession() { - return client; + return m_client; } KServerSession& GetServerSession() { - return server; + return m_server; } const KClientSession& GetClientSession() const { - return client; + return m_client; } const KServerSession& GetServerSession() const { - return server; + return m_server; } const KClientPort* GetParent() const { - return port; - } - - KClientPort* GetParent() { - return port; + return m_port; } private: @@ -80,20 +75,20 @@ private: }; void SetState(State state) { - atomic_state = static_cast<u8>(state); + m_atomic_state = static_cast<u8>(state); } State GetState() const { - return static_cast<State>(atomic_state.load(std::memory_order_relaxed)); + return static_cast<State>(m_atomic_state.load()); } - KServerSession server; - KClientSession client; - std::atomic<std::underlying_type_t<State>> atomic_state{ - static_cast<std::underlying_type_t<State>>(State::Invalid)}; - KClientPort* port{}; - KProcess* process{}; - bool initialized{}; + KServerSession m_server; + KClientSession m_client; + KClientPort* m_port{}; + uintptr_t m_name{}; + KProcess* m_process{}; + std::atomic<u8> m_atomic_state{static_cast<u8>(State::Invalid)}; + bool m_initialized{}; }; } // namespace Kernel diff --git a/src/core/hle/kernel/k_session_request.cpp b/src/core/hle/kernel/k_session_request.cpp index 520da6aa7..a329e5690 100644 --- a/src/core/hle/kernel/k_session_request.cpp +++ b/src/core/hle/kernel/k_session_request.cpp @@ -14,46 +14,46 @@ Result KSessionRequest::SessionMappings::PushMap(VAddr client, VAddr server, siz // Get the mapping. Mapping* mapping; if (index < NumStaticMappings) { - mapping = &m_static_mappings[index]; + mapping = std::addressof(m_static_mappings[index]); } else { // Allocate a page for the extra mappings. if (m_mappings == nullptr) { - KPageBuffer* page_buffer = KPageBuffer::Allocate(kernel); + KPageBuffer* page_buffer = KPageBuffer::Allocate(m_kernel); R_UNLESS(page_buffer != nullptr, ResultOutOfMemory); m_mappings = reinterpret_cast<Mapping*>(page_buffer); } - mapping = &m_mappings[index - NumStaticMappings]; + mapping = std::addressof(m_mappings[index - NumStaticMappings]); } // Set the mapping. mapping->Set(client, server, size, state); - return ResultSuccess; + R_SUCCEED(); } Result KSessionRequest::SessionMappings::PushSend(VAddr client, VAddr server, size_t size, KMemoryState state) { ASSERT(m_num_recv == 0); ASSERT(m_num_exch == 0); - return this->PushMap(client, server, size, state, m_num_send++); + R_RETURN(this->PushMap(client, server, size, state, m_num_send++)); } Result KSessionRequest::SessionMappings::PushReceive(VAddr client, VAddr server, size_t size, KMemoryState state) { ASSERT(m_num_exch == 0); - return this->PushMap(client, server, size, state, m_num_send + m_num_recv++); + R_RETURN(this->PushMap(client, server, size, state, m_num_send + m_num_recv++)); } Result KSessionRequest::SessionMappings::PushExchange(VAddr client, VAddr server, size_t size, KMemoryState state) { - return this->PushMap(client, server, size, state, m_num_send + m_num_recv + m_num_exch++); + R_RETURN(this->PushMap(client, server, size, state, m_num_send + m_num_recv + m_num_exch++)); } void KSessionRequest::SessionMappings::Finalize() { if (m_mappings) { - KPageBuffer::Free(kernel, reinterpret_cast<KPageBuffer*>(m_mappings)); + KPageBuffer::Free(m_kernel, reinterpret_cast<KPageBuffer*>(m_mappings)); m_mappings = nullptr; } } diff --git a/src/core/hle/kernel/k_session_request.h b/src/core/hle/kernel/k_session_request.h index e5558bc2c..5685048ba 100644 --- a/src/core/hle/kernel/k_session_request.h +++ b/src/core/hle/kernel/k_session_request.h @@ -47,14 +47,14 @@ public: } private: - VAddr m_client_address; - VAddr m_server_address; - size_t m_size; - KMemoryState m_state; + VAddr m_client_address{}; + VAddr m_server_address{}; + size_t m_size{}; + KMemoryState m_state{}; }; public: - explicit SessionMappings(KernelCore& kernel_) : kernel(kernel_) {} + explicit SessionMappings(KernelCore& kernel) : m_kernel(kernel) {} void Initialize() {} void Finalize(); @@ -149,8 +149,8 @@ public: } private: - KernelCore& kernel; - std::array<Mapping, NumStaticMappings> m_static_mappings; + KernelCore& m_kernel; + std::array<Mapping, NumStaticMappings> m_static_mappings{}; Mapping* m_mappings{}; u8 m_num_send{}; u8 m_num_recv{}; @@ -158,7 +158,7 @@ public: }; public: - explicit KSessionRequest(KernelCore& kernel_) : KAutoObject(kernel_), m_mappings(kernel_) {} + explicit KSessionRequest(KernelCore& kernel) : KAutoObject(kernel), m_mappings(kernel) {} static KSessionRequest* Create(KernelCore& kernel) { KSessionRequest* req = KSessionRequest::Allocate(kernel); @@ -170,13 +170,13 @@ public: void Destroy() override { this->Finalize(); - KSessionRequest::Free(kernel, this); + KSessionRequest::Free(m_kernel, this); } void Initialize(KEvent* event, uintptr_t address, size_t size) { m_mappings.Initialize(); - m_thread = GetCurrentThreadPointer(kernel); + m_thread = GetCurrentThreadPointer(m_kernel); m_event = event; m_address = address; m_size = size; diff --git a/src/core/hle/kernel/k_shared_memory.cpp b/src/core/hle/kernel/k_shared_memory.cpp index df505edfe..954e5befe 100644 --- a/src/core/hle/kernel/k_shared_memory.cpp +++ b/src/core/hle/kernel/k_shared_memory.cpp @@ -12,29 +12,27 @@ namespace Kernel { -KSharedMemory::KSharedMemory(KernelCore& kernel_) : KAutoObjectWithSlabHeapAndContainer{kernel_} {} +KSharedMemory::KSharedMemory(KernelCore& kernel) : KAutoObjectWithSlabHeapAndContainer{kernel} {} KSharedMemory::~KSharedMemory() = default; -Result KSharedMemory::Initialize(Core::DeviceMemory& device_memory_, KProcess* owner_process_, - Svc::MemoryPermission owner_permission_, - Svc::MemoryPermission user_permission_, std::size_t size_, - std::string name_) { +Result KSharedMemory::Initialize(Core::DeviceMemory& device_memory, KProcess* owner_process, + Svc::MemoryPermission owner_permission, + Svc::MemoryPermission user_permission, std::size_t size) { // Set members. - owner_process = owner_process_; - device_memory = &device_memory_; - owner_permission = owner_permission_; - user_permission = user_permission_; - size = Common::AlignUp(size_, PageSize); - name = std::move(name_); + m_owner_process = owner_process; + m_device_memory = std::addressof(device_memory); + m_owner_permission = owner_permission; + m_user_permission = user_permission; + m_size = Common::AlignUp(size, PageSize); const size_t num_pages = Common::DivideUp(size, PageSize); // Get the resource limit. - KResourceLimit* reslimit = kernel.GetSystemResourceLimit(); + KResourceLimit* reslimit = m_kernel.GetSystemResourceLimit(); // Reserve memory for ourselves. KScopedResourceReservation memory_reservation(reslimit, LimitableResource::PhysicalMemoryMax, - size_); + size); R_UNLESS(memory_reservation.Succeeded(), ResultLimitReached); // Allocate the memory. @@ -42,67 +40,66 @@ Result KSharedMemory::Initialize(Core::DeviceMemory& device_memory_, KProcess* o //! HACK: Open continuous mapping from sysmodule pool. auto option = KMemoryManager::EncodeOption(KMemoryManager::Pool::Secure, KMemoryManager::Direction::FromBack); - physical_address = kernel.MemoryManager().AllocateAndOpenContinuous(num_pages, 1, option); - R_UNLESS(physical_address != 0, ResultOutOfMemory); + m_physical_address = m_kernel.MemoryManager().AllocateAndOpenContinuous(num_pages, 1, option); + R_UNLESS(m_physical_address != 0, ResultOutOfMemory); //! Insert the result into our page group. - page_group.emplace(kernel, &kernel.GetSystemSystemResource().GetBlockInfoManager()); - page_group->AddBlock(physical_address, num_pages); + m_page_group.emplace(m_kernel, + std::addressof(m_kernel.GetSystemSystemResource().GetBlockInfoManager())); + m_page_group->AddBlock(m_physical_address, num_pages); // Commit our reservation. memory_reservation.Commit(); // Set our resource limit. - resource_limit = reslimit; - resource_limit->Open(); + m_resource_limit = reslimit; + m_resource_limit->Open(); // Mark initialized. - is_initialized = true; + m_is_initialized = true; // Clear all pages in the memory. - for (const auto& block : *page_group) { - std::memset(device_memory_.GetPointer<void>(block.GetAddress()), 0, block.GetSize()); + for (const auto& block : *m_page_group) { + std::memset(m_device_memory->GetPointer<void>(block.GetAddress()), 0, block.GetSize()); } - return ResultSuccess; + R_SUCCEED(); } void KSharedMemory::Finalize() { // Close and finalize the page group. - page_group->Close(); - page_group->Finalize(); + m_page_group->Close(); + m_page_group->Finalize(); // Release the memory reservation. - resource_limit->Release(LimitableResource::PhysicalMemoryMax, size); - resource_limit->Close(); - - // Perform inherited finalization. - KAutoObjectWithSlabHeapAndContainer<KSharedMemory, KAutoObjectWithList>::Finalize(); + m_resource_limit->Release(LimitableResource::PhysicalMemoryMax, m_size); + m_resource_limit->Close(); } Result KSharedMemory::Map(KProcess& target_process, VAddr address, std::size_t map_size, Svc::MemoryPermission map_perm) { // Validate the size. - R_UNLESS(size == map_size, ResultInvalidSize); + R_UNLESS(m_size == map_size, ResultInvalidSize); // Validate the permission. const Svc::MemoryPermission test_perm = - &target_process == owner_process ? owner_permission : user_permission; + std::addressof(target_process) == m_owner_process ? m_owner_permission : m_user_permission; if (test_perm == Svc::MemoryPermission::DontCare) { ASSERT(map_perm == Svc::MemoryPermission::Read || map_perm == Svc::MemoryPermission::Write); } else { R_UNLESS(map_perm == test_perm, ResultInvalidNewMemoryPermission); } - return target_process.PageTable().MapPageGroup(address, *page_group, KMemoryState::Shared, - ConvertToKMemoryPermission(map_perm)); + R_RETURN(target_process.PageTable().MapPageGroup(address, *m_page_group, KMemoryState::Shared, + ConvertToKMemoryPermission(map_perm))); } Result KSharedMemory::Unmap(KProcess& target_process, VAddr address, std::size_t unmap_size) { // Validate the size. - R_UNLESS(size == unmap_size, ResultInvalidSize); + R_UNLESS(m_size == unmap_size, ResultInvalidSize); - return target_process.PageTable().UnmapPageGroup(address, *page_group, KMemoryState::Shared); + R_RETURN( + target_process.PageTable().UnmapPageGroup(address, *m_page_group, KMemoryState::Shared)); } } // namespace Kernel diff --git a/src/core/hle/kernel/k_shared_memory.h b/src/core/hle/kernel/k_shared_memory.h index 8b29f0b4a..b4c4125bb 100644 --- a/src/core/hle/kernel/k_shared_memory.h +++ b/src/core/hle/kernel/k_shared_memory.h @@ -23,12 +23,12 @@ class KSharedMemory final KERNEL_AUTOOBJECT_TRAITS(KSharedMemory, KAutoObject); public: - explicit KSharedMemory(KernelCore& kernel_); + explicit KSharedMemory(KernelCore& kernel); ~KSharedMemory() override; Result Initialize(Core::DeviceMemory& device_memory_, KProcess* owner_process_, Svc::MemoryPermission owner_permission_, - Svc::MemoryPermission user_permission_, std::size_t size_, std::string name_); + Svc::MemoryPermission user_permission_, std::size_t size_); /** * Maps a shared memory block to an address in the target process' address space @@ -54,7 +54,7 @@ public: * @return A pointer to the shared memory block from the specified offset */ u8* GetPointer(std::size_t offset = 0) { - return device_memory->GetPointer<u8>(physical_address + offset); + return m_device_memory->GetPointer<u8>(m_physical_address + offset); } /** @@ -63,26 +63,26 @@ public: * @return A pointer to the shared memory block from the specified offset */ const u8* GetPointer(std::size_t offset = 0) const { - return device_memory->GetPointer<u8>(physical_address + offset); + return m_device_memory->GetPointer<u8>(m_physical_address + offset); } void Finalize() override; bool IsInitialized() const override { - return is_initialized; + return m_is_initialized; } - static void PostDestroy([[maybe_unused]] uintptr_t arg) {} + static void PostDestroy(uintptr_t arg) {} private: - Core::DeviceMemory* device_memory{}; - KProcess* owner_process{}; - std::optional<KPageGroup> page_group{}; - Svc::MemoryPermission owner_permission{}; - Svc::MemoryPermission user_permission{}; - PAddr physical_address{}; - std::size_t size{}; - KResourceLimit* resource_limit{}; - bool is_initialized{}; + Core::DeviceMemory* m_device_memory{}; + KProcess* m_owner_process{}; + std::optional<KPageGroup> m_page_group{}; + Svc::MemoryPermission m_owner_permission{}; + Svc::MemoryPermission m_user_permission{}; + PAddr m_physical_address{}; + std::size_t m_size{}; + KResourceLimit* m_resource_limit{}; + bool m_is_initialized{}; }; } // namespace Kernel diff --git a/src/core/hle/kernel/k_shared_memory_info.h b/src/core/hle/kernel/k_shared_memory_info.h index 2bb6b6d08..75b73ba39 100644 --- a/src/core/hle/kernel/k_shared_memory_info.h +++ b/src/core/hle/kernel/k_shared_memory_info.h @@ -18,25 +18,28 @@ public: explicit KSharedMemoryInfo(KernelCore&) {} KSharedMemoryInfo() = default; - constexpr void Initialize(KSharedMemory* shmem) { - shared_memory = shmem; + constexpr void Initialize(KSharedMemory* m) { + m_shared_memory = m; + m_reference_count = 0; } constexpr KSharedMemory* GetSharedMemory() const { - return shared_memory; + return m_shared_memory; } constexpr void Open() { - ++reference_count; + ++m_reference_count; + ASSERT(m_reference_count > 0); } constexpr bool Close() { - return (--reference_count) == 0; + ASSERT(m_reference_count > 0); + return (--m_reference_count) == 0; } private: - KSharedMemory* shared_memory{}; - size_t reference_count{}; + KSharedMemory* m_shared_memory{}; + size_t m_reference_count{}; }; } // namespace Kernel diff --git a/src/core/hle/kernel/k_slab_heap.h b/src/core/hle/kernel/k_slab_heap.h index 68469b041..334afebb7 100644 --- a/src/core/hle/kernel/k_slab_heap.h +++ b/src/core/hle/kernel/k_slab_heap.h @@ -89,7 +89,8 @@ private: if (alloc_peak <= cur_peak) { break; } - } while (!Common::AtomicCompareAndSwap(&m_peak, alloc_peak, cur_peak, cur_peak)); + } while ( + !Common::AtomicCompareAndSwap(std::addressof(m_peak), alloc_peak, cur_peak, cur_peak)); } public: diff --git a/src/core/hle/kernel/k_spin_lock.cpp b/src/core/hle/kernel/k_spin_lock.cpp index 6e16a1849..852532037 100644 --- a/src/core/hle/kernel/k_spin_lock.cpp +++ b/src/core/hle/kernel/k_spin_lock.cpp @@ -6,15 +6,15 @@ namespace Kernel { void KSpinLock::Lock() { - lck.lock(); + m_lock.lock(); } void KSpinLock::Unlock() { - lck.unlock(); + m_lock.unlock(); } bool KSpinLock::TryLock() { - return lck.try_lock(); + return m_lock.try_lock(); } } // namespace Kernel diff --git a/src/core/hle/kernel/k_spin_lock.h b/src/core/hle/kernel/k_spin_lock.h index 397a93d21..094a1e6be 100644 --- a/src/core/hle/kernel/k_spin_lock.h +++ b/src/core/hle/kernel/k_spin_lock.h @@ -5,26 +5,24 @@ #include <mutex> +#include "common/common_funcs.h" #include "core/hle/kernel/k_scoped_lock.h" namespace Kernel { class KSpinLock { public: - KSpinLock() = default; + explicit KSpinLock() = default; - KSpinLock(const KSpinLock&) = delete; - KSpinLock& operator=(const KSpinLock&) = delete; - - KSpinLock(KSpinLock&&) = delete; - KSpinLock& operator=(KSpinLock&&) = delete; + YUZU_NON_COPYABLE(KSpinLock); + YUZU_NON_MOVEABLE(KSpinLock); void Lock(); void Unlock(); - [[nodiscard]] bool TryLock(); + bool TryLock(); private: - std::mutex lck; + std::mutex m_lock; }; // TODO(bunnei): Alias for now, in case we want to implement these accurately in the future. diff --git a/src/core/hle/kernel/k_synchronization_object.cpp b/src/core/hle/kernel/k_synchronization_object.cpp index 802dca046..b7da3eee7 100644 --- a/src/core/hle/kernel/k_synchronization_object.cpp +++ b/src/core/hle/kernel/k_synchronization_object.cpp @@ -17,9 +17,9 @@ namespace { class ThreadQueueImplForKSynchronizationObjectWait final : public KThreadQueueWithoutEndWait { public: - ThreadQueueImplForKSynchronizationObjectWait(KernelCore& kernel_, KSynchronizationObject** o, + ThreadQueueImplForKSynchronizationObjectWait(KernelCore& kernel, KSynchronizationObject** o, KSynchronizationObject::ThreadListNode* n, s32 c) - : KThreadQueueWithoutEndWait(kernel_), m_objects(o), m_nodes(n), m_count(c) {} + : KThreadQueueWithoutEndWait(kernel), m_objects(o), m_nodes(n), m_count(c) {} void NotifyAvailable(KThread* waiting_thread, KSynchronizationObject* signaled_object, Result wait_result) override { @@ -71,25 +71,26 @@ void KSynchronizationObject::Finalize() { KAutoObject::Finalize(); } -Result KSynchronizationObject::Wait(KernelCore& kernel_ctx, s32* out_index, +Result KSynchronizationObject::Wait(KernelCore& kernel, s32* out_index, KSynchronizationObject** objects, const s32 num_objects, s64 timeout) { // Allocate space on stack for thread nodes. std::vector<ThreadListNode> thread_nodes(num_objects); // Prepare for wait. - KThread* thread = GetCurrentThreadPointer(kernel_ctx); - ThreadQueueImplForKSynchronizationObjectWait wait_queue(kernel_ctx, objects, - thread_nodes.data(), num_objects); + KThread* thread = GetCurrentThreadPointer(kernel); + KHardwareTimer* timer{}; + ThreadQueueImplForKSynchronizationObjectWait wait_queue(kernel, objects, thread_nodes.data(), + num_objects); { // Setup the scheduling lock and sleep. - KScopedSchedulerLockAndSleep slp(kernel_ctx, thread, timeout); + KScopedSchedulerLockAndSleep slp(kernel, std::addressof(timer), thread, timeout); // Check if the thread should terminate. if (thread->IsTerminationRequested()) { slp.CancelSleep(); - return ResultTerminationRequested; + R_THROW(ResultTerminationRequested); } // Check if any of the objects are already signaled. @@ -99,21 +100,21 @@ Result KSynchronizationObject::Wait(KernelCore& kernel_ctx, s32* out_index, if (objects[i]->IsSignaled()) { *out_index = i; slp.CancelSleep(); - return ResultSuccess; + R_THROW(ResultSuccess); } } // Check if the timeout is zero. if (timeout == 0) { slp.CancelSleep(); - return ResultTimedOut; + R_THROW(ResultTimedOut); } // Check if waiting was canceled. if (thread->IsWaitCancelled()) { slp.CancelSleep(); thread->ClearWaitCancelled(); - return ResultCancelled; + R_THROW(ResultCancelled); } // Add the waiters. @@ -131,6 +132,7 @@ Result KSynchronizationObject::Wait(KernelCore& kernel_ctx, s32* out_index, thread->SetSyncedIndex(-1); // Wait for an object to be signaled. + wait_queue.SetHardwareTimer(timer); thread->BeginWait(std::addressof(wait_queue)); thread->SetWaitReasonForDebugging(ThreadWaitReasonForDebugging::Synchronization); } @@ -139,16 +141,15 @@ Result KSynchronizationObject::Wait(KernelCore& kernel_ctx, s32* out_index, *out_index = thread->GetSyncedIndex(); // Get the wait result. - return thread->GetWaitResult(); + R_RETURN(thread->GetWaitResult()); } -KSynchronizationObject::KSynchronizationObject(KernelCore& kernel_) - : KAutoObjectWithList{kernel_} {} +KSynchronizationObject::KSynchronizationObject(KernelCore& kernel) : KAutoObjectWithList{kernel} {} KSynchronizationObject::~KSynchronizationObject() = default; void KSynchronizationObject::NotifyAvailable(Result result) { - KScopedSchedulerLock sl(kernel); + KScopedSchedulerLock sl(m_kernel); // If we're not signaled, we've nothing to notify. if (!this->IsSignaled()) { @@ -156,7 +157,7 @@ void KSynchronizationObject::NotifyAvailable(Result result) { } // Iterate over each thread. - for (auto* cur_node = thread_list_head; cur_node != nullptr; cur_node = cur_node->next) { + for (auto* cur_node = m_thread_list_head; cur_node != nullptr; cur_node = cur_node->next) { cur_node->thread->NotifyAvailable(this, result); } } @@ -166,8 +167,8 @@ std::vector<KThread*> KSynchronizationObject::GetWaitingThreadsForDebugging() co // If debugging, dump the list of waiters. { - KScopedSchedulerLock lock(kernel); - for (auto* cur_node = thread_list_head; cur_node != nullptr; cur_node = cur_node->next) { + KScopedSchedulerLock lock(m_kernel); + for (auto* cur_node = m_thread_list_head; cur_node != nullptr; cur_node = cur_node->next) { threads.emplace_back(cur_node->thread); } } diff --git a/src/core/hle/kernel/k_synchronization_object.h b/src/core/hle/kernel/k_synchronization_object.h index 8d8122ab7..d55a2673d 100644 --- a/src/core/hle/kernel/k_synchronization_object.h +++ b/src/core/hle/kernel/k_synchronization_object.h @@ -24,31 +24,30 @@ public: KThread* thread{}; }; - [[nodiscard]] static Result Wait(KernelCore& kernel, s32* out_index, - KSynchronizationObject** objects, const s32 num_objects, - s64 timeout); + static Result Wait(KernelCore& kernel, s32* out_index, KSynchronizationObject** objects, + const s32 num_objects, s64 timeout); void Finalize() override; - [[nodiscard]] virtual bool IsSignaled() const = 0; + virtual bool IsSignaled() const = 0; - [[nodiscard]] std::vector<KThread*> GetWaitingThreadsForDebugging() const; + std::vector<KThread*> GetWaitingThreadsForDebugging() const; void LinkNode(ThreadListNode* node_) { // Link the node to the list. - if (thread_list_tail == nullptr) { - thread_list_head = node_; + if (m_thread_list_tail == nullptr) { + m_thread_list_head = node_; } else { - thread_list_tail->next = node_; + m_thread_list_tail->next = node_; } - thread_list_tail = node_; + m_thread_list_tail = node_; } void UnlinkNode(ThreadListNode* node_) { // Unlink the node from the list. ThreadListNode* prev_ptr = - reinterpret_cast<ThreadListNode*>(std::addressof(thread_list_head)); + reinterpret_cast<ThreadListNode*>(std::addressof(m_thread_list_head)); ThreadListNode* prev_val = nullptr; ThreadListNode *prev, *tail_prev; @@ -59,8 +58,8 @@ public: prev_val = prev_ptr; } while (prev_ptr != node_); - if (thread_list_tail == node_) { - thread_list_tail = tail_prev; + if (m_thread_list_tail == node_) { + m_thread_list_tail = tail_prev; } prev->next = node_->next; @@ -78,8 +77,8 @@ protected: } private: - ThreadListNode* thread_list_head{}; - ThreadListNode* thread_list_tail{}; + ThreadListNode* m_thread_list_head{}; + ThreadListNode* m_thread_list_tail{}; }; } // namespace Kernel diff --git a/src/core/hle/kernel/k_system_resource.cpp b/src/core/hle/kernel/k_system_resource.cpp index 4cc377a6c..e6c8d589a 100644 --- a/src/core/hle/kernel/k_system_resource.cpp +++ b/src/core/hle/kernel/k_system_resource.cpp @@ -5,9 +5,8 @@ namespace Kernel { -Result KSecureSystemResource::Initialize([[maybe_unused]] size_t size, - [[maybe_unused]] KResourceLimit* resource_limit, - [[maybe_unused]] KMemoryManager::Pool pool) { +Result KSecureSystemResource::Initialize(size_t size, KResourceLimit* resource_limit, + KMemoryManager::Pool pool) { // Unimplemented UNREACHABLE(); } @@ -17,8 +16,8 @@ void KSecureSystemResource::Finalize() { UNREACHABLE(); } -size_t KSecureSystemResource::CalculateRequiredSecureMemorySize( - [[maybe_unused]] size_t size, [[maybe_unused]] KMemoryManager::Pool pool) { +size_t KSecureSystemResource::CalculateRequiredSecureMemorySize(size_t size, + KMemoryManager::Pool pool) { // Unimplemented UNREACHABLE(); } diff --git a/src/core/hle/kernel/k_system_resource.h b/src/core/hle/kernel/k_system_resource.h index 9a991f725..d36aaa9bd 100644 --- a/src/core/hle/kernel/k_system_resource.h +++ b/src/core/hle/kernel/k_system_resource.h @@ -21,7 +21,7 @@ class KSystemResource : public KAutoObject { KERNEL_AUTOOBJECT_TRAITS(KSystemResource, KAutoObject); public: - explicit KSystemResource(KernelCore& kernel_) : KAutoObject(kernel_) {} + explicit KSystemResource(KernelCore& kernel) : KAutoObject(kernel) {} protected: void SetSecureResource() { @@ -87,8 +87,8 @@ private: class KSecureSystemResource final : public KAutoObjectWithSlabHeap<KSecureSystemResource, KSystemResource> { public: - explicit KSecureSystemResource(KernelCore& kernel_) - : KAutoObjectWithSlabHeap<KSecureSystemResource, KSystemResource>(kernel_) { + explicit KSecureSystemResource(KernelCore& kernel) + : KAutoObjectWithSlabHeap<KSecureSystemResource, KSystemResource>(kernel) { // Mark ourselves as being a secure resource. this->SetSecureResource(); } @@ -99,7 +99,7 @@ public: bool IsInitialized() const { return m_is_initialized; } - static void PostDestroy([[maybe_unused]] uintptr_t arg) {} + static void PostDestroy(uintptr_t arg) {} size_t CalculateRequiredSecureMemorySize() const { return CalculateRequiredSecureMemorySize(m_resource_size, m_resource_pool); diff --git a/src/core/hle/kernel/k_thread.cpp b/src/core/hle/kernel/k_thread.cpp index 8c403f5fd..c0e3ecb45 100644 --- a/src/core/hle/kernel/k_thread.cpp +++ b/src/core/hle/kernel/k_thread.cpp @@ -35,31 +35,28 @@ #include "core/hle/result.h" #include "core/memory.h" -#ifdef ARCHITECTURE_x86_64 -#include "core/arm/dynarmic/arm_dynarmic_32.h" -#endif - namespace { constexpr inline s32 TerminatingThreadPriority = Kernel::Svc::SystemThreadPriorityHighest - 1; -static void ResetThreadContext32(Core::ARM_Interface::ThreadContext32& context, u32 stack_top, +static void ResetThreadContext32(Kernel::KThread::ThreadContext32& context, u32 stack_top, u32 entry_point, u32 arg) { context = {}; context.cpu_registers[0] = arg; context.cpu_registers[15] = entry_point; context.cpu_registers[13] = stack_top; + context.fpscr = 0; } -static void ResetThreadContext64(Core::ARM_Interface::ThreadContext64& context, VAddr stack_top, +static void ResetThreadContext64(Kernel::KThread::ThreadContext64& context, VAddr stack_top, VAddr entry_point, u64 arg) { context = {}; context.cpu_registers[0] = arg; context.cpu_registers[18] = Kernel::KSystemControl::GenerateRandomU64() | 1; context.pc = entry_point; context.sp = stack_top; - // TODO(merry): Perform a hardware test to determine the below value. context.fpcr = 0; + context.fpsr = 0; } } // namespace @@ -76,14 +73,14 @@ struct ThreadLocalRegion { class ThreadQueueImplForKThreadSleep final : public KThreadQueueWithoutEndWait { public: - explicit ThreadQueueImplForKThreadSleep(KernelCore& kernel_) - : KThreadQueueWithoutEndWait(kernel_) {} + explicit ThreadQueueImplForKThreadSleep(KernelCore& kernel) + : KThreadQueueWithoutEndWait(kernel) {} }; class ThreadQueueImplForKThreadSetProperty final : public KThreadQueue { public: - explicit ThreadQueueImplForKThreadSetProperty(KernelCore& kernel_, KThread::WaiterList* wl) - : KThreadQueue(kernel_), m_wait_list(wl) {} + explicit ThreadQueueImplForKThreadSetProperty(KernelCore& kernel, KThread::WaiterList* wl) + : KThreadQueue(kernel), m_wait_list(wl) {} void CancelWait(KThread* waiting_thread, Result wait_result, bool cancel_timer_task) override { // Remove the thread from the wait list. @@ -94,13 +91,13 @@ public: } private: - KThread::WaiterList* m_wait_list; + KThread::WaiterList* m_wait_list{}; }; } // namespace -KThread::KThread(KernelCore& kernel_) - : KAutoObjectWithSlabHeapAndContainer{kernel_}, activity_pause_lock{kernel_} {} +KThread::KThread(KernelCore& kernel) + : KAutoObjectWithSlabHeapAndContainer{kernel}, m_activity_pause_lock{kernel} {} KThread::~KThread() = default; Result KThread::Initialize(KThreadFunction func, uintptr_t arg, VAddr user_stack_top, s32 prio, @@ -116,7 +113,7 @@ Result KThread::Initialize(KThreadFunction func, uintptr_t arg, VAddr user_stack ASSERT(0 <= phys_core && phys_core < static_cast<s32>(Core::Hardware::NUM_CPU_CORES)); // First, clear the TLS address. - tls_address = {}; + m_tls_address = {}; // Next, assert things based on the type. switch (type) { @@ -140,110 +137,110 @@ Result KThread::Initialize(KThreadFunction func, uintptr_t arg, VAddr user_stack ASSERT_MSG(false, "KThread::Initialize: Unknown ThreadType {}", static_cast<u32>(type)); break; } - thread_type = type; + m_thread_type = type; // Set the ideal core ID and affinity mask. - virtual_ideal_core_id = virt_core; - physical_ideal_core_id = phys_core; - virtual_affinity_mask = 1ULL << virt_core; - physical_affinity_mask.SetAffinity(phys_core, true); + m_virtual_ideal_core_id = virt_core; + m_physical_ideal_core_id = phys_core; + m_virtual_affinity_mask = 1ULL << virt_core; + m_physical_affinity_mask.SetAffinity(phys_core, true); // Set the thread state. - thread_state = (type == ThreadType::Main || type == ThreadType::Dummy) - ? ThreadState::Runnable - : ThreadState::Initialized; + m_thread_state = (type == ThreadType::Main || type == ThreadType::Dummy) + ? ThreadState::Runnable + : ThreadState::Initialized; // Set TLS address. - tls_address = 0; + m_tls_address = 0; // Set parent and condvar tree. - parent = nullptr; - condvar_tree = nullptr; + m_parent = nullptr; + m_condvar_tree = nullptr; // Set sync booleans. - signaled = false; - termination_requested = false; - wait_cancelled = false; - cancellable = false; + m_signaled = false; + m_termination_requested = false; + m_wait_cancelled = false; + m_cancellable = false; // Set core ID and wait result. - core_id = phys_core; - wait_result = ResultNoSynchronizationObject; + m_core_id = phys_core; + m_wait_result = ResultNoSynchronizationObject; // Set priorities. - priority = prio; - base_priority = prio; + m_priority = prio; + m_base_priority = prio; // Initialize sleeping queue. - wait_queue = nullptr; + m_wait_queue = nullptr; // Set suspend flags. - suspend_request_flags = 0; - suspend_allowed_flags = static_cast<u32>(ThreadState::SuspendFlagMask); + m_suspend_request_flags = 0; + m_suspend_allowed_flags = static_cast<u32>(ThreadState::SuspendFlagMask); // We're neither debug attached, nor are we nesting our priority inheritance. - debug_attached = false; - priority_inheritance_count = 0; + m_debug_attached = false; + m_priority_inheritance_count = 0; // We haven't been scheduled, and we have done no light IPC. - schedule_count = -1; - last_scheduled_tick = 0; - light_ipc_data = nullptr; + m_schedule_count = -1; + m_last_scheduled_tick = 0; + m_light_ipc_data = nullptr; // We're not waiting for a lock, and we haven't disabled migration. - waiting_lock_info = nullptr; - num_core_migration_disables = 0; + m_waiting_lock_info = nullptr; + m_num_core_migration_disables = 0; // We have no waiters, but we do have an entrypoint. - num_kernel_waiters = 0; + m_num_kernel_waiters = 0; // Set our current core id. - current_core_id = phys_core; + m_current_core_id = phys_core; // We haven't released our resource limit hint, and we've spent no time on the cpu. - resource_limit_release_hint = false; - cpu_time = 0; + m_resource_limit_release_hint = false; + m_cpu_time = 0; // Set debug context. - stack_top = user_stack_top; - argument = arg; + m_stack_top = user_stack_top; + m_argument = arg; // Clear our stack parameters. - std::memset(static_cast<void*>(std::addressof(GetStackParameters())), 0, + std::memset(static_cast<void*>(std::addressof(this->GetStackParameters())), 0, sizeof(StackParameters)); // Set parent, if relevant. if (owner != nullptr) { // Setup the TLS, if needed. if (type == ThreadType::User) { - R_TRY(owner->CreateThreadLocalRegion(std::addressof(tls_address))); + R_TRY(owner->CreateThreadLocalRegion(std::addressof(m_tls_address))); } - parent = owner; - parent->Open(); + m_parent = owner; + m_parent->Open(); } // Initialize thread context. - ResetThreadContext64(thread_context_64, user_stack_top, func, arg); - ResetThreadContext32(thread_context_32, static_cast<u32>(user_stack_top), + ResetThreadContext64(m_thread_context_64, user_stack_top, func, arg); + ResetThreadContext32(m_thread_context_32, static_cast<u32>(user_stack_top), static_cast<u32>(func), static_cast<u32>(arg)); // Setup the stack parameters. - StackParameters& sp = GetStackParameters(); + StackParameters& sp = this->GetStackParameters(); sp.cur_thread = this; sp.disable_count = 1; - SetInExceptionHandler(); + this->SetInExceptionHandler(); // Set thread ID. - thread_id = kernel.CreateNewThreadID(); + m_thread_id = m_kernel.CreateNewThreadID(); // We initialized! - initialized = true; + m_initialized = true; // Register ourselves with our parent process. - if (parent != nullptr) { - parent->RegisterThread(this); - if (parent->IsSuspended()) { + if (m_parent != nullptr) { + m_parent->RegisterThread(this); + if (m_parent->IsSuspended()) { RequestSuspend(SuspendType::Process); } } @@ -258,8 +255,7 @@ Result KThread::InitializeThread(KThread* thread, KThreadFunction func, uintptr_ R_TRY(thread->Initialize(func, arg, user_stack_top, prio, core, owner, type)); // Initialize emulation parameters. - thread->host_context = std::make_shared<Common::Fiber>(std::move(init_func)); - thread->is_single_core = !Settings::values.use_multi_core.GetValue(); + thread->m_host_context = std::make_shared<Common::Fiber>(std::move(init_func)); R_SUCCEED(); } @@ -269,7 +265,7 @@ Result KThread::InitializeDummyThread(KThread* thread, KProcess* owner) { R_TRY(thread->Initialize({}, {}, {}, DummyThreadPriority, 3, owner, ThreadType::Dummy)); // Initialize emulation parameters. - thread->stack_parameters.disable_count = 0; + thread->m_stack_parameters.disable_count = 0; R_SUCCEED(); } @@ -330,25 +326,25 @@ void KThread::PostDestroy(uintptr_t arg) { void KThread::Finalize() { // If the thread has an owner process, unregister it. - if (parent != nullptr) { - parent->UnregisterThread(this); + if (m_parent != nullptr) { + m_parent->UnregisterThread(this); } // If the thread has a local region, delete it. - if (tls_address != 0) { - ASSERT(parent->DeleteThreadLocalRegion(tls_address).IsSuccess()); + if (m_tls_address != 0) { + ASSERT(m_parent->DeleteThreadLocalRegion(m_tls_address).IsSuccess()); } // Release any waiters. { - ASSERT(waiting_lock_info == nullptr); - KScopedSchedulerLock sl{kernel}; + ASSERT(m_waiting_lock_info == nullptr); + KScopedSchedulerLock sl{m_kernel}; // Check that we have no kernel waiters. - ASSERT(num_kernel_waiters == 0); + ASSERT(m_num_kernel_waiters == 0); - auto it = held_lock_info_list.begin(); - while (it != held_lock_info_list.end()) { + auto it = m_held_lock_info_list.begin(); + while (it != m_held_lock_info_list.end()) { // Get the lock info. auto* const lock_info = std::addressof(*it); @@ -370,70 +366,70 @@ void KThread::Finalize() { } // Remove the held lock from our list. - it = held_lock_info_list.erase(it); + it = m_held_lock_info_list.erase(it); // Free the lock info. - LockWithPriorityInheritanceInfo::Free(kernel, lock_info); + LockWithPriorityInheritanceInfo::Free(m_kernel, lock_info); } } // Release host emulation members. - host_context.reset(); + m_host_context.reset(); // Perform inherited finalization. KSynchronizationObject::Finalize(); } bool KThread::IsSignaled() const { - return signaled; + return m_signaled; } void KThread::OnTimer() { - ASSERT(kernel.GlobalSchedulerContext().IsLocked()); + ASSERT(KScheduler::IsSchedulerLockedByCurrentThread(m_kernel)); // If we're waiting, cancel the wait. - if (GetState() == ThreadState::Waiting) { - wait_queue->CancelWait(this, ResultTimedOut, false); + if (this->GetState() == ThreadState::Waiting) { + m_wait_queue->CancelWait(this, ResultTimedOut, false); } } void KThread::StartTermination() { - ASSERT(kernel.GlobalSchedulerContext().IsLocked()); + ASSERT(KScheduler::IsSchedulerLockedByCurrentThread(m_kernel)); // Release user exception and unpin, if relevant. - if (parent != nullptr) { - parent->ReleaseUserException(this); - if (parent->GetPinnedThread(GetCurrentCoreId(kernel)) == this) { - parent->UnpinCurrentThread(core_id); + if (m_parent != nullptr) { + m_parent->ReleaseUserException(this); + if (m_parent->GetPinnedThread(GetCurrentCoreId(m_kernel)) == this) { + m_parent->UnpinCurrentThread(m_core_id); } } // Set state to terminated. - SetState(ThreadState::Terminated); + this->SetState(ThreadState::Terminated); // Clear the thread's status as running in parent. - if (parent != nullptr) { - parent->ClearRunningThread(this); + if (m_parent != nullptr) { + m_parent->ClearRunningThread(this); } // Signal. - signaled = true; + m_signaled = true; KSynchronizationObject::NotifyAvailable(); // Clear previous thread in KScheduler. - KScheduler::ClearPreviousThread(kernel, this); + KScheduler::ClearPreviousThread(m_kernel, this); // Register terminated dpc flag. - RegisterDpc(DpcFlag::Terminated); + this->RegisterDpc(DpcFlag::Terminated); } void KThread::FinishTermination() { // Ensure that the thread is not executing on any core. - if (parent != nullptr) { + if (m_parent != nullptr) { for (std::size_t i = 0; i < static_cast<std::size_t>(Core::Hardware::NUM_CPU_CORES); ++i) { KThread* core_thread{}; do { - core_thread = kernel.Scheduler(i).GetSchedulerCurrentThread(); + core_thread = m_kernel.Scheduler(i).GetSchedulerCurrentThread(); } while (core_thread == this); } } @@ -448,182 +444,183 @@ void KThread::DoWorkerTaskImpl() { } void KThread::Pin(s32 current_core) { - ASSERT(kernel.GlobalSchedulerContext().IsLocked()); + ASSERT(KScheduler::IsSchedulerLockedByCurrentThread(m_kernel)); // Set ourselves as pinned. GetStackParameters().is_pinned = true; // Disable core migration. - ASSERT(num_core_migration_disables == 0); + ASSERT(m_num_core_migration_disables == 0); { - ++num_core_migration_disables; + ++m_num_core_migration_disables; // Save our ideal state to restore when we're unpinned. - original_physical_ideal_core_id = physical_ideal_core_id; - original_physical_affinity_mask = physical_affinity_mask; + m_original_physical_ideal_core_id = m_physical_ideal_core_id; + m_original_physical_affinity_mask = m_physical_affinity_mask; // Bind ourselves to this core. - const s32 active_core = GetActiveCore(); + const s32 active_core = this->GetActiveCore(); - SetActiveCore(current_core); - physical_ideal_core_id = current_core; - physical_affinity_mask.SetAffinityMask(1ULL << current_core); + this->SetActiveCore(current_core); + m_physical_ideal_core_id = current_core; + m_physical_affinity_mask.SetAffinityMask(1ULL << current_core); - if (active_core != current_core || physical_affinity_mask.GetAffinityMask() != - original_physical_affinity_mask.GetAffinityMask()) { - KScheduler::OnThreadAffinityMaskChanged(kernel, this, original_physical_affinity_mask, - active_core); + if (active_core != current_core || + m_physical_affinity_mask.GetAffinityMask() != + m_original_physical_affinity_mask.GetAffinityMask()) { + KScheduler::OnThreadAffinityMaskChanged(m_kernel, this, + m_original_physical_affinity_mask, active_core); } } // Disallow performing thread suspension. { // Update our allow flags. - suspend_allowed_flags &= ~(1 << (static_cast<u32>(SuspendType::Thread) + - static_cast<u32>(ThreadState::SuspendShift))); + m_suspend_allowed_flags &= ~(1 << (static_cast<u32>(SuspendType::Thread) + + static_cast<u32>(ThreadState::SuspendShift))); // Update our state. - UpdateState(); + this->UpdateState(); } // TODO(bunnei): Update our SVC access permissions. - ASSERT(parent != nullptr); + ASSERT(m_parent != nullptr); } void KThread::Unpin() { - ASSERT(kernel.GlobalSchedulerContext().IsLocked()); + ASSERT(KScheduler::IsSchedulerLockedByCurrentThread(m_kernel)); // Set ourselves as unpinned. - GetStackParameters().is_pinned = false; + this->GetStackParameters().is_pinned = false; // Enable core migration. - ASSERT(num_core_migration_disables == 1); + ASSERT(m_num_core_migration_disables == 1); { - num_core_migration_disables--; + m_num_core_migration_disables--; // Restore our original state. - const KAffinityMask old_mask = physical_affinity_mask; + const KAffinityMask old_mask = m_physical_affinity_mask; - physical_ideal_core_id = original_physical_ideal_core_id; - physical_affinity_mask = original_physical_affinity_mask; + m_physical_ideal_core_id = m_original_physical_ideal_core_id; + m_physical_affinity_mask = m_original_physical_affinity_mask; - if (physical_affinity_mask.GetAffinityMask() != old_mask.GetAffinityMask()) { - const s32 active_core = GetActiveCore(); + if (m_physical_affinity_mask.GetAffinityMask() != old_mask.GetAffinityMask()) { + const s32 active_core = this->GetActiveCore(); - if (!physical_affinity_mask.GetAffinity(active_core)) { - if (physical_ideal_core_id >= 0) { - SetActiveCore(physical_ideal_core_id); + if (!m_physical_affinity_mask.GetAffinity(active_core)) { + if (m_physical_ideal_core_id >= 0) { + this->SetActiveCore(m_physical_ideal_core_id); } else { - SetActiveCore(static_cast<s32>( + this->SetActiveCore(static_cast<s32>( Common::BitSize<u64>() - 1 - - std::countl_zero(physical_affinity_mask.GetAffinityMask()))); + std::countl_zero(m_physical_affinity_mask.GetAffinityMask()))); } } - KScheduler::OnThreadAffinityMaskChanged(kernel, this, old_mask, active_core); + KScheduler::OnThreadAffinityMaskChanged(m_kernel, this, old_mask, active_core); } } // Allow performing thread suspension (if termination hasn't been requested). - if (!IsTerminationRequested()) { + if (!this->IsTerminationRequested()) { // Update our allow flags. - suspend_allowed_flags |= (1 << (static_cast<u32>(SuspendType::Thread) + - static_cast<u32>(ThreadState::SuspendShift))); + m_suspend_allowed_flags |= (1 << (static_cast<u32>(SuspendType::Thread) + + static_cast<u32>(ThreadState::SuspendShift))); // Update our state. - UpdateState(); + this->UpdateState(); } // TODO(bunnei): Update our SVC access permissions. - ASSERT(parent != nullptr); + ASSERT(m_parent != nullptr); // Resume any threads that began waiting on us while we were pinned. - for (auto it = pinned_waiter_list.begin(); it != pinned_waiter_list.end(); ++it) { + for (auto it = m_pinned_waiter_list.begin(); it != m_pinned_waiter_list.end(); ++it) { it->EndWait(ResultSuccess); } } u16 KThread::GetUserDisableCount() const { - if (!IsUserThread()) { + if (!this->IsUserThread()) { // We only emulate TLS for user threads return {}; } - auto& memory = kernel.System().Memory(); - return memory.Read16(tls_address + offsetof(ThreadLocalRegion, disable_count)); + auto& memory = m_kernel.System().Memory(); + return memory.Read16(m_tls_address + offsetof(ThreadLocalRegion, disable_count)); } void KThread::SetInterruptFlag() { - if (!IsUserThread()) { + if (!this->IsUserThread()) { // We only emulate TLS for user threads return; } - auto& memory = kernel.System().Memory(); - memory.Write16(tls_address + offsetof(ThreadLocalRegion, interrupt_flag), 1); + auto& memory = m_kernel.System().Memory(); + memory.Write16(m_tls_address + offsetof(ThreadLocalRegion, interrupt_flag), 1); } void KThread::ClearInterruptFlag() { - if (!IsUserThread()) { + if (!this->IsUserThread()) { // We only emulate TLS for user threads return; } - auto& memory = kernel.System().Memory(); - memory.Write16(tls_address + offsetof(ThreadLocalRegion, interrupt_flag), 0); + auto& memory = m_kernel.System().Memory(); + memory.Write16(m_tls_address + offsetof(ThreadLocalRegion, interrupt_flag), 0); } Result KThread::GetCoreMask(s32* out_ideal_core, u64* out_affinity_mask) { - KScopedSchedulerLock sl{kernel}; + KScopedSchedulerLock sl{m_kernel}; // Get the virtual mask. - *out_ideal_core = virtual_ideal_core_id; - *out_affinity_mask = virtual_affinity_mask; + *out_ideal_core = m_virtual_ideal_core_id; + *out_affinity_mask = m_virtual_affinity_mask; R_SUCCEED(); } Result KThread::GetPhysicalCoreMask(s32* out_ideal_core, u64* out_affinity_mask) { - KScopedSchedulerLock sl{kernel}; - ASSERT(num_core_migration_disables >= 0); + KScopedSchedulerLock sl{m_kernel}; + ASSERT(m_num_core_migration_disables >= 0); // Select between core mask and original core mask. - if (num_core_migration_disables == 0) { - *out_ideal_core = physical_ideal_core_id; - *out_affinity_mask = physical_affinity_mask.GetAffinityMask(); + if (m_num_core_migration_disables == 0) { + *out_ideal_core = m_physical_ideal_core_id; + *out_affinity_mask = m_physical_affinity_mask.GetAffinityMask(); } else { - *out_ideal_core = original_physical_ideal_core_id; - *out_affinity_mask = original_physical_affinity_mask.GetAffinityMask(); + *out_ideal_core = m_original_physical_ideal_core_id; + *out_affinity_mask = m_original_physical_affinity_mask.GetAffinityMask(); } R_SUCCEED(); } -Result KThread::SetCoreMask(s32 core_id_, u64 v_affinity_mask) { - ASSERT(parent != nullptr); +Result KThread::SetCoreMask(s32 core_id, u64 v_affinity_mask) { + ASSERT(m_parent != nullptr); ASSERT(v_affinity_mask != 0); - KScopedLightLock lk(activity_pause_lock); + KScopedLightLock lk(m_activity_pause_lock); // Set the core mask. u64 p_affinity_mask = 0; { - KScopedSchedulerLock sl(kernel); - ASSERT(num_core_migration_disables >= 0); + KScopedSchedulerLock sl(m_kernel); + ASSERT(m_num_core_migration_disables >= 0); // If we're updating, set our ideal virtual core. - if (core_id_ != Svc::IdealCoreNoUpdate) { - virtual_ideal_core_id = core_id_; + if (core_id != Svc::IdealCoreNoUpdate) { + m_virtual_ideal_core_id = core_id; } else { // Preserve our ideal core id. - core_id_ = virtual_ideal_core_id; - R_UNLESS(((1ULL << core_id_) & v_affinity_mask) != 0, ResultInvalidCombination); + core_id = m_virtual_ideal_core_id; + R_UNLESS(((1ULL << core_id) & v_affinity_mask) != 0, ResultInvalidCombination); } // Set our affinity mask. - virtual_affinity_mask = v_affinity_mask; + m_virtual_affinity_mask = v_affinity_mask; // Translate the virtual core to a physical core. - if (core_id_ >= 0) { - core_id_ = Core::Hardware::VirtualToPhysicalCoreMap[core_id_]; + if (core_id >= 0) { + core_id = Core::Hardware::VirtualToPhysicalCoreMap[core_id]; } // Translate the virtual affinity mask to a physical one. @@ -634,43 +631,43 @@ Result KThread::SetCoreMask(s32 core_id_, u64 v_affinity_mask) { } // If we haven't disabled migration, perform an affinity change. - if (num_core_migration_disables == 0) { - const KAffinityMask old_mask = physical_affinity_mask; + if (m_num_core_migration_disables == 0) { + const KAffinityMask old_mask = m_physical_affinity_mask; // Set our new ideals. - physical_ideal_core_id = core_id_; - physical_affinity_mask.SetAffinityMask(p_affinity_mask); + m_physical_ideal_core_id = core_id; + m_physical_affinity_mask.SetAffinityMask(p_affinity_mask); - if (physical_affinity_mask.GetAffinityMask() != old_mask.GetAffinityMask()) { + if (m_physical_affinity_mask.GetAffinityMask() != old_mask.GetAffinityMask()) { const s32 active_core = GetActiveCore(); - if (active_core >= 0 && !physical_affinity_mask.GetAffinity(active_core)) { + if (active_core >= 0 && !m_physical_affinity_mask.GetAffinity(active_core)) { const s32 new_core = static_cast<s32>( - physical_ideal_core_id >= 0 - ? physical_ideal_core_id + m_physical_ideal_core_id >= 0 + ? m_physical_ideal_core_id : Common::BitSize<u64>() - 1 - - std::countl_zero(physical_affinity_mask.GetAffinityMask())); + std::countl_zero(m_physical_affinity_mask.GetAffinityMask())); SetActiveCore(new_core); } - KScheduler::OnThreadAffinityMaskChanged(kernel, this, old_mask, active_core); + KScheduler::OnThreadAffinityMaskChanged(m_kernel, this, old_mask, active_core); } } else { // Otherwise, we edit the original affinity for restoration later. - original_physical_ideal_core_id = core_id_; - original_physical_affinity_mask.SetAffinityMask(p_affinity_mask); + m_original_physical_ideal_core_id = core_id; + m_original_physical_affinity_mask.SetAffinityMask(p_affinity_mask); } } // Update the pinned waiter list. - ThreadQueueImplForKThreadSetProperty wait_queue_(kernel, std::addressof(pinned_waiter_list)); + ThreadQueueImplForKThreadSetProperty wait_queue(m_kernel, std::addressof(m_pinned_waiter_list)); { bool retry_update{}; do { // Lock the scheduler. - KScopedSchedulerLock sl(kernel); + KScopedSchedulerLock sl(m_kernel); // Don't do any further management if our termination has been requested. - R_SUCCEED_IF(IsTerminationRequested()); + R_SUCCEED_IF(this->IsTerminationRequested()); // By default, we won't need to retry. retry_update = false; @@ -680,7 +677,7 @@ Result KThread::SetCoreMask(s32 core_id_, u64 v_affinity_mask) { s32 thread_core; for (thread_core = 0; thread_core < static_cast<s32>(Core::Hardware::NUM_CPU_CORES); ++thread_core) { - if (kernel.Scheduler(thread_core).GetSchedulerCurrentThread() == this) { + if (m_kernel.Scheduler(thread_core).GetSchedulerCurrentThread() == this) { thread_is_current = true; break; } @@ -690,14 +687,14 @@ Result KThread::SetCoreMask(s32 core_id_, u64 v_affinity_mask) { // new mask. if (thread_is_current && ((1ULL << thread_core) & p_affinity_mask) == 0) { // If the thread is pinned, we want to wait until it's not pinned. - if (GetStackParameters().is_pinned) { + if (this->GetStackParameters().is_pinned) { // Verify that the current thread isn't terminating. - R_UNLESS(!GetCurrentThread(kernel).IsTerminationRequested(), + R_UNLESS(!GetCurrentThread(m_kernel).IsTerminationRequested(), ResultTerminationRequested); // Wait until the thread isn't pinned any more. - pinned_waiter_list.push_back(GetCurrentThread(kernel)); - GetCurrentThread(kernel).BeginWait(std::addressof(wait_queue_)); + m_pinned_waiter_list.push_back(GetCurrentThread(m_kernel)); + GetCurrentThread(m_kernel).BeginWait(std::addressof(wait_queue)); } else { // If the thread isn't pinned, release the scheduler lock and retry until it's // not current. @@ -713,116 +710,137 @@ Result KThread::SetCoreMask(s32 core_id_, u64 v_affinity_mask) { void KThread::SetBasePriority(s32 value) { ASSERT(Svc::HighestThreadPriority <= value && value <= Svc::LowestThreadPriority); - KScopedSchedulerLock sl{kernel}; + KScopedSchedulerLock sl{m_kernel}; // Change our base priority. - base_priority = value; + m_base_priority = value; // Perform a priority restoration. - RestorePriority(kernel, this); + RestorePriority(m_kernel, this); } KThread* KThread::GetLockOwner() const { - return waiting_lock_info != nullptr ? waiting_lock_info->GetOwner() : nullptr; + return m_waiting_lock_info != nullptr ? m_waiting_lock_info->GetOwner() : nullptr; } -void KThread::IncreaseBasePriority(s32 priority_) { - ASSERT(Svc::HighestThreadPriority <= priority_ && priority_ <= Svc::LowestThreadPriority); - ASSERT(KScheduler::IsSchedulerLockedByCurrentThread(kernel)); +void KThread::IncreaseBasePriority(s32 priority) { + ASSERT(Svc::HighestThreadPriority <= priority && priority <= Svc::LowestThreadPriority); + ASSERT(KScheduler::IsSchedulerLockedByCurrentThread(m_kernel)); ASSERT(!this->GetStackParameters().is_pinned); // Set our base priority. - if (base_priority > priority_) { - base_priority = priority_; + if (m_base_priority > priority) { + m_base_priority = priority; // Perform a priority restoration. - RestorePriority(kernel, this); + RestorePriority(m_kernel, this); } } void KThread::RequestSuspend(SuspendType type) { - KScopedSchedulerLock sl{kernel}; + KScopedSchedulerLock sl{m_kernel}; // Note the request in our flags. - suspend_request_flags |= - (1u << (static_cast<u32>(ThreadState::SuspendShift) + static_cast<u32>(type))); + m_suspend_request_flags |= + (1U << (static_cast<u32>(ThreadState::SuspendShift) + static_cast<u32>(type))); // Try to perform the suspend. - TrySuspend(); + this->TrySuspend(); } void KThread::Resume(SuspendType type) { - KScopedSchedulerLock sl{kernel}; + KScopedSchedulerLock sl{m_kernel}; // Clear the request in our flags. - suspend_request_flags &= - ~(1u << (static_cast<u32>(ThreadState::SuspendShift) + static_cast<u32>(type))); + m_suspend_request_flags &= + ~(1U << (static_cast<u32>(ThreadState::SuspendShift) + static_cast<u32>(type))); // Update our state. this->UpdateState(); } void KThread::WaitCancel() { - KScopedSchedulerLock sl{kernel}; + KScopedSchedulerLock sl{m_kernel}; // Check if we're waiting and cancellable. - if (this->GetState() == ThreadState::Waiting && cancellable) { - wait_cancelled = false; - wait_queue->CancelWait(this, ResultCancelled, true); + if (this->GetState() == ThreadState::Waiting && m_cancellable) { + m_wait_cancelled = false; + m_wait_queue->CancelWait(this, ResultCancelled, true); } else { // Otherwise, note that we cancelled a wait. - wait_cancelled = true; + m_wait_cancelled = true; } } void KThread::TrySuspend() { - ASSERT(kernel.GlobalSchedulerContext().IsLocked()); - ASSERT(IsSuspendRequested()); + ASSERT(KScheduler::IsSchedulerLockedByCurrentThread(m_kernel)); + ASSERT(this->IsSuspendRequested()); // Ensure that we have no waiters. - if (GetNumKernelWaiters() > 0) { + if (this->GetNumKernelWaiters() > 0) { return; } - ASSERT(GetNumKernelWaiters() == 0); + ASSERT(this->GetNumKernelWaiters() == 0); // Perform the suspend. this->UpdateState(); } void KThread::UpdateState() { - ASSERT(kernel.GlobalSchedulerContext().IsLocked()); + ASSERT(KScheduler::IsSchedulerLockedByCurrentThread(m_kernel)); // Set our suspend flags in state. - const ThreadState old_state = thread_state.load(std::memory_order_relaxed); + const ThreadState old_state = m_thread_state.load(std::memory_order_relaxed); const auto new_state = static_cast<ThreadState>(this->GetSuspendFlags()) | (old_state & ThreadState::Mask); - thread_state.store(new_state, std::memory_order_relaxed); + m_thread_state.store(new_state, std::memory_order_relaxed); // Note the state change in scheduler. if (new_state != old_state) { - KScheduler::OnThreadStateChanged(kernel, this, old_state); + KScheduler::OnThreadStateChanged(m_kernel, this, old_state); } } void KThread::Continue() { - ASSERT(kernel.GlobalSchedulerContext().IsLocked()); + ASSERT(KScheduler::IsSchedulerLockedByCurrentThread(m_kernel)); // Clear our suspend flags in state. - const ThreadState old_state = thread_state.load(std::memory_order_relaxed); - thread_state.store(old_state & ThreadState::Mask, std::memory_order_relaxed); + const ThreadState old_state = m_thread_state.load(std::memory_order_relaxed); + m_thread_state.store(old_state & ThreadState::Mask, std::memory_order_relaxed); // Note the state change in scheduler. - KScheduler::OnThreadStateChanged(kernel, this, old_state); + KScheduler::OnThreadStateChanged(m_kernel, this, old_state); +} + +void KThread::CloneFpuStatus() { + // We shouldn't reach here when starting kernel threads. + ASSERT(this->GetOwnerProcess() != nullptr); + ASSERT(this->GetOwnerProcess() == GetCurrentProcessPointer(m_kernel)); + + if (this->GetOwnerProcess()->Is64BitProcess()) { + // Clone FPSR and FPCR. + ThreadContext64 cur_ctx{}; + m_kernel.System().CurrentArmInterface().SaveContext(cur_ctx); + + this->GetContext64().fpcr = cur_ctx.fpcr; + this->GetContext64().fpsr = cur_ctx.fpsr; + } else { + // Clone FPSCR. + ThreadContext32 cur_ctx{}; + m_kernel.System().CurrentArmInterface().SaveContext(cur_ctx); + + this->GetContext32().fpscr = cur_ctx.fpscr; + } } Result KThread::SetActivity(Svc::ThreadActivity activity) { // Lock ourselves. - KScopedLightLock lk(activity_pause_lock); + KScopedLightLock lk(m_activity_pause_lock); // Set the activity. { // Lock the scheduler. - KScopedSchedulerLock sl(kernel); + KScopedSchedulerLock sl(m_kernel); // Verify our state. const auto cur_state = this->GetState(); @@ -849,13 +867,13 @@ Result KThread::SetActivity(Svc::ThreadActivity activity) { // If the thread is now paused, update the pinned waiter list. if (activity == Svc::ThreadActivity::Paused) { - ThreadQueueImplForKThreadSetProperty wait_queue_(kernel, - std::addressof(pinned_waiter_list)); + ThreadQueueImplForKThreadSetProperty wait_queue(m_kernel, + std::addressof(m_pinned_waiter_list)); - bool thread_is_current; + bool thread_is_current{}; do { // Lock the scheduler. - KScopedSchedulerLock sl(kernel); + KScopedSchedulerLock sl(m_kernel); // Don't do any further management if our termination has been requested. R_SUCCEED_IF(this->IsTerminationRequested()); @@ -866,17 +884,17 @@ Result KThread::SetActivity(Svc::ThreadActivity activity) { // Check whether the thread is pinned. if (this->GetStackParameters().is_pinned) { // Verify that the current thread isn't terminating. - R_UNLESS(!GetCurrentThread(kernel).IsTerminationRequested(), + R_UNLESS(!GetCurrentThread(m_kernel).IsTerminationRequested(), ResultTerminationRequested); // Wait until the thread isn't pinned any more. - pinned_waiter_list.push_back(GetCurrentThread(kernel)); - GetCurrentThread(kernel).BeginWait(std::addressof(wait_queue_)); + m_pinned_waiter_list.push_back(GetCurrentThread(m_kernel)); + GetCurrentThread(m_kernel).BeginWait(std::addressof(wait_queue)); } else { // Check if the thread is currently running. // If it is, we'll need to retry. for (auto i = 0; i < static_cast<s32>(Core::Hardware::NUM_CPU_CORES); ++i) { - if (kernel.Scheduler(i).GetSchedulerCurrentThread() == this) { + if (m_kernel.Scheduler(i).GetSchedulerCurrentThread() == this) { thread_is_current = true; break; } @@ -890,32 +908,32 @@ Result KThread::SetActivity(Svc::ThreadActivity activity) { Result KThread::GetThreadContext3(std::vector<u8>& out) { // Lock ourselves. - KScopedLightLock lk{activity_pause_lock}; + KScopedLightLock lk{m_activity_pause_lock}; // Get the context. { // Lock the scheduler. - KScopedSchedulerLock sl{kernel}; + KScopedSchedulerLock sl{m_kernel}; // Verify that we're suspended. - R_UNLESS(IsSuspendRequested(SuspendType::Thread), ResultInvalidState); + R_UNLESS(this->IsSuspendRequested(SuspendType::Thread), ResultInvalidState); // If we're not terminating, get the thread's user context. - if (!IsTerminationRequested()) { - if (parent->Is64BitProcess()) { + if (!this->IsTerminationRequested()) { + if (m_parent->Is64BitProcess()) { // Mask away mode bits, interrupt bits, IL bit, and other reserved bits. auto context = GetContext64(); context.pstate &= 0xFF0FFE20; out.resize(sizeof(context)); - std::memcpy(out.data(), &context, sizeof(context)); + std::memcpy(out.data(), std::addressof(context), sizeof(context)); } else { // Mask away mode bits, interrupt bits, IL bit, and other reserved bits. auto context = GetContext32(); context.cpsr &= 0xFF0FFE20; out.resize(sizeof(context)); - std::memcpy(out.data(), &context, sizeof(context)); + std::memcpy(out.data(), std::addressof(context), sizeof(context)); } } } @@ -924,23 +942,23 @@ Result KThread::GetThreadContext3(std::vector<u8>& out) { } void KThread::AddHeldLock(LockWithPriorityInheritanceInfo* lock_info) { - ASSERT(KScheduler::IsSchedulerLockedByCurrentThread(kernel)); + ASSERT(KScheduler::IsSchedulerLockedByCurrentThread(m_kernel)); // Set ourselves as the lock's owner. lock_info->SetOwner(this); // Add the lock to our held list. - held_lock_info_list.push_front(*lock_info); + m_held_lock_info_list.push_front(*lock_info); } -KThread::LockWithPriorityInheritanceInfo* KThread::FindHeldLock(VAddr address_key_, - bool is_kernel_address_key_) { - ASSERT(KScheduler::IsSchedulerLockedByCurrentThread(kernel)); +KThread::LockWithPriorityInheritanceInfo* KThread::FindHeldLock(VAddr address_key, + bool is_kernel_address_key) { + ASSERT(KScheduler::IsSchedulerLockedByCurrentThread(m_kernel)); // Try to find an existing held lock. - for (auto& held_lock : held_lock_info_list) { - if (held_lock.GetAddressKey() == address_key_ && - held_lock.GetIsKernelAddressKey() == is_kernel_address_key_) { + for (auto& held_lock : m_held_lock_info_list) { + if (held_lock.GetAddressKey() == address_key && + held_lock.GetIsKernelAddressKey() == is_kernel_address_key) { return std::addressof(held_lock); } } @@ -949,25 +967,25 @@ KThread::LockWithPriorityInheritanceInfo* KThread::FindHeldLock(VAddr address_ke } void KThread::AddWaiterImpl(KThread* thread) { - ASSERT(KScheduler::IsSchedulerLockedByCurrentThread(kernel)); + ASSERT(KScheduler::IsSchedulerLockedByCurrentThread(m_kernel)); ASSERT(thread->GetConditionVariableTree() == nullptr); // Get the thread's address key. - const auto address_key_ = thread->GetAddressKey(); - const auto is_kernel_address_key_ = thread->GetIsKernelAddressKey(); + const auto address_key = thread->GetAddressKey(); + const auto is_kernel_address_key = thread->GetIsKernelAddressKey(); // Keep track of how many kernel waiters we have. - if (is_kernel_address_key_) { - ASSERT((num_kernel_waiters++) >= 0); - KScheduler::SetSchedulerUpdateNeeded(kernel); + if (is_kernel_address_key) { + ASSERT((m_num_kernel_waiters++) >= 0); + KScheduler::SetSchedulerUpdateNeeded(m_kernel); } // Get the relevant lock info. - auto* lock_info = this->FindHeldLock(address_key_, is_kernel_address_key_); + auto* lock_info = this->FindHeldLock(address_key, is_kernel_address_key); if (lock_info == nullptr) { // Create a new lock for the address key. lock_info = - LockWithPriorityInheritanceInfo::Create(kernel, address_key_, is_kernel_address_key_); + LockWithPriorityInheritanceInfo::Create(m_kernel, address_key, is_kernel_address_key); // Add the new lock to our list. this->AddHeldLock(lock_info); @@ -978,12 +996,12 @@ void KThread::AddWaiterImpl(KThread* thread) { } void KThread::RemoveWaiterImpl(KThread* thread) { - ASSERT(KScheduler::IsSchedulerLockedByCurrentThread(kernel)); + ASSERT(KScheduler::IsSchedulerLockedByCurrentThread(m_kernel)); // Keep track of how many kernel waiters we have. if (thread->GetIsKernelAddressKey()) { - ASSERT((num_kernel_waiters--) > 0); - KScheduler::SetSchedulerUpdateNeeded(kernel); + ASSERT((m_num_kernel_waiters--) > 0); + KScheduler::SetSchedulerUpdateNeeded(m_kernel); } // Get the info for the lock the thread is waiting on. @@ -992,8 +1010,8 @@ void KThread::RemoveWaiterImpl(KThread* thread) { // Remove the waiter. if (lock_info->RemoveWaiter(thread)) { - held_lock_info_list.erase(held_lock_info_list.iterator_to(*lock_info)); - LockWithPriorityInheritanceInfo::Free(kernel, lock_info); + m_held_lock_info_list.erase(m_held_lock_info_list.iterator_to(*lock_info)); + LockWithPriorityInheritanceInfo::Free(m_kernel, lock_info); } } @@ -1003,7 +1021,7 @@ void KThread::RestorePriority(KernelCore& kernel, KThread* thread) { while (thread != nullptr) { // We want to inherit priority where possible. s32 new_priority = thread->GetBasePriority(); - for (const auto& held_lock : thread->held_lock_info_list) { + for (const auto& held_lock : thread->m_held_lock_info_list) { new_priority = std::min(new_priority, held_lock.GetHighestPriorityWaiter()->GetPriority()); } @@ -1054,7 +1072,7 @@ void KThread::AddWaiter(KThread* thread) { // If the thread has a higher priority than us, we should inherit. if (thread->GetPriority() < this->GetPriority()) { - RestorePriority(kernel, this); + RestorePriority(m_kernel, this); } } @@ -1065,12 +1083,12 @@ void KThread::RemoveWaiter(KThread* thread) { // lower priority. if (this->GetPriority() == thread->GetPriority() && this->GetPriority() < this->GetBasePriority()) { - RestorePriority(kernel, this); + RestorePriority(m_kernel, this); } } KThread* KThread::RemoveWaiterByKey(bool* out_has_waiters, VAddr key, bool is_kernel_address_key_) { - ASSERT(KScheduler::IsSchedulerLockedByCurrentThread(kernel)); + ASSERT(KScheduler::IsSchedulerLockedByCurrentThread(m_kernel)); // Get the relevant lock info. auto* lock_info = this->FindHeldLock(key, is_kernel_address_key_); @@ -1080,13 +1098,13 @@ KThread* KThread::RemoveWaiterByKey(bool* out_has_waiters, VAddr key, bool is_ke } // Remove the lock info from our held list. - held_lock_info_list.erase(held_lock_info_list.iterator_to(*lock_info)); + m_held_lock_info_list.erase(m_held_lock_info_list.iterator_to(*lock_info)); // Keep track of how many kernel waiters we have. if (lock_info->GetIsKernelAddressKey()) { - num_kernel_waiters -= lock_info->GetWaiterCount(); - ASSERT(num_kernel_waiters >= 0); - KScheduler::SetSchedulerUpdateNeeded(kernel); + m_num_kernel_waiters -= lock_info->GetWaiterCount(); + ASSERT(m_num_kernel_waiters >= 0); + KScheduler::SetSchedulerUpdateNeeded(m_kernel); } ASSERT(lock_info->GetWaiterCount() > 0); @@ -1098,7 +1116,7 @@ KThread* KThread::RemoveWaiterByKey(bool* out_has_waiters, VAddr key, bool is_ke *out_has_waiters = false; // Free the lock info, since it has no waiters. - LockWithPriorityInheritanceInfo::Free(kernel, lock_info); + LockWithPriorityInheritanceInfo::Free(m_kernel, lock_info); } else { // There are additional waiters on the lock. *out_has_waiters = true; @@ -1108,8 +1126,8 @@ KThread* KThread::RemoveWaiterByKey(bool* out_has_waiters, VAddr key, bool is_ke // Keep track of any kernel waiters for the new owner. if (lock_info->GetIsKernelAddressKey()) { - next_lock_owner->num_kernel_waiters += lock_info->GetWaiterCount(); - ASSERT(next_lock_owner->num_kernel_waiters > 0); + next_lock_owner->m_num_kernel_waiters += lock_info->GetWaiterCount(); + ASSERT(next_lock_owner->m_num_kernel_waiters > 0); // NOTE: No need to set scheduler update needed, because we will have already done so // when removing earlier. @@ -1120,7 +1138,7 @@ KThread* KThread::RemoveWaiterByKey(bool* out_has_waiters, VAddr key, bool is_ke // to lower priority. if (this->GetPriority() == next_lock_owner->GetPriority() && this->GetPriority() < this->GetBasePriority()) { - RestorePriority(kernel, this); + RestorePriority(m_kernel, this); // NOTE: No need to restore priority on the next lock owner, because it was already the // highest priority waiter on the lock. } @@ -1131,76 +1149,76 @@ KThread* KThread::RemoveWaiterByKey(bool* out_has_waiters, VAddr key, bool is_ke Result KThread::Run() { while (true) { - KScopedSchedulerLock lk{kernel}; + KScopedSchedulerLock lk{m_kernel}; // If either this thread or the current thread are requesting termination, note it. - R_UNLESS(!IsTerminationRequested(), ResultTerminationRequested); - R_UNLESS(!GetCurrentThread(kernel).IsTerminationRequested(), ResultTerminationRequested); + R_UNLESS(!this->IsTerminationRequested(), ResultTerminationRequested); + R_UNLESS(!GetCurrentThread(m_kernel).IsTerminationRequested(), ResultTerminationRequested); // Ensure our thread state is correct. - R_UNLESS(GetState() == ThreadState::Initialized, ResultInvalidState); + R_UNLESS(this->GetState() == ThreadState::Initialized, ResultInvalidState); // If the current thread has been asked to suspend, suspend it and retry. - if (GetCurrentThread(kernel).IsSuspended()) { - GetCurrentThread(kernel).UpdateState(); + if (GetCurrentThread(m_kernel).IsSuspended()) { + GetCurrentThread(m_kernel).UpdateState(); continue; } // If we're not a kernel thread and we've been asked to suspend, suspend ourselves. if (KProcess* owner = this->GetOwnerProcess(); owner != nullptr) { - if (IsUserThread() && IsSuspended()) { + if (this->IsUserThread() && this->IsSuspended()) { this->UpdateState(); } owner->IncrementRunningThreadCount(); } // Set our state and finish. - SetState(ThreadState::Runnable); + this->SetState(ThreadState::Runnable); R_SUCCEED(); } } void KThread::Exit() { - ASSERT(this == GetCurrentThreadPointer(kernel)); + ASSERT(this == GetCurrentThreadPointer(m_kernel)); // Release the thread resource hint, running thread count from parent. - if (parent != nullptr) { - parent->GetResourceLimit()->Release(Kernel::LimitableResource::ThreadCountMax, 0, 1); - resource_limit_release_hint = true; - parent->DecrementRunningThreadCount(); + if (m_parent != nullptr) { + m_parent->GetResourceLimit()->Release(Kernel::LimitableResource::ThreadCountMax, 0, 1); + m_resource_limit_release_hint = true; + m_parent->DecrementRunningThreadCount(); } // Perform termination. { - KScopedSchedulerLock sl{kernel}; + KScopedSchedulerLock sl{m_kernel}; // Disallow all suspension. - suspend_allowed_flags = 0; + m_suspend_allowed_flags = 0; this->UpdateState(); // Disallow all suspension. - suspend_allowed_flags = 0; + m_suspend_allowed_flags = 0; // Start termination. - StartTermination(); + this->StartTermination(); // Register the thread as a work task. - KWorkerTaskManager::AddTask(kernel, KWorkerTaskManager::WorkerType::Exit, this); + KWorkerTaskManager::AddTask(m_kernel, KWorkerTaskManager::WorkerType::Exit, this); } UNREACHABLE_MSG("KThread::Exit() would return"); } Result KThread::Terminate() { - ASSERT(this != GetCurrentThreadPointer(kernel)); + ASSERT(this != GetCurrentThreadPointer(m_kernel)); // Request the thread terminate if it hasn't already. if (const auto new_state = this->RequestTerminate(); new_state != ThreadState::Terminated) { // If the thread isn't terminated, wait for it to terminate. s32 index; KSynchronizationObject* objects[] = {this}; - R_TRY(KSynchronizationObject::Wait(kernel, std::addressof(index), objects, 1, + R_TRY(KSynchronizationObject::Wait(m_kernel, std::addressof(index), objects, 1, Svc::WaitInfinite)); } @@ -1208,22 +1226,22 @@ Result KThread::Terminate() { } ThreadState KThread::RequestTerminate() { - ASSERT(this != GetCurrentThreadPointer(kernel)); + ASSERT(this != GetCurrentThreadPointer(m_kernel)); - KScopedSchedulerLock sl{kernel}; + KScopedSchedulerLock sl{m_kernel}; // Determine if this is the first termination request. const bool first_request = [&]() -> bool { // Perform an atomic compare-and-swap from false to true. bool expected = false; - return termination_requested.compare_exchange_strong(expected, true); + return m_termination_requested.compare_exchange_strong(expected, true); }(); // If this is the first request, start termination procedure. if (first_request) { // If the thread is in initialized state, just change state to terminated. if (this->GetState() == ThreadState::Initialized) { - thread_state = ThreadState::Terminated; + m_thread_state = ThreadState::Terminated; return ThreadState::Terminated; } @@ -1237,7 +1255,7 @@ ThreadState KThread::RequestTerminate() { // If the thread is suspended, continue it. if (this->IsSuspended()) { - suspend_allowed_flags = 0; + m_suspend_allowed_flags = 0; this->UpdateState(); } @@ -1246,16 +1264,16 @@ ThreadState KThread::RequestTerminate() { // If the thread is runnable, send a termination interrupt to other cores. if (this->GetState() == ThreadState::Runnable) { - if (const u64 core_mask = - physical_affinity_mask.GetAffinityMask() & ~(1ULL << GetCurrentCoreId(kernel)); + if (const u64 core_mask = m_physical_affinity_mask.GetAffinityMask() & + ~(1ULL << GetCurrentCoreId(m_kernel)); core_mask != 0) { - Kernel::KInterruptManager::SendInterProcessorInterrupt(kernel, core_mask); + Kernel::KInterruptManager::SendInterProcessorInterrupt(m_kernel, core_mask); } } // Wake up the thread. if (this->GetState() == ThreadState::Waiting) { - wait_queue->CancelWait(this, ResultTerminationRequested, true); + m_wait_queue->CancelWait(this, ResultTerminationRequested, true); } } @@ -1263,14 +1281,15 @@ ThreadState KThread::RequestTerminate() { } Result KThread::Sleep(s64 timeout) { - ASSERT(!kernel.GlobalSchedulerContext().IsLocked()); - ASSERT(this == GetCurrentThreadPointer(kernel)); + ASSERT(!KScheduler::IsSchedulerLockedByCurrentThread(m_kernel)); + ASSERT(this == GetCurrentThreadPointer(m_kernel)); ASSERT(timeout > 0); - ThreadQueueImplForKThreadSleep wait_queue_(kernel); + ThreadQueueImplForKThreadSleep wait_queue(m_kernel); + KHardwareTimer* timer{}; { // Setup the scheduling lock and sleep. - KScopedSchedulerLockAndSleep slp(kernel, this, timeout); + KScopedSchedulerLockAndSleep slp(m_kernel, std::addressof(timer), this, timeout); // Check if the thread should terminate. if (this->IsTerminationRequested()) { @@ -1279,102 +1298,102 @@ Result KThread::Sleep(s64 timeout) { } // Wait for the sleep to end. - this->BeginWait(std::addressof(wait_queue_)); - SetWaitReasonForDebugging(ThreadWaitReasonForDebugging::Sleep); + wait_queue.SetHardwareTimer(timer); + this->BeginWait(std::addressof(wait_queue)); + this->SetWaitReasonForDebugging(ThreadWaitReasonForDebugging::Sleep); } R_SUCCEED(); } void KThread::RequestDummyThreadWait() { - ASSERT(KScheduler::IsSchedulerLockedByCurrentThread(kernel)); + ASSERT(KScheduler::IsSchedulerLockedByCurrentThread(m_kernel)); ASSERT(this->IsDummyThread()); // We will block when the scheduler lock is released. - dummy_thread_runnable.store(false); + m_dummy_thread_runnable.store(false); } void KThread::DummyThreadBeginWait() { - if (!this->IsDummyThread() || kernel.IsPhantomModeForSingleCore()) { + if (!this->IsDummyThread() || m_kernel.IsPhantomModeForSingleCore()) { // Occurs in single core mode. return; } // Block until runnable is no longer false. - dummy_thread_runnable.wait(false); + m_dummy_thread_runnable.wait(false); } void KThread::DummyThreadEndWait() { - ASSERT(KScheduler::IsSchedulerLockedByCurrentThread(kernel)); + ASSERT(KScheduler::IsSchedulerLockedByCurrentThread(m_kernel)); ASSERT(this->IsDummyThread()); // Wake up the waiting thread. - dummy_thread_runnable.store(true); - dummy_thread_runnable.notify_one(); + m_dummy_thread_runnable.store(true); + m_dummy_thread_runnable.notify_one(); } void KThread::BeginWait(KThreadQueue* queue) { // Set our state as waiting. - SetState(ThreadState::Waiting); + this->SetState(ThreadState::Waiting); // Set our wait queue. - wait_queue = queue; + m_wait_queue = queue; } -void KThread::NotifyAvailable(KSynchronizationObject* signaled_object, Result wait_result_) { +void KThread::NotifyAvailable(KSynchronizationObject* signaled_object, Result wait_result) { // Lock the scheduler. - KScopedSchedulerLock sl(kernel); + KScopedSchedulerLock sl(m_kernel); // If we're waiting, notify our queue that we're available. - if (GetState() == ThreadState::Waiting) { - wait_queue->NotifyAvailable(this, signaled_object, wait_result_); + if (this->GetState() == ThreadState::Waiting) { + m_wait_queue->NotifyAvailable(this, signaled_object, wait_result); } } -void KThread::EndWait(Result wait_result_) { +void KThread::EndWait(Result wait_result) { // Lock the scheduler. - KScopedSchedulerLock sl(kernel); + KScopedSchedulerLock sl(m_kernel); // If we're waiting, notify our queue that we're available. - if (GetState() == ThreadState::Waiting) { - if (wait_queue == nullptr) { + if (this->GetState() == ThreadState::Waiting) { + if (m_wait_queue == nullptr) { // This should never happen, but avoid a hard crash below to get this logged. ASSERT_MSG(false, "wait_queue is nullptr!"); return; } - wait_queue->EndWait(this, wait_result_); + m_wait_queue->EndWait(this, wait_result); } } -void KThread::CancelWait(Result wait_result_, bool cancel_timer_task) { +void KThread::CancelWait(Result wait_result, bool cancel_timer_task) { // Lock the scheduler. - KScopedSchedulerLock sl(kernel); + KScopedSchedulerLock sl(m_kernel); // If we're waiting, notify our queue that we're available. - if (GetState() == ThreadState::Waiting) { - wait_queue->CancelWait(this, wait_result_, cancel_timer_task); + if (this->GetState() == ThreadState::Waiting) { + m_wait_queue->CancelWait(this, wait_result, cancel_timer_task); } } void KThread::SetState(ThreadState state) { - KScopedSchedulerLock sl{kernel}; + KScopedSchedulerLock sl{m_kernel}; // Clear debugging state - SetMutexWaitAddressForDebugging({}); - SetWaitReasonForDebugging({}); + this->SetWaitReasonForDebugging({}); - const ThreadState old_state = thread_state.load(std::memory_order_relaxed); - thread_state.store( + const ThreadState old_state = m_thread_state.load(std::memory_order_relaxed); + m_thread_state.store( static_cast<ThreadState>((old_state & ~ThreadState::Mask) | (state & ThreadState::Mask)), std::memory_order_relaxed); - if (thread_state.load(std::memory_order_relaxed) != old_state) { - KScheduler::OnThreadStateChanged(kernel, this, old_state); + if (m_thread_state.load(std::memory_order_relaxed) != old_state) { + KScheduler::OnThreadStateChanged(m_kernel, this, old_state); } } std::shared_ptr<Common::Fiber>& KThread::GetHostContext() { - return host_context; + return m_host_context; } void SetCurrentThread(KernelCore& kernel, KThread* thread) { @@ -1403,20 +1422,20 @@ s32 GetCurrentCoreId(KernelCore& kernel) { KScopedDisableDispatch::~KScopedDisableDispatch() { // If we are shutting down the kernel, none of this is relevant anymore. - if (kernel.IsShuttingDown()) { + if (m_kernel.IsShuttingDown()) { return; } - if (GetCurrentThread(kernel).GetDisableDispatchCount() <= 1) { - auto* scheduler = kernel.CurrentScheduler(); + if (GetCurrentThread(m_kernel).GetDisableDispatchCount() <= 1) { + auto* scheduler = m_kernel.CurrentScheduler(); - if (scheduler && !kernel.IsPhantomModeForSingleCore()) { + if (scheduler && !m_kernel.IsPhantomModeForSingleCore()) { scheduler->RescheduleCurrentCore(); } else { - KScheduler::RescheduleCurrentHLEThread(kernel); + KScheduler::RescheduleCurrentHLEThread(m_kernel); } } else { - GetCurrentThread(kernel).EnableDispatch(); + GetCurrentThread(m_kernel).EnableDispatch(); } } diff --git a/src/core/hle/kernel/k_thread.h b/src/core/hle/kernel/k_thread.h index bd125f5f1..53fa64369 100644 --- a/src/core/hle/kernel/k_thread.h +++ b/src/core/hle/kernel/k_thread.h @@ -108,11 +108,11 @@ enum class StepState : u32 { }; void SetCurrentThread(KernelCore& kernel, KThread* thread); -[[nodiscard]] KThread* GetCurrentThreadPointer(KernelCore& kernel); -[[nodiscard]] KThread& GetCurrentThread(KernelCore& kernel); -[[nodiscard]] KProcess* GetCurrentProcessPointer(KernelCore& kernel); -[[nodiscard]] KProcess& GetCurrentProcess(KernelCore& kernel); -[[nodiscard]] s32 GetCurrentCoreId(KernelCore& kernel); +KThread* GetCurrentThreadPointer(KernelCore& kernel); +KThread& GetCurrentThread(KernelCore& kernel); +KProcess* GetCurrentProcessPointer(KernelCore& kernel); +KProcess& GetCurrentProcess(KernelCore& kernel); +s32 GetCurrentCoreId(KernelCore& kernel); class KThread final : public KAutoObjectWithSlabHeapAndContainer<KThread, KWorkerTask>, public boost::intrusive::list_base_hook<>, @@ -128,7 +128,7 @@ public: static constexpr s32 IdleThreadPriority = Svc::LowestThreadPriority + 1; static constexpr s32 DummyThreadPriority = Svc::LowestThreadPriority + 2; - explicit KThread(KernelCore& kernel_); + explicit KThread(KernelCore& kernel); ~KThread() override; public: @@ -136,16 +136,12 @@ public: using ThreadContext64 = Core::ARM_Interface::ThreadContext64; using WaiterList = boost::intrusive::list<KThread>; - void SetName(std::string new_name) { - name = std::move(new_name); - } - /** * Gets the thread's current priority * @return The current thread's priority */ - [[nodiscard]] s32 GetPriority() const { - return priority; + s32 GetPriority() const { + return m_priority; } /** @@ -153,23 +149,23 @@ public: * @param priority The new priority. */ void SetPriority(s32 value) { - priority = value; + m_priority = value; } /** * Gets the thread's nominal priority. * @return The current thread's nominal priority. */ - [[nodiscard]] s32 GetBasePriority() const { - return base_priority; + s32 GetBasePriority() const { + return m_base_priority; } /** * Gets the thread's thread ID * @return The thread's ID */ - [[nodiscard]] u64 GetThreadID() const { - return thread_id; + u64 GetThreadId() const { + return m_thread_id; } void ContinueIfHasKernelWaiters() { @@ -180,7 +176,7 @@ public: void SetBasePriority(s32 value); - [[nodiscard]] Result Run(); + Result Run(); void Exit(); @@ -188,22 +184,22 @@ public: ThreadState RequestTerminate(); - [[nodiscard]] u32 GetSuspendFlags() const { - return suspend_allowed_flags & suspend_request_flags; + u32 GetSuspendFlags() const { + return m_suspend_allowed_flags & m_suspend_request_flags; } - [[nodiscard]] bool IsSuspended() const { + bool IsSuspended() const { return GetSuspendFlags() != 0; } - [[nodiscard]] bool IsSuspendRequested(SuspendType type) const { - return (suspend_request_flags & - (1u << (static_cast<u32>(ThreadState::SuspendShift) + static_cast<u32>(type)))) != + bool IsSuspendRequested(SuspendType type) const { + return (m_suspend_request_flags & + (1U << (static_cast<u32>(ThreadState::SuspendShift) + static_cast<u32>(type)))) != 0; } - [[nodiscard]] bool IsSuspendRequested() const { - return suspend_request_flags != 0; + bool IsSuspendRequested() const { + return m_suspend_request_flags != 0; } void RequestSuspend(SuspendType type); @@ -217,122 +213,124 @@ public: void Continue(); constexpr void SetSyncedIndex(s32 index) { - synced_index = index; + m_synced_index = index; } - [[nodiscard]] constexpr s32 GetSyncedIndex() const { - return synced_index; + constexpr s32 GetSyncedIndex() const { + return m_synced_index; } constexpr void SetWaitResult(Result wait_res) { - wait_result = wait_res; + m_wait_result = wait_res; } - [[nodiscard]] constexpr Result GetWaitResult() const { - return wait_result; + constexpr Result GetWaitResult() const { + return m_wait_result; } /* * Returns the Thread Local Storage address of the current thread * @returns VAddr of the thread's TLS */ - [[nodiscard]] VAddr GetTLSAddress() const { - return tls_address; + VAddr GetTlsAddress() const { + return m_tls_address; } /* * Returns the value of the TPIDR_EL0 Read/Write system register for this thread. * @returns The value of the TPIDR_EL0 register. */ - [[nodiscard]] u64 GetTPIDR_EL0() const { - return thread_context_64.tpidr; + u64 GetTpidrEl0() const { + return m_thread_context_64.tpidr; } /// Sets the value of the TPIDR_EL0 Read/Write system register for this thread. - void SetTPIDR_EL0(u64 value) { - thread_context_64.tpidr = value; - thread_context_32.tpidr = static_cast<u32>(value); + void SetTpidrEl0(u64 value) { + m_thread_context_64.tpidr = value; + m_thread_context_32.tpidr = static_cast<u32>(value); } - [[nodiscard]] ThreadContext32& GetContext32() { - return thread_context_32; + void CloneFpuStatus(); + + ThreadContext32& GetContext32() { + return m_thread_context_32; } - [[nodiscard]] const ThreadContext32& GetContext32() const { - return thread_context_32; + const ThreadContext32& GetContext32() const { + return m_thread_context_32; } - [[nodiscard]] ThreadContext64& GetContext64() { - return thread_context_64; + ThreadContext64& GetContext64() { + return m_thread_context_64; } - [[nodiscard]] const ThreadContext64& GetContext64() const { - return thread_context_64; + const ThreadContext64& GetContext64() const { + return m_thread_context_64; } - [[nodiscard]] std::shared_ptr<Common::Fiber>& GetHostContext(); + std::shared_ptr<Common::Fiber>& GetHostContext(); - [[nodiscard]] ThreadState GetState() const { - return thread_state.load(std::memory_order_relaxed) & ThreadState::Mask; + ThreadState GetState() const { + return m_thread_state.load(std::memory_order_relaxed) & ThreadState::Mask; } - [[nodiscard]] ThreadState GetRawState() const { - return thread_state.load(std::memory_order_relaxed); + ThreadState GetRawState() const { + return m_thread_state.load(std::memory_order_relaxed); } void SetState(ThreadState state); - [[nodiscard]] StepState GetStepState() const { - return step_state; + StepState GetStepState() const { + return m_step_state; } void SetStepState(StepState state) { - step_state = state; + m_step_state = state; } - [[nodiscard]] s64 GetLastScheduledTick() const { - return last_scheduled_tick; + s64 GetLastScheduledTick() const { + return m_last_scheduled_tick; } void SetLastScheduledTick(s64 tick) { - last_scheduled_tick = tick; + m_last_scheduled_tick = tick; } - void AddCpuTime([[maybe_unused]] s32 core_id_, s64 amount) { - cpu_time += amount; + void AddCpuTime(s32 core_id, s64 amount) { + m_cpu_time += amount; // TODO(bunnei): Debug kernels track per-core tick counts. Should we? } - [[nodiscard]] s64 GetCpuTime() const { - return cpu_time; + s64 GetCpuTime() const { + return m_cpu_time; } - [[nodiscard]] s32 GetActiveCore() const { - return core_id; + s32 GetActiveCore() const { + return m_core_id; } void SetActiveCore(s32 core) { - core_id = core; + m_core_id = core; } - [[nodiscard]] s32 GetCurrentCore() const { - return current_core_id; + s32 GetCurrentCore() const { + return m_current_core_id; } void SetCurrentCore(s32 core) { - current_core_id = core; + m_current_core_id = core; } - [[nodiscard]] KProcess* GetOwnerProcess() { - return parent; + KProcess* GetOwnerProcess() { + return m_parent; } - [[nodiscard]] const KProcess* GetOwnerProcess() const { - return parent; + const KProcess* GetOwnerProcess() const { + return m_parent; } - [[nodiscard]] bool IsUserThread() const { - return parent != nullptr; + bool IsUserThread() const { + return m_parent != nullptr; } u16 GetUserDisableCount() const; @@ -341,69 +339,69 @@ public: KThread* GetLockOwner() const; - [[nodiscard]] const KAffinityMask& GetAffinityMask() const { - return physical_affinity_mask; + const KAffinityMask& GetAffinityMask() const { + return m_physical_affinity_mask; } - [[nodiscard]] Result GetCoreMask(s32* out_ideal_core, u64* out_affinity_mask); + Result GetCoreMask(s32* out_ideal_core, u64* out_affinity_mask); - [[nodiscard]] Result GetPhysicalCoreMask(s32* out_ideal_core, u64* out_affinity_mask); + Result GetPhysicalCoreMask(s32* out_ideal_core, u64* out_affinity_mask); - [[nodiscard]] Result SetCoreMask(s32 cpu_core_id, u64 v_affinity_mask); + Result SetCoreMask(s32 cpu_core_id, u64 v_affinity_mask); - [[nodiscard]] Result SetActivity(Svc::ThreadActivity activity); + Result SetActivity(Svc::ThreadActivity activity); - [[nodiscard]] Result Sleep(s64 timeout); + Result Sleep(s64 timeout); - [[nodiscard]] s64 GetYieldScheduleCount() const { - return schedule_count; + s64 GetYieldScheduleCount() const { + return m_schedule_count; } void SetYieldScheduleCount(s64 count) { - schedule_count = count; + m_schedule_count = count; } void WaitCancel(); - [[nodiscard]] bool IsWaitCancelled() const { - return wait_cancelled; + bool IsWaitCancelled() const { + return m_wait_cancelled; } void ClearWaitCancelled() { - wait_cancelled = false; + m_wait_cancelled = false; } - [[nodiscard]] bool IsCancellable() const { - return cancellable; + bool IsCancellable() const { + return m_cancellable; } void SetCancellable() { - cancellable = true; + m_cancellable = true; } void ClearCancellable() { - cancellable = false; + m_cancellable = false; } - [[nodiscard]] bool IsTerminationRequested() const { - return termination_requested || GetRawState() == ThreadState::Terminated; + bool IsTerminationRequested() const { + return m_termination_requested || GetRawState() == ThreadState::Terminated; } - [[nodiscard]] u64 GetId() const override { - return this->GetThreadID(); + u64 GetId() const override { + return this->GetThreadId(); } - [[nodiscard]] bool IsInitialized() const override { - return initialized; + bool IsInitialized() const override { + return m_initialized; } - [[nodiscard]] uintptr_t GetPostDestroyArgument() const override { - return reinterpret_cast<uintptr_t>(parent) | (resource_limit_release_hint ? 1 : 0); + uintptr_t GetPostDestroyArgument() const override { + return reinterpret_cast<uintptr_t>(m_parent) | (m_resource_limit_release_hint ? 1 : 0); } void Finalize() override; - [[nodiscard]] bool IsSignaled() const override; + bool IsSignaled() const override; void OnTimer(); @@ -411,26 +409,22 @@ public: static void PostDestroy(uintptr_t arg); - [[nodiscard]] static Result InitializeDummyThread(KThread* thread, KProcess* owner); + static Result InitializeDummyThread(KThread* thread, KProcess* owner); - [[nodiscard]] static Result InitializeMainThread(Core::System& system, KThread* thread, - s32 virt_core); + static Result InitializeMainThread(Core::System& system, KThread* thread, s32 virt_core); - [[nodiscard]] static Result InitializeIdleThread(Core::System& system, KThread* thread, - s32 virt_core); + static Result InitializeIdleThread(Core::System& system, KThread* thread, s32 virt_core); - [[nodiscard]] static Result InitializeHighPriorityThread(Core::System& system, KThread* thread, - KThreadFunction func, uintptr_t arg, - s32 virt_core); + static Result InitializeHighPriorityThread(Core::System& system, KThread* thread, + KThreadFunction func, uintptr_t arg, s32 virt_core); - [[nodiscard]] static Result InitializeUserThread(Core::System& system, KThread* thread, - KThreadFunction func, uintptr_t arg, - VAddr user_stack_top, s32 prio, s32 virt_core, - KProcess* owner); + static Result InitializeUserThread(Core::System& system, KThread* thread, KThreadFunction func, + uintptr_t arg, VAddr user_stack_top, s32 prio, s32 virt_core, + KProcess* owner); - [[nodiscard]] static Result InitializeServiceThread(Core::System& system, KThread* thread, - std::function<void()>&& thread_func, - s32 prio, s32 virt_core, KProcess* owner); + static Result InitializeServiceThread(Core::System& system, KThread* thread, + std::function<void()>&& thread_func, s32 prio, + s32 virt_core, KProcess* owner); public: struct StackParameters { @@ -444,12 +438,12 @@ public: KThread* cur_thread; }; - [[nodiscard]] StackParameters& GetStackParameters() { - return stack_parameters; + StackParameters& GetStackParameters() { + return m_stack_parameters; } - [[nodiscard]] const StackParameters& GetStackParameters() const { - return stack_parameters; + const StackParameters& GetStackParameters() const { + return m_stack_parameters; } class QueueEntry { @@ -457,47 +451,47 @@ public: constexpr QueueEntry() = default; constexpr void Initialize() { - prev = nullptr; - next = nullptr; + m_prev = nullptr; + m_next = nullptr; } constexpr KThread* GetPrev() const { - return prev; + return m_prev; } constexpr KThread* GetNext() const { - return next; + return m_next; } constexpr void SetPrev(KThread* thread) { - prev = thread; + m_prev = thread; } constexpr void SetNext(KThread* thread) { - next = thread; + m_next = thread; } private: - KThread* prev{}; - KThread* next{}; + KThread* m_prev{}; + KThread* m_next{}; }; - [[nodiscard]] QueueEntry& GetPriorityQueueEntry(s32 core) { - return per_core_priority_queue_entry[core]; + QueueEntry& GetPriorityQueueEntry(s32 core) { + return m_per_core_priority_queue_entry[core]; } - [[nodiscard]] const QueueEntry& GetPriorityQueueEntry(s32 core) const { - return per_core_priority_queue_entry[core]; + const QueueEntry& GetPriorityQueueEntry(s32 core) const { + return m_per_core_priority_queue_entry[core]; } - [[nodiscard]] s32 GetDisableDispatchCount() const { + s32 GetDisableDispatchCount() const { return this->GetStackParameters().disable_count; } void DisableDispatch() { - ASSERT(GetCurrentThread(kernel).GetDisableDispatchCount() >= 0); + ASSERT(GetCurrentThread(m_kernel).GetDisableDispatchCount() >= 0); this->GetStackParameters().disable_count++; } void EnableDispatch() { - ASSERT(GetCurrentThread(kernel).GetDisableDispatchCount() > 0); + ASSERT(GetCurrentThread(m_kernel).GetDisableDispatchCount() > 0); this->GetStackParameters().disable_count--; } @@ -513,7 +507,7 @@ public: this->GetStackParameters().is_in_exception_handler = false; } - [[nodiscard]] bool IsInExceptionHandler() const { + bool IsInExceptionHandler() const { return this->GetStackParameters().is_in_exception_handler; } @@ -525,11 +519,11 @@ public: this->GetStackParameters().is_calling_svc = false; } - [[nodiscard]] bool IsCallingSvc() const { + bool IsCallingSvc() const { return this->GetStackParameters().is_calling_svc; } - [[nodiscard]] u8 GetSvcId() const { + u8 GetSvcId() const { return this->GetStackParameters().current_svc_id; } @@ -541,78 +535,54 @@ public: this->GetStackParameters().dpc_flags &= ~static_cast<u8>(flag); } - [[nodiscard]] u8 GetDpc() const { + u8 GetDpc() const { return this->GetStackParameters().dpc_flags; } - [[nodiscard]] bool HasDpc() const { + bool HasDpc() const { return this->GetDpc() != 0; } void SetWaitReasonForDebugging(ThreadWaitReasonForDebugging reason) { - wait_reason_for_debugging = reason; - } - - [[nodiscard]] ThreadWaitReasonForDebugging GetWaitReasonForDebugging() const { - return wait_reason_for_debugging; - } - - [[nodiscard]] ThreadType GetThreadType() const { - return thread_type; + m_wait_reason_for_debugging = reason; } - [[nodiscard]] bool IsDummyThread() const { - return GetThreadType() == ThreadType::Dummy; + ThreadWaitReasonForDebugging GetWaitReasonForDebugging() const { + return m_wait_reason_for_debugging; } - void SetWaitObjectsForDebugging(const std::span<KSynchronizationObject*>& objects) { - wait_objects_for_debugging.clear(); - wait_objects_for_debugging.reserve(objects.size()); - for (const auto& object : objects) { - wait_objects_for_debugging.emplace_back(object); - } + ThreadType GetThreadType() const { + return m_thread_type; } - [[nodiscard]] const std::vector<KSynchronizationObject*>& GetWaitObjectsForDebugging() const { - return wait_objects_for_debugging; - } - - void SetMutexWaitAddressForDebugging(VAddr address) { - mutex_wait_address_for_debugging = address; - } - - [[nodiscard]] VAddr GetMutexWaitAddressForDebugging() const { - return mutex_wait_address_for_debugging; - } - - [[nodiscard]] s32 GetIdealCoreForDebugging() const { - return virtual_ideal_core_id; + bool IsDummyThread() const { + return this->GetThreadType() == ThreadType::Dummy; } void AddWaiter(KThread* thread); void RemoveWaiter(KThread* thread); - [[nodiscard]] Result GetThreadContext3(std::vector<u8>& out); + Result GetThreadContext3(std::vector<u8>& out); - [[nodiscard]] KThread* RemoveUserWaiterByKey(bool* out_has_waiters, VAddr key) { + KThread* RemoveUserWaiterByKey(bool* out_has_waiters, VAddr key) { return this->RemoveWaiterByKey(out_has_waiters, key, false); } - [[nodiscard]] KThread* RemoveKernelWaiterByKey(bool* out_has_waiters, VAddr key) { + KThread* RemoveKernelWaiterByKey(bool* out_has_waiters, VAddr key) { return this->RemoveWaiterByKey(out_has_waiters, key, true); } - [[nodiscard]] VAddr GetAddressKey() const { - return address_key; + VAddr GetAddressKey() const { + return m_address_key; } - [[nodiscard]] u32 GetAddressKeyValue() const { - return address_key_value; + u32 GetAddressKeyValue() const { + return m_address_key_value; } - [[nodiscard]] bool GetIsKernelAddressKey() const { - return is_kernel_address_key; + bool GetIsKernelAddressKey() const { + return m_is_kernel_address_key; } //! NB: intentional deviation from official kernel. @@ -622,37 +592,37 @@ public: // into things. void SetUserAddressKey(VAddr key, u32 val) { - ASSERT(waiting_lock_info == nullptr); - address_key = key; - address_key_value = val; - is_kernel_address_key = false; + ASSERT(m_waiting_lock_info == nullptr); + m_address_key = key; + m_address_key_value = val; + m_is_kernel_address_key = false; } void SetKernelAddressKey(VAddr key) { - ASSERT(waiting_lock_info == nullptr); - address_key = key; - is_kernel_address_key = true; + ASSERT(m_waiting_lock_info == nullptr); + m_address_key = key; + m_is_kernel_address_key = true; } void ClearWaitQueue() { - wait_queue = nullptr; + m_wait_queue = nullptr; } void BeginWait(KThreadQueue* queue); - void NotifyAvailable(KSynchronizationObject* signaled_object, Result wait_result_); - void EndWait(Result wait_result_); - void CancelWait(Result wait_result_, bool cancel_timer_task); + void NotifyAvailable(KSynchronizationObject* signaled_object, Result wait_result); + void EndWait(Result wait_result); + void CancelWait(Result wait_result, bool cancel_timer_task); - [[nodiscard]] s32 GetNumKernelWaiters() const { - return num_kernel_waiters; + s32 GetNumKernelWaiters() const { + return m_num_kernel_waiters; } - [[nodiscard]] u64 GetConditionVariableKey() const { - return condvar_key; + u64 GetConditionVariableKey() const { + return m_condvar_key; } - [[nodiscard]] u64 GetAddressArbiterKey() const { - return condvar_key; + u64 GetAddressArbiterKey() const { + return m_condvar_key; } // Dummy threads (used for HLE host threads) cannot wait based on the guest scheduler, and @@ -663,17 +633,16 @@ public: void DummyThreadBeginWait(); void DummyThreadEndWait(); - [[nodiscard]] uintptr_t GetArgument() const { - return argument; + uintptr_t GetArgument() const { + return m_argument; } - [[nodiscard]] VAddr GetUserStackTop() const { - return stack_top; + VAddr GetUserStackTop() const { + return m_stack_top; } private: - [[nodiscard]] KThread* RemoveWaiterByKey(bool* out_has_waiters, VAddr key, - bool is_kernel_address_key); + KThread* RemoveWaiterByKey(bool* out_has_waiters, VAddr key, bool is_kernel_address_key); static constexpr size_t PriorityInheritanceCountMax = 10; union SyncObjectBuffer { @@ -690,11 +659,11 @@ private: u64 cv_key{}; s32 priority{}; - [[nodiscard]] constexpr u64 GetConditionVariableKey() const { + constexpr u64 GetConditionVariableKey() const { return cv_key; } - [[nodiscard]] constexpr s32 GetPriority() const { + constexpr s32 GetPriority() const { return priority; } }; @@ -726,22 +695,21 @@ private: void IncreaseBasePriority(s32 priority); - [[nodiscard]] Result Initialize(KThreadFunction func, uintptr_t arg, VAddr user_stack_top, - s32 prio, s32 virt_core, KProcess* owner, ThreadType type); + Result Initialize(KThreadFunction func, uintptr_t arg, VAddr user_stack_top, s32 prio, + s32 virt_core, KProcess* owner, ThreadType type); - [[nodiscard]] static Result InitializeThread(KThread* thread, KThreadFunction func, - uintptr_t arg, VAddr user_stack_top, s32 prio, - s32 core, KProcess* owner, ThreadType type, - std::function<void()>&& init_func); + static Result InitializeThread(KThread* thread, KThreadFunction func, uintptr_t arg, + VAddr user_stack_top, s32 prio, s32 core, KProcess* owner, + ThreadType type, std::function<void()>&& init_func); // For core KThread implementation - ThreadContext32 thread_context_32{}; - ThreadContext64 thread_context_64{}; - Common::IntrusiveRedBlackTreeNode condvar_arbiter_tree_node{}; - s32 priority{}; + ThreadContext32 m_thread_context_32{}; + ThreadContext64 m_thread_context_64{}; + Common::IntrusiveRedBlackTreeNode m_condvar_arbiter_tree_node{}; + s32 m_priority{}; using ConditionVariableThreadTreeTraits = Common::IntrusiveRedBlackTreeMemberTraitsDeferredAssert< - &KThread::condvar_arbiter_tree_node>; + &KThread::m_condvar_arbiter_tree_node>; using ConditionVariableThreadTree = ConditionVariableThreadTreeTraits::TreeType<ConditionVariableComparator>; @@ -771,7 +739,7 @@ private: using LockWithPriorityInheritanceThreadTreeTraits = Common::IntrusiveRedBlackTreeMemberTraitsDeferredAssert< - &KThread::condvar_arbiter_tree_node>; + &KThread::m_condvar_arbiter_tree_node>; using LockWithPriorityInheritanceThreadTree = ConditionVariableThreadTreeTraits::TreeType<LockWithPriorityInheritanceComparator>; @@ -807,7 +775,7 @@ public: waiter->SetWaitingLockInfo(this); } - [[nodiscard]] bool RemoveWaiter(KThread* waiter) { + bool RemoveWaiter(KThread* waiter) { m_tree.erase(m_tree.iterator_to(*waiter)); waiter->SetWaitingLockInfo(nullptr); @@ -851,11 +819,11 @@ public: }; void SetWaitingLockInfo(LockWithPriorityInheritanceInfo* lock) { - waiting_lock_info = lock; + m_waiting_lock_info = lock; } LockWithPriorityInheritanceInfo* GetWaitingLockInfo() { - return waiting_lock_info; + return m_waiting_lock_info; } void AddHeldLock(LockWithPriorityInheritanceInfo* lock_info); @@ -865,111 +833,110 @@ private: using LockWithPriorityInheritanceInfoList = boost::intrusive::list<LockWithPriorityInheritanceInfo>; - ConditionVariableThreadTree* condvar_tree{}; - u64 condvar_key{}; - u64 virtual_affinity_mask{}; - KAffinityMask physical_affinity_mask{}; - u64 thread_id{}; - std::atomic<s64> cpu_time{}; - VAddr address_key{}; - KProcess* parent{}; - VAddr kernel_stack_top{}; - u32* light_ipc_data{}; - VAddr tls_address{}; - KLightLock activity_pause_lock; - s64 schedule_count{}; - s64 last_scheduled_tick{}; - std::array<QueueEntry, Core::Hardware::NUM_CPU_CORES> per_core_priority_queue_entry{}; - KThreadQueue* wait_queue{}; - LockWithPriorityInheritanceInfoList held_lock_info_list{}; - LockWithPriorityInheritanceInfo* waiting_lock_info{}; - WaiterList pinned_waiter_list{}; - u32 address_key_value{}; - u32 suspend_request_flags{}; - u32 suspend_allowed_flags{}; - s32 synced_index{}; - Result wait_result{ResultSuccess}; - s32 base_priority{}; - s32 physical_ideal_core_id{}; - s32 virtual_ideal_core_id{}; - s32 num_kernel_waiters{}; - s32 current_core_id{}; - s32 core_id{}; - KAffinityMask original_physical_affinity_mask{}; - s32 original_physical_ideal_core_id{}; - s32 num_core_migration_disables{}; - std::atomic<ThreadState> thread_state{}; - std::atomic<bool> termination_requested{}; - bool wait_cancelled{}; - bool cancellable{}; - bool signaled{}; - bool initialized{}; - bool debug_attached{}; - s8 priority_inheritance_count{}; - bool resource_limit_release_hint{}; - bool is_kernel_address_key{}; - StackParameters stack_parameters{}; - Common::SpinLock context_guard{}; + ConditionVariableThreadTree* m_condvar_tree{}; + u64 m_condvar_key{}; + u64 m_virtual_affinity_mask{}; + KAffinityMask m_physical_affinity_mask{}; + u64 m_thread_id{}; + std::atomic<s64> m_cpu_time{}; + VAddr m_address_key{}; + KProcess* m_parent{}; + VAddr m_kernel_stack_top{}; + u32* m_light_ipc_data{}; + VAddr m_tls_address{}; + KLightLock m_activity_pause_lock; + s64 m_schedule_count{}; + s64 m_last_scheduled_tick{}; + std::array<QueueEntry, Core::Hardware::NUM_CPU_CORES> m_per_core_priority_queue_entry{}; + KThreadQueue* m_wait_queue{}; + LockWithPriorityInheritanceInfoList m_held_lock_info_list{}; + LockWithPriorityInheritanceInfo* m_waiting_lock_info{}; + WaiterList m_pinned_waiter_list{}; + u32 m_address_key_value{}; + u32 m_suspend_request_flags{}; + u32 m_suspend_allowed_flags{}; + s32 m_synced_index{}; + Result m_wait_result{ResultSuccess}; + s32 m_base_priority{}; + s32 m_physical_ideal_core_id{}; + s32 m_virtual_ideal_core_id{}; + s32 m_num_kernel_waiters{}; + s32 m_current_core_id{}; + s32 m_core_id{}; + KAffinityMask m_original_physical_affinity_mask{}; + s32 m_original_physical_ideal_core_id{}; + s32 m_num_core_migration_disables{}; + std::atomic<ThreadState> m_thread_state{}; + std::atomic<bool> m_termination_requested{}; + bool m_wait_cancelled{}; + bool m_cancellable{}; + bool m_signaled{}; + bool m_initialized{}; + bool m_debug_attached{}; + s8 m_priority_inheritance_count{}; + bool m_resource_limit_release_hint{}; + bool m_is_kernel_address_key{}; + StackParameters m_stack_parameters{}; + Common::SpinLock m_context_guard{}; // For emulation - std::shared_ptr<Common::Fiber> host_context{}; - bool is_single_core{}; - ThreadType thread_type{}; - StepState step_state{}; - std::atomic<bool> dummy_thread_runnable{true}; + std::shared_ptr<Common::Fiber> m_host_context{}; + ThreadType m_thread_type{}; + StepState m_step_state{}; + std::atomic<bool> m_dummy_thread_runnable{true}; // For debugging - std::vector<KSynchronizationObject*> wait_objects_for_debugging; - VAddr mutex_wait_address_for_debugging{}; - ThreadWaitReasonForDebugging wait_reason_for_debugging{}; - uintptr_t argument{}; - VAddr stack_top{}; + std::vector<KSynchronizationObject*> m_wait_objects_for_debugging{}; + VAddr m_mutex_wait_address_for_debugging{}; + ThreadWaitReasonForDebugging m_wait_reason_for_debugging{}; + uintptr_t m_argument{}; + VAddr m_stack_top{}; public: using ConditionVariableThreadTreeType = ConditionVariableThreadTree; void SetConditionVariable(ConditionVariableThreadTree* tree, VAddr address, u64 cv_key, u32 value) { - ASSERT(waiting_lock_info == nullptr); - condvar_tree = tree; - condvar_key = cv_key; - address_key = address; - address_key_value = value; - is_kernel_address_key = false; + ASSERT(m_waiting_lock_info == nullptr); + m_condvar_tree = tree; + m_condvar_key = cv_key; + m_address_key = address; + m_address_key_value = value; + m_is_kernel_address_key = false; } void ClearConditionVariable() { - condvar_tree = nullptr; + m_condvar_tree = nullptr; } - [[nodiscard]] bool IsWaitingForConditionVariable() const { - return condvar_tree != nullptr; + bool IsWaitingForConditionVariable() const { + return m_condvar_tree != nullptr; } void SetAddressArbiter(ConditionVariableThreadTree* tree, u64 address) { - ASSERT(waiting_lock_info == nullptr); - condvar_tree = tree; - condvar_key = address; + ASSERT(m_waiting_lock_info == nullptr); + m_condvar_tree = tree; + m_condvar_key = address; } void ClearAddressArbiter() { - condvar_tree = nullptr; + m_condvar_tree = nullptr; } - [[nodiscard]] bool IsWaitingForAddressArbiter() const { - return condvar_tree != nullptr; + bool IsWaitingForAddressArbiter() const { + return m_condvar_tree != nullptr; } - [[nodiscard]] ConditionVariableThreadTree* GetConditionVariableTree() const { - return condvar_tree; + ConditionVariableThreadTree* GetConditionVariableTree() const { + return m_condvar_tree; } }; class KScopedDisableDispatch { public: - [[nodiscard]] explicit KScopedDisableDispatch(KernelCore& kernel_) : kernel{kernel_} { + explicit KScopedDisableDispatch(KernelCore& kernel) : m_kernel{kernel} { // If we are shutting down the kernel, none of this is relevant anymore. - if (kernel.IsShuttingDown()) { + if (m_kernel.IsShuttingDown()) { return; } GetCurrentThread(kernel).DisableDispatch(); @@ -978,7 +945,7 @@ public: ~KScopedDisableDispatch(); private: - KernelCore& kernel; + KernelCore& m_kernel; }; inline void KTimerTask::OnTimer() { diff --git a/src/core/hle/kernel/k_thread_local_page.cpp b/src/core/hle/kernel/k_thread_local_page.cpp index 563560114..c2af6898a 100644 --- a/src/core/hle/kernel/k_thread_local_page.cpp +++ b/src/core/hle/kernel/k_thread_local_page.cpp @@ -16,7 +16,7 @@ namespace Kernel { Result KThreadLocalPage::Initialize(KernelCore& kernel, KProcess* process) { // Set that this process owns us. m_owner = process; - m_kernel = &kernel; + m_kernel = std::addressof(kernel); // Allocate a new page. KPageBuffer* page_buf = KPageBuffer::Allocate(kernel); diff --git a/src/core/hle/kernel/k_thread_queue.cpp b/src/core/hle/kernel/k_thread_queue.cpp index 5f1dc97eb..61488f4ce 100644 --- a/src/core/hle/kernel/k_thread_queue.cpp +++ b/src/core/hle/kernel/k_thread_queue.cpp @@ -7,9 +7,10 @@ namespace Kernel { -void KThreadQueue::NotifyAvailable([[maybe_unused]] KThread* waiting_thread, - [[maybe_unused]] KSynchronizationObject* signaled_object, - [[maybe_unused]] Result wait_result) {} +void KThreadQueue::NotifyAvailable(KThread* waiting_thread, KSynchronizationObject* signaled_object, + Result wait_result) { + UNREACHABLE(); +} void KThreadQueue::EndWait(KThread* waiting_thread, Result wait_result) { // Set the thread's wait result. @@ -22,7 +23,9 @@ void KThreadQueue::EndWait(KThread* waiting_thread, Result wait_result) { waiting_thread->ClearWaitQueue(); // Cancel the thread task. - kernel.HardwareTimer().CancelTask(waiting_thread); + if (m_hardware_timer != nullptr) { + m_hardware_timer->CancelTask(waiting_thread); + } } void KThreadQueue::CancelWait(KThread* waiting_thread, Result wait_result, bool cancel_timer_task) { @@ -36,12 +39,13 @@ void KThreadQueue::CancelWait(KThread* waiting_thread, Result wait_result, bool waiting_thread->ClearWaitQueue(); // Cancel the thread task. - if (cancel_timer_task) { - kernel.HardwareTimer().CancelTask(waiting_thread); + if (cancel_timer_task && m_hardware_timer != nullptr) { + m_hardware_timer->CancelTask(waiting_thread); } } -void KThreadQueueWithoutEndWait::EndWait([[maybe_unused]] KThread* waiting_thread, - [[maybe_unused]] Result wait_result) {} +void KThreadQueueWithoutEndWait::EndWait(KThread* waiting_thread, Result wait_result) { + UNREACHABLE(); +} } // namespace Kernel diff --git a/src/core/hle/kernel/k_thread_queue.h b/src/core/hle/kernel/k_thread_queue.h index 8d76ece81..117af0919 100644 --- a/src/core/hle/kernel/k_thread_queue.h +++ b/src/core/hle/kernel/k_thread_queue.h @@ -8,24 +8,30 @@ namespace Kernel { +class KHardwareTimer; + class KThreadQueue { public: - explicit KThreadQueue(KernelCore& kernel_) : kernel{kernel_} {} + explicit KThreadQueue(KernelCore& kernel) : m_kernel{kernel}, m_hardware_timer{} {} virtual ~KThreadQueue() = default; + void SetHardwareTimer(KHardwareTimer* timer) { + m_hardware_timer = timer; + } + virtual void NotifyAvailable(KThread* waiting_thread, KSynchronizationObject* signaled_object, Result wait_result); virtual void EndWait(KThread* waiting_thread, Result wait_result); virtual void CancelWait(KThread* waiting_thread, Result wait_result, bool cancel_timer_task); private: - KernelCore& kernel; - KThread::WaiterList wait_list{}; + KernelCore& m_kernel; + KHardwareTimer* m_hardware_timer{}; }; class KThreadQueueWithoutEndWait : public KThreadQueue { public: - explicit KThreadQueueWithoutEndWait(KernelCore& kernel_) : KThreadQueue(kernel_) {} + explicit KThreadQueueWithoutEndWait(KernelCore& kernel) : KThreadQueue(kernel) {} void EndWait(KThread* waiting_thread, Result wait_result) override final; }; diff --git a/src/core/hle/kernel/k_transfer_memory.cpp b/src/core/hle/kernel/k_transfer_memory.cpp index faa5c73b5..471349282 100644 --- a/src/core/hle/kernel/k_transfer_memory.cpp +++ b/src/core/hle/kernel/k_transfer_memory.cpp @@ -8,32 +8,29 @@ namespace Kernel { -KTransferMemory::KTransferMemory(KernelCore& kernel_) - : KAutoObjectWithSlabHeapAndContainer{kernel_} {} +KTransferMemory::KTransferMemory(KernelCore& kernel) + : KAutoObjectWithSlabHeapAndContainer{kernel} {} KTransferMemory::~KTransferMemory() = default; -Result KTransferMemory::Initialize(VAddr address_, std::size_t size_, - Svc::MemoryPermission owner_perm_) { +Result KTransferMemory::Initialize(VAddr address, std::size_t size, + Svc::MemoryPermission owner_perm) { // Set members. - owner = GetCurrentProcessPointer(kernel); + m_owner = GetCurrentProcessPointer(m_kernel); // TODO(bunnei): Lock for transfer memory // Set remaining tracking members. - owner->Open(); - owner_perm = owner_perm_; - address = address_; - size = size_; - is_initialized = true; + m_owner->Open(); + m_owner_perm = owner_perm; + m_address = address; + m_size = size; + m_is_initialized = true; - return ResultSuccess; + R_SUCCEED(); } -void KTransferMemory::Finalize() { - // Perform inherited finalization. - KAutoObjectWithSlabHeapAndContainer<KTransferMemory, KAutoObjectWithList>::Finalize(); -} +void KTransferMemory::Finalize() {} void KTransferMemory::PostDestroy(uintptr_t arg) { KProcess* owner = reinterpret_cast<KProcess*>(arg); diff --git a/src/core/hle/kernel/k_transfer_memory.h b/src/core/hle/kernel/k_transfer_memory.h index 85d508ee7..3d4d795a5 100644 --- a/src/core/hle/kernel/k_transfer_memory.h +++ b/src/core/hle/kernel/k_transfer_memory.h @@ -23,41 +23,41 @@ class KTransferMemory final KERNEL_AUTOOBJECT_TRAITS(KTransferMemory, KAutoObject); public: - explicit KTransferMemory(KernelCore& kernel_); + explicit KTransferMemory(KernelCore& kernel); ~KTransferMemory() override; - Result Initialize(VAddr address_, std::size_t size_, Svc::MemoryPermission owner_perm_); + Result Initialize(VAddr address, std::size_t size, Svc::MemoryPermission owner_perm); void Finalize() override; bool IsInitialized() const override { - return is_initialized; + return m_is_initialized; } uintptr_t GetPostDestroyArgument() const override { - return reinterpret_cast<uintptr_t>(owner); + return reinterpret_cast<uintptr_t>(m_owner); } static void PostDestroy(uintptr_t arg); KProcess* GetOwner() const override { - return owner; + return m_owner; } VAddr GetSourceAddress() const { - return address; + return m_address; } size_t GetSize() const { - return is_initialized ? size : 0; + return m_is_initialized ? m_size : 0; } private: - KProcess* owner{}; - VAddr address{}; - Svc::MemoryPermission owner_perm{}; - size_t size{}; - bool is_initialized{}; + KProcess* m_owner{}; + VAddr m_address{}; + Svc::MemoryPermission m_owner_perm{}; + size_t m_size{}; + bool m_is_initialized{}; }; } // namespace Kernel diff --git a/src/core/hle/kernel/k_worker_task.h b/src/core/hle/kernel/k_worker_task.h index ef591d831..9a230c03c 100644 --- a/src/core/hle/kernel/k_worker_task.h +++ b/src/core/hle/kernel/k_worker_task.h @@ -9,7 +9,7 @@ namespace Kernel { class KWorkerTask : public KSynchronizationObject { public: - explicit KWorkerTask(KernelCore& kernel_); + explicit KWorkerTask(KernelCore& kernel); void DoWorkerTask(); }; diff --git a/src/core/hle/kernel/k_worker_task_manager.cpp b/src/core/hle/kernel/k_worker_task_manager.cpp index 04042bf8f..8ead39591 100644 --- a/src/core/hle/kernel/k_worker_task_manager.cpp +++ b/src/core/hle/kernel/k_worker_task_manager.cpp @@ -10,7 +10,7 @@ namespace Kernel { -KWorkerTask::KWorkerTask(KernelCore& kernel_) : KSynchronizationObject{kernel_} {} +KWorkerTask::KWorkerTask(KernelCore& kernel) : KSynchronizationObject{kernel} {} void KWorkerTask::DoWorkerTask() { if (auto* const thread = this->DynamicCast<KThread*>(); thread != nullptr) { diff --git a/src/core/hle/kernel/k_worker_task_manager.h b/src/core/hle/kernel/k_worker_task_manager.h index f6618883e..8745a4ce2 100644 --- a/src/core/hle/kernel/k_worker_task_manager.h +++ b/src/core/hle/kernel/k_worker_task_manager.h @@ -20,7 +20,7 @@ public: KWorkerTaskManager(); - static void AddTask(KernelCore& kernel_, WorkerType type, KWorkerTask* task); + static void AddTask(KernelCore& kernel, WorkerType type, KWorkerTask* task); private: void AddTask(KernelCore& kernel, KWorkerTask* task); diff --git a/src/core/hle/kernel/kernel.cpp b/src/core/hle/kernel/kernel.cpp index ef7057ff7..98ecaf12f 100644 --- a/src/core/hle/kernel/kernel.cpp +++ b/src/core/hle/kernel/kernel.cpp @@ -214,7 +214,6 @@ struct KernelCore::Impl { cores[i] = std::make_unique<Kernel::PhysicalCore>(i, system, *schedulers[i]); auto* main_thread{Kernel::KThread::Create(system.Kernel())}; - main_thread->SetName(fmt::format("MainThread:{}", core)); main_thread->SetCurrentCore(core); ASSERT(Kernel::KThread::InitializeMainThread(system, main_thread, core).IsSuccess()); @@ -356,7 +355,6 @@ struct KernelCore::Impl { ASSERT(KThread::InitializeHighPriorityThread(system, shutdown_threads[core_id], {}, {}, core_id) .IsSuccess()); - shutdown_threads[core_id]->SetName(fmt::format("SuspendThread:{}", core_id)); } } @@ -388,11 +386,10 @@ struct KernelCore::Impl { // Gets the dummy KThread for the caller, allocating a new one if this is the first time KThread* GetHostDummyThread(KThread* existing_thread) { - auto initialize = [this](KThread* thread) { + const auto initialize{[](KThread* thread) { ASSERT(KThread::InitializeDummyThread(thread, nullptr).IsSuccess()); - thread->SetName(fmt::format("DummyThread:{}", next_host_thread_id++)); return thread; - }; + }}; thread_local KThread raw_thread{system.Kernel()}; thread_local KThread* thread = existing_thread ? existing_thread : initialize(&raw_thread); @@ -742,16 +739,15 @@ struct KernelCore::Impl { hidbus_shared_mem = KSharedMemory::Create(system.Kernel()); hid_shared_mem->Initialize(system.DeviceMemory(), nullptr, Svc::MemoryPermission::None, - Svc::MemoryPermission::Read, hid_size, "HID:SharedMemory"); + Svc::MemoryPermission::Read, hid_size); font_shared_mem->Initialize(system.DeviceMemory(), nullptr, Svc::MemoryPermission::None, - Svc::MemoryPermission::Read, font_size, "Font:SharedMemory"); + Svc::MemoryPermission::Read, font_size); irs_shared_mem->Initialize(system.DeviceMemory(), nullptr, Svc::MemoryPermission::None, - Svc::MemoryPermission::Read, irs_size, "IRS:SharedMemory"); + Svc::MemoryPermission::Read, irs_size); time_shared_mem->Initialize(system.DeviceMemory(), nullptr, Svc::MemoryPermission::None, - Svc::MemoryPermission::Read, time_size, "Time:SharedMemory"); + Svc::MemoryPermission::Read, time_size); hidbus_shared_mem->Initialize(system.DeviceMemory(), nullptr, Svc::MemoryPermission::None, - Svc::MemoryPermission::Read, hidbus_size, - "HidBus:SharedMemory"); + Svc::MemoryPermission::Read, hidbus_size); } std::mutex registered_objects_lock; @@ -1321,7 +1317,6 @@ const Core::System& KernelCore::System() const { struct KernelCore::SlabHeapContainer { KSlabHeap<KClientSession> client_session; KSlabHeap<KEvent> event; - KSlabHeap<KLinkedListNode> linked_list_node; KSlabHeap<KPort> port; KSlabHeap<KProcess> process; KSlabHeap<KResourceLimit> resource_limit; @@ -1348,8 +1343,6 @@ KSlabHeap<T>& KernelCore::SlabHeap() { return slab_heap_container->client_session; } else if constexpr (std::is_same_v<T, KEvent>) { return slab_heap_container->event; - } else if constexpr (std::is_same_v<T, KLinkedListNode>) { - return slab_heap_container->linked_list_node; } else if constexpr (std::is_same_v<T, KPort>) { return slab_heap_container->port; } else if constexpr (std::is_same_v<T, KProcess>) { @@ -1391,7 +1384,6 @@ KSlabHeap<T>& KernelCore::SlabHeap() { template KSlabHeap<KClientSession>& KernelCore::SlabHeap(); template KSlabHeap<KEvent>& KernelCore::SlabHeap(); -template KSlabHeap<KLinkedListNode>& KernelCore::SlabHeap(); template KSlabHeap<KPort>& KernelCore::SlabHeap(); template KSlabHeap<KProcess>& KernelCore::SlabHeap(); template KSlabHeap<KResourceLimit>& KernelCore::SlabHeap(); diff --git a/src/core/hle/kernel/kernel.h b/src/core/hle/kernel/kernel.h index 1b380a07b..183a4d227 100644 --- a/src/core/hle/kernel/kernel.h +++ b/src/core/hle/kernel/kernel.h @@ -47,7 +47,6 @@ class KEvent; class KEventInfo; class KHandleTable; class KHardwareTimer; -class KLinkedListNode; class KMemoryLayout; class KMemoryManager; class KObjectName; diff --git a/src/core/hle/kernel/physical_core.cpp b/src/core/hle/kernel/physical_core.cpp index 3044922ac..2e0c36129 100644 --- a/src/core/hle/kernel/physical_core.cpp +++ b/src/core/hle/kernel/physical_core.cpp @@ -10,14 +10,14 @@ namespace Kernel { -PhysicalCore::PhysicalCore(std::size_t core_index_, Core::System& system_, KScheduler& scheduler_) - : core_index{core_index_}, system{system_}, scheduler{scheduler_} { +PhysicalCore::PhysicalCore(std::size_t core_index, Core::System& system, KScheduler& scheduler) + : m_core_index{core_index}, m_system{system}, m_scheduler{scheduler} { #if defined(ARCHITECTURE_x86_64) || defined(ARCHITECTURE_arm64) // TODO(bunnei): Initialization relies on a core being available. We may later replace this with // a 32-bit instance of Dynarmic. This should be abstracted out to a CPU manager. auto& kernel = system.Kernel(); - arm_interface = std::make_unique<Core::ARM_Dynarmic_64>( - system, kernel.IsMulticore(), kernel.GetExclusiveMonitor(), core_index); + m_arm_interface = std::make_unique<Core::ARM_Dynarmic_64>( + system, kernel.IsMulticore(), kernel.GetExclusiveMonitor(), m_core_index); #else #error Platform not supported yet. #endif @@ -25,13 +25,13 @@ PhysicalCore::PhysicalCore(std::size_t core_index_, Core::System& system_, KSche PhysicalCore::~PhysicalCore() = default; -void PhysicalCore::Initialize([[maybe_unused]] bool is_64_bit) { +void PhysicalCore::Initialize(bool is_64_bit) { #if defined(ARCHITECTURE_x86_64) || defined(ARCHITECTURE_arm64) - auto& kernel = system.Kernel(); + auto& kernel = m_system.Kernel(); if (!is_64_bit) { // We already initialized a 64-bit core, replace with a 32-bit one. - arm_interface = std::make_unique<Core::ARM_Dynarmic_32>( - system, kernel.IsMulticore(), kernel.GetExclusiveMonitor(), core_index); + m_arm_interface = std::make_unique<Core::ARM_Dynarmic_32>( + m_system, kernel.IsMulticore(), kernel.GetExclusiveMonitor(), m_core_index); } #else #error Platform not supported yet. @@ -39,31 +39,30 @@ void PhysicalCore::Initialize([[maybe_unused]] bool is_64_bit) { } void PhysicalCore::Run() { - arm_interface->Run(); - arm_interface->ClearExclusiveState(); + m_arm_interface->Run(); + m_arm_interface->ClearExclusiveState(); } void PhysicalCore::Idle() { - std::unique_lock lk{guard}; - on_interrupt.wait(lk, [this] { return is_interrupted; }); + std::unique_lock lk{m_guard}; + m_on_interrupt.wait(lk, [this] { return m_is_interrupted; }); } bool PhysicalCore::IsInterrupted() const { - return is_interrupted; + return m_is_interrupted; } void PhysicalCore::Interrupt() { - std::unique_lock lk{guard}; - is_interrupted = true; - arm_interface->SignalInterrupt(); - on_interrupt.notify_all(); + std::unique_lock lk{m_guard}; + m_is_interrupted = true; + m_arm_interface->SignalInterrupt(); + m_on_interrupt.notify_all(); } void PhysicalCore::ClearInterrupt() { - std::unique_lock lk{guard}; - is_interrupted = false; - arm_interface->ClearInterrupt(); - on_interrupt.notify_all(); + std::unique_lock lk{m_guard}; + m_is_interrupted = false; + m_arm_interface->ClearInterrupt(); } } // namespace Kernel diff --git a/src/core/hle/kernel/physical_core.h b/src/core/hle/kernel/physical_core.h index fb8e7933e..5cb398fdc 100644 --- a/src/core/hle/kernel/physical_core.h +++ b/src/core/hle/kernel/physical_core.h @@ -47,46 +47,38 @@ public: bool IsInterrupted() const; bool IsInitialized() const { - return arm_interface != nullptr; + return m_arm_interface != nullptr; } Core::ARM_Interface& ArmInterface() { - return *arm_interface; + return *m_arm_interface; } const Core::ARM_Interface& ArmInterface() const { - return *arm_interface; - } - - bool IsMainCore() const { - return core_index == 0; - } - - bool IsSystemCore() const { - return core_index == 3; + return *m_arm_interface; } std::size_t CoreIndex() const { - return core_index; + return m_core_index; } Kernel::KScheduler& Scheduler() { - return scheduler; + return m_scheduler; } const Kernel::KScheduler& Scheduler() const { - return scheduler; + return m_scheduler; } private: - const std::size_t core_index; - Core::System& system; - Kernel::KScheduler& scheduler; - - std::mutex guard; - std::condition_variable on_interrupt; - std::unique_ptr<Core::ARM_Interface> arm_interface; - bool is_interrupted{}; + const std::size_t m_core_index; + Core::System& m_system; + Kernel::KScheduler& m_scheduler; + + std::mutex m_guard; + std::condition_variable m_on_interrupt; + std::unique_ptr<Core::ARM_Interface> m_arm_interface; + bool m_is_interrupted{}; }; } // namespace Kernel diff --git a/src/core/hle/kernel/slab_helpers.h b/src/core/hle/kernel/slab_helpers.h index 0228ce188..d1bbc7670 100644 --- a/src/core/hle/kernel/slab_helpers.h +++ b/src/core/hle/kernel/slab_helpers.h @@ -66,7 +66,7 @@ private: } public: - explicit KAutoObjectWithSlabHeap(KernelCore& kernel_) : Base(kernel_), kernel(kernel_) {} + explicit KAutoObjectWithSlabHeap(KernelCore& kernel) : Base(kernel) {} virtual ~KAutoObjectWithSlabHeap() = default; virtual void Destroy() override { @@ -76,7 +76,7 @@ public: arg = this->GetPostDestroyArgument(); this->Finalize(); } - Free(kernel, static_cast<Derived*>(this)); + Free(Base::m_kernel, static_cast<Derived*>(this)); if (is_initialized) { Derived::PostDestroy(arg); } @@ -90,7 +90,7 @@ public: } size_t GetSlabIndex() const { - return SlabHeap<Derived>(kernel).GetObjectIndex(static_cast<const Derived*>(this)); + return SlabHeap<Derived>(Base::m_kernel).GetObjectIndex(static_cast<const Derived*>(this)); } public: @@ -125,14 +125,11 @@ public: static size_t GetNumRemaining(KernelCore& kernel) { return kernel.SlabHeap<Derived>().GetNumRemaining(); } - -protected: - KernelCore& kernel; }; template <typename Derived, typename Base> class KAutoObjectWithSlabHeapAndContainer : public Base { - static_assert(std::is_base_of<KAutoObjectWithList, Base>::value); + static_assert(std::is_base_of_v<KAutoObjectWithList, Base>); private: static Derived* Allocate(KernelCore& kernel) { @@ -144,18 +141,18 @@ private: } public: - KAutoObjectWithSlabHeapAndContainer(KernelCore& kernel_) : Base(kernel_), kernel(kernel_) {} + KAutoObjectWithSlabHeapAndContainer(KernelCore& kernel) : Base(kernel) {} virtual ~KAutoObjectWithSlabHeapAndContainer() {} virtual void Destroy() override { const bool is_initialized = this->IsInitialized(); uintptr_t arg = 0; if (is_initialized) { - kernel.ObjectListContainer().Unregister(this); + Base::m_kernel.ObjectListContainer().Unregister(this); arg = this->GetPostDestroyArgument(); this->Finalize(); } - Free(kernel, static_cast<Derived*>(this)); + Free(Base::m_kernel, static_cast<Derived*>(this)); if (is_initialized) { Derived::PostDestroy(arg); } @@ -169,7 +166,7 @@ public: } size_t GetSlabIndex() const { - return SlabHeap<Derived>(kernel).GetObjectIndex(static_cast<const Derived*>(this)); + return SlabHeap<Derived>(Base::m_kernel).GetObjectIndex(static_cast<const Derived*>(this)); } public: @@ -209,9 +206,6 @@ public: static size_t GetNumRemaining(KernelCore& kernel) { return kernel.SlabHeap<Derived>().GetNumRemaining(); } - -protected: - KernelCore& kernel; }; } // namespace Kernel diff --git a/src/core/hle/kernel/svc.cpp b/src/core/hle/kernel/svc.cpp index a0bfd6bbc..871d541d4 100644 --- a/src/core/hle/kernel/svc.cpp +++ b/src/core/hle/kernel/svc.cpp @@ -36,9 +36,9 @@ static To Convert(const From& from) { To to{}; if constexpr (sizeof(To) >= sizeof(From)) { - std::memcpy(&to, &from, sizeof(From)); + std::memcpy(std::addressof(to), std::addressof(from), sizeof(From)); } else { - std::memcpy(&to, &from, sizeof(To)); + std::memcpy(std::addressof(to), std::addressof(from), sizeof(To)); } return to; @@ -87,7 +87,7 @@ static void SvcWrap_SetHeapSize64From32(Core::System& system) { size = Convert<uint32_t>(GetReg32(system, 1)); - ret = SetHeapSize64From32(system, &out_address, size); + ret = SetHeapSize64From32(system, std::addressof(out_address), size); SetReg32(system, 0, Convert<uint32_t>(ret)); SetReg32(system, 1, Convert<uint32_t>(out_address)); @@ -169,7 +169,7 @@ static void SvcWrap_QueryMemory64From32(Core::System& system) { out_memory_info = Convert<uint32_t>(GetReg32(system, 0)); address = Convert<uint32_t>(GetReg32(system, 2)); - ret = QueryMemory64From32(system, out_memory_info, &out_page_info, address); + ret = QueryMemory64From32(system, out_memory_info, std::addressof(out_page_info), address); SetReg32(system, 0, Convert<uint32_t>(ret)); SetReg32(system, 1, Convert<uint32_t>(out_page_info)); @@ -195,7 +195,7 @@ static void SvcWrap_CreateThread64From32(Core::System& system) { priority = Convert<int32_t>(GetReg32(system, 0)); core_id = Convert<int32_t>(GetReg32(system, 4)); - ret = CreateThread64From32(system, &out_handle, func, arg, stack_bottom, priority, core_id); + ret = CreateThread64From32(system, std::addressof(out_handle), func, arg, stack_bottom, priority, core_id); SetReg32(system, 0, Convert<uint32_t>(ret)); SetReg32(system, 1, Convert<uint32_t>(out_handle)); @@ -236,7 +236,7 @@ static void SvcWrap_GetThreadPriority64From32(Core::System& system) { thread_handle = Convert<Handle>(GetReg32(system, 1)); - ret = GetThreadPriority64From32(system, &out_priority, thread_handle); + ret = GetThreadPriority64From32(system, std::addressof(out_priority), thread_handle); SetReg32(system, 0, Convert<uint32_t>(ret)); SetReg32(system, 1, Convert<uint32_t>(out_priority)); @@ -265,7 +265,7 @@ static void SvcWrap_GetThreadCoreMask64From32(Core::System& system) { thread_handle = Convert<Handle>(GetReg32(system, 2)); - ret = GetThreadCoreMask64From32(system, &out_core_id, &out_affinity_mask, thread_handle); + ret = GetThreadCoreMask64From32(system, std::addressof(out_core_id), std::addressof(out_affinity_mask), thread_handle); SetReg32(system, 0, Convert<uint32_t>(ret)); SetReg32(system, 1, Convert<uint32_t>(out_core_id)); @@ -371,7 +371,7 @@ static void SvcWrap_CreateTransferMemory64From32(Core::System& system) { size = Convert<uint32_t>(GetReg32(system, 2)); map_perm = Convert<MemoryPermission>(GetReg32(system, 3)); - ret = CreateTransferMemory64From32(system, &out_handle, address, size, map_perm); + ret = CreateTransferMemory64From32(system, std::addressof(out_handle), address, size, map_perm); SetReg32(system, 0, Convert<uint32_t>(ret)); SetReg32(system, 1, Convert<uint32_t>(out_handle)); @@ -416,7 +416,7 @@ static void SvcWrap_WaitSynchronization64From32(Core::System& system) { timeout_ns_gather[1] = GetReg32(system, 3); timeout_ns = Convert<int64_t>(timeout_ns_gather); - ret = WaitSynchronization64From32(system, &out_index, handles, num_handles, timeout_ns); + ret = WaitSynchronization64From32(system, std::addressof(out_index), handles, num_handles, timeout_ns); SetReg32(system, 0, Convert<uint32_t>(ret)); SetReg32(system, 1, Convert<uint32_t>(out_index)); @@ -511,7 +511,7 @@ static void SvcWrap_ConnectToNamedPort64From32(Core::System& system) { name = Convert<uint32_t>(GetReg32(system, 1)); - ret = ConnectToNamedPort64From32(system, &out_handle, name); + ret = ConnectToNamedPort64From32(system, std::addressof(out_handle), name); SetReg32(system, 0, Convert<uint32_t>(ret)); SetReg32(system, 1, Convert<uint32_t>(out_handle)); @@ -557,7 +557,7 @@ static void SvcWrap_SendAsyncRequestWithUserBuffer64From32(Core::System& system) message_buffer_size = Convert<uint32_t>(GetReg32(system, 2)); session_handle = Convert<Handle>(GetReg32(system, 3)); - ret = SendAsyncRequestWithUserBuffer64From32(system, &out_event_handle, message_buffer, message_buffer_size, session_handle); + ret = SendAsyncRequestWithUserBuffer64From32(system, std::addressof(out_event_handle), message_buffer, message_buffer_size, session_handle); SetReg32(system, 0, Convert<uint32_t>(ret)); SetReg32(system, 1, Convert<uint32_t>(out_event_handle)); @@ -571,7 +571,7 @@ static void SvcWrap_GetProcessId64From32(Core::System& system) { process_handle = Convert<Handle>(GetReg32(system, 1)); - ret = GetProcessId64From32(system, &out_process_id, process_handle); + ret = GetProcessId64From32(system, std::addressof(out_process_id), process_handle); SetReg32(system, 0, Convert<uint32_t>(ret)); auto out_process_id_scatter = Convert<std::array<uint32_t, 2>>(out_process_id); @@ -587,7 +587,7 @@ static void SvcWrap_GetThreadId64From32(Core::System& system) { thread_handle = Convert<Handle>(GetReg32(system, 1)); - ret = GetThreadId64From32(system, &out_thread_id, thread_handle); + ret = GetThreadId64From32(system, std::addressof(out_thread_id), thread_handle); SetReg32(system, 0, Convert<uint32_t>(ret)); auto out_thread_id_scatter = Convert<std::array<uint32_t, 2>>(out_thread_id); @@ -644,7 +644,7 @@ static void SvcWrap_GetInfo64From32(Core::System& system) { info_subtype_gather[1] = GetReg32(system, 3); info_subtype = Convert<uint64_t>(info_subtype_gather); - ret = GetInfo64From32(system, &out, info_type, handle, info_subtype); + ret = GetInfo64From32(system, std::addressof(out), info_type, handle, info_subtype); SetReg32(system, 0, Convert<uint32_t>(ret)); auto out_scatter = Convert<std::array<uint32_t, 2>>(out); @@ -712,7 +712,7 @@ static void SvcWrap_GetDebugFutureThreadInfo64From32(Core::System& system) { ns_gather[1] = GetReg32(system, 1); ns = Convert<int64_t>(ns_gather); - ret = GetDebugFutureThreadInfo64From32(system, &out_context, &out_thread_id, debug_handle, ns); + ret = GetDebugFutureThreadInfo64From32(system, std::addressof(out_context), std::addressof(out_thread_id), debug_handle, ns); SetReg32(system, 0, Convert<uint32_t>(ret)); auto out_context_scatter = Convert<std::array<uint32_t, 4>>(out_context); @@ -732,7 +732,7 @@ static void SvcWrap_GetLastThreadInfo64From32(Core::System& system) { uint64_t out_tls_address{}; uint32_t out_flags{}; - ret = GetLastThreadInfo64From32(system, &out_context, &out_tls_address, &out_flags); + ret = GetLastThreadInfo64From32(system, std::addressof(out_context), std::addressof(out_tls_address), std::addressof(out_flags)); SetReg32(system, 0, Convert<uint32_t>(ret)); auto out_context_scatter = Convert<std::array<uint32_t, 4>>(out_context); @@ -754,7 +754,7 @@ static void SvcWrap_GetResourceLimitLimitValue64From32(Core::System& system) { resource_limit_handle = Convert<Handle>(GetReg32(system, 1)); which = Convert<LimitableResource>(GetReg32(system, 2)); - ret = GetResourceLimitLimitValue64From32(system, &out_limit_value, resource_limit_handle, which); + ret = GetResourceLimitLimitValue64From32(system, std::addressof(out_limit_value), resource_limit_handle, which); SetReg32(system, 0, Convert<uint32_t>(ret)); auto out_limit_value_scatter = Convert<std::array<uint32_t, 2>>(out_limit_value); @@ -772,7 +772,7 @@ static void SvcWrap_GetResourceLimitCurrentValue64From32(Core::System& system) { resource_limit_handle = Convert<Handle>(GetReg32(system, 1)); which = Convert<LimitableResource>(GetReg32(system, 2)); - ret = GetResourceLimitCurrentValue64From32(system, &out_current_value, resource_limit_handle, which); + ret = GetResourceLimitCurrentValue64From32(system, std::addressof(out_current_value), resource_limit_handle, which); SetReg32(system, 0, Convert<uint32_t>(ret)); auto out_current_value_scatter = Convert<std::array<uint32_t, 2>>(out_current_value); @@ -861,7 +861,7 @@ static void SvcWrap_GetResourceLimitPeakValue64From32(Core::System& system) { resource_limit_handle = Convert<Handle>(GetReg32(system, 1)); which = Convert<LimitableResource>(GetReg32(system, 2)); - ret = GetResourceLimitPeakValue64From32(system, &out_peak_value, resource_limit_handle, which); + ret = GetResourceLimitPeakValue64From32(system, std::addressof(out_peak_value), resource_limit_handle, which); SetReg32(system, 0, Convert<uint32_t>(ret)); auto out_peak_value_scatter = Convert<std::array<uint32_t, 2>>(out_peak_value); @@ -877,7 +877,7 @@ static void SvcWrap_CreateIoPool64From32(Core::System& system) { which = Convert<IoPoolType>(GetReg32(system, 1)); - ret = CreateIoPool64From32(system, &out_handle, which); + ret = CreateIoPool64From32(system, std::addressof(out_handle), which); SetReg32(system, 0, Convert<uint32_t>(ret)); SetReg32(system, 1, Convert<uint32_t>(out_handle)); @@ -902,7 +902,7 @@ static void SvcWrap_CreateIoRegion64From32(Core::System& system) { mapping = Convert<MemoryMapping>(GetReg32(system, 4)); perm = Convert<MemoryPermission>(GetReg32(system, 5)); - ret = CreateIoRegion64From32(system, &out_handle, io_pool, physical_address, size, mapping, perm); + ret = CreateIoRegion64From32(system, std::addressof(out_handle), io_pool, physical_address, size, mapping, perm); SetReg32(system, 0, Convert<uint32_t>(ret)); SetReg32(system, 1, Convert<uint32_t>(out_handle)); @@ -950,7 +950,7 @@ static void SvcWrap_CreateSession64From32(Core::System& system) { is_light = Convert<bool>(GetReg32(system, 2)); name = Convert<uint32_t>(GetReg32(system, 3)); - ret = CreateSession64From32(system, &out_server_session_handle, &out_client_session_handle, is_light, name); + ret = CreateSession64From32(system, std::addressof(out_server_session_handle), std::addressof(out_client_session_handle), is_light, name); SetReg32(system, 0, Convert<uint32_t>(ret)); SetReg32(system, 1, Convert<uint32_t>(out_server_session_handle)); @@ -965,7 +965,7 @@ static void SvcWrap_AcceptSession64From32(Core::System& system) { port = Convert<Handle>(GetReg32(system, 1)); - ret = AcceptSession64From32(system, &out_handle, port); + ret = AcceptSession64From32(system, std::addressof(out_handle), port); SetReg32(system, 0, Convert<uint32_t>(ret)); SetReg32(system, 1, Convert<uint32_t>(out_handle)); @@ -988,7 +988,7 @@ static void SvcWrap_ReplyAndReceive64From32(Core::System& system) { timeout_ns_gather[1] = GetReg32(system, 4); timeout_ns = Convert<int64_t>(timeout_ns_gather); - ret = ReplyAndReceive64From32(system, &out_index, handles, num_handles, reply_target, timeout_ns); + ret = ReplyAndReceive64From32(system, std::addressof(out_index), handles, num_handles, reply_target, timeout_ns); SetReg32(system, 0, Convert<uint32_t>(ret)); SetReg32(system, 1, Convert<uint32_t>(out_index)); @@ -1015,7 +1015,7 @@ static void SvcWrap_ReplyAndReceiveWithUserBuffer64From32(Core::System& system) timeout_ns_gather[1] = GetReg32(system, 6); timeout_ns = Convert<int64_t>(timeout_ns_gather); - ret = ReplyAndReceiveWithUserBuffer64From32(system, &out_index, message_buffer, message_buffer_size, handles, num_handles, reply_target, timeout_ns); + ret = ReplyAndReceiveWithUserBuffer64From32(system, std::addressof(out_index), message_buffer, message_buffer_size, handles, num_handles, reply_target, timeout_ns); SetReg32(system, 0, Convert<uint32_t>(ret)); SetReg32(system, 1, Convert<uint32_t>(out_index)); @@ -1027,7 +1027,7 @@ static void SvcWrap_CreateEvent64From32(Core::System& system) { Handle out_write_handle{}; Handle out_read_handle{}; - ret = CreateEvent64From32(system, &out_write_handle, &out_read_handle); + ret = CreateEvent64From32(system, std::addressof(out_write_handle), std::addressof(out_read_handle)); SetReg32(system, 0, Convert<uint32_t>(ret)); SetReg32(system, 1, Convert<uint32_t>(out_write_handle)); @@ -1118,7 +1118,7 @@ static void SvcWrap_CreateCodeMemory64From32(Core::System& system) { address = Convert<uint32_t>(GetReg32(system, 1)); size = Convert<uint32_t>(GetReg32(system, 2)); - ret = CreateCodeMemory64From32(system, &out_handle, address, size); + ret = CreateCodeMemory64From32(system, std::addressof(out_handle), address, size); SetReg32(system, 0, Convert<uint32_t>(ret)); SetReg32(system, 1, Convert<uint32_t>(out_handle)); @@ -1169,7 +1169,7 @@ static void SvcWrap_ReadWriteRegister64From32(Core::System& system) { mask = Convert<uint32_t>(GetReg32(system, 0)); value = Convert<uint32_t>(GetReg32(system, 1)); - ret = ReadWriteRegister64From32(system, &out_value, address, mask, value); + ret = ReadWriteRegister64From32(system, std::addressof(out_value), address, mask, value); SetReg32(system, 0, Convert<uint32_t>(ret)); SetReg32(system, 1, Convert<uint32_t>(out_value)); @@ -1201,7 +1201,7 @@ static void SvcWrap_CreateSharedMemory64From32(Core::System& system) { owner_perm = Convert<MemoryPermission>(GetReg32(system, 2)); remote_perm = Convert<MemoryPermission>(GetReg32(system, 3)); - ret = CreateSharedMemory64From32(system, &out_handle, size, owner_perm, remote_perm); + ret = CreateSharedMemory64From32(system, std::addressof(out_handle), size, owner_perm, remote_perm); SetReg32(system, 0, Convert<uint32_t>(ret)); SetReg32(system, 1, Convert<uint32_t>(out_handle)); @@ -1251,7 +1251,7 @@ static void SvcWrap_CreateInterruptEvent64From32(Core::System& system) { interrupt_id = Convert<int32_t>(GetReg32(system, 1)); interrupt_type = Convert<InterruptType>(GetReg32(system, 2)); - ret = CreateInterruptEvent64From32(system, &out_read_handle, interrupt_id, interrupt_type); + ret = CreateInterruptEvent64From32(system, std::addressof(out_read_handle), interrupt_id, interrupt_type); SetReg32(system, 0, Convert<uint32_t>(ret)); SetReg32(system, 1, Convert<uint32_t>(out_read_handle)); @@ -1265,7 +1265,7 @@ static void SvcWrap_QueryPhysicalAddress64From32(Core::System& system) { address = Convert<uint32_t>(GetReg32(system, 1)); - ret = QueryPhysicalAddress64From32(system, &out_info, address); + ret = QueryPhysicalAddress64From32(system, std::addressof(out_info), address); SetReg32(system, 0, Convert<uint32_t>(ret)); auto out_info_scatter = Convert<std::array<uint32_t, 4>>(out_info); @@ -1289,7 +1289,7 @@ static void SvcWrap_QueryIoMapping64From32(Core::System& system) { physical_address = Convert<uint64_t>(physical_address_gather); size = Convert<uint32_t>(GetReg32(system, 0)); - ret = QueryIoMapping64From32(system, &out_address, &out_size, physical_address, size); + ret = QueryIoMapping64From32(system, std::addressof(out_address), std::addressof(out_size), physical_address, size); SetReg32(system, 0, Convert<uint32_t>(ret)); SetReg32(system, 1, Convert<uint32_t>(out_address)); @@ -1312,7 +1312,7 @@ static void SvcWrap_CreateDeviceAddressSpace64From32(Core::System& system) { das_size_gather[1] = GetReg32(system, 1); das_size = Convert<uint64_t>(das_size_gather); - ret = CreateDeviceAddressSpace64From32(system, &out_handle, das_address, das_size); + ret = CreateDeviceAddressSpace64From32(system, std::addressof(out_handle), das_address, das_size); SetReg32(system, 0, Convert<uint32_t>(ret)); SetReg32(system, 1, Convert<uint32_t>(out_handle)); @@ -1505,7 +1505,7 @@ static void SvcWrap_DebugActiveProcess64From32(Core::System& system) { process_id_gather[1] = GetReg32(system, 3); process_id = Convert<uint64_t>(process_id_gather); - ret = DebugActiveProcess64From32(system, &out_handle, process_id); + ret = DebugActiveProcess64From32(system, std::addressof(out_handle), process_id); SetReg32(system, 0, Convert<uint32_t>(ret)); SetReg32(system, 1, Convert<uint32_t>(out_handle)); @@ -1577,7 +1577,7 @@ static void SvcWrap_GetProcessList64From32(Core::System& system) { out_process_ids = Convert<uint32_t>(GetReg32(system, 1)); max_out_count = Convert<int32_t>(GetReg32(system, 2)); - ret = GetProcessList64From32(system, &out_num_processes, out_process_ids, max_out_count); + ret = GetProcessList64From32(system, std::addressof(out_num_processes), out_process_ids, max_out_count); SetReg32(system, 0, Convert<uint32_t>(ret)); SetReg32(system, 1, Convert<uint32_t>(out_num_processes)); @@ -1595,7 +1595,7 @@ static void SvcWrap_GetThreadList64From32(Core::System& system) { max_out_count = Convert<int32_t>(GetReg32(system, 2)); debug_handle = Convert<Handle>(GetReg32(system, 3)); - ret = GetThreadList64From32(system, &out_num_threads, out_thread_ids, max_out_count, debug_handle); + ret = GetThreadList64From32(system, std::addressof(out_num_threads), out_thread_ids, max_out_count, debug_handle); SetReg32(system, 0, Convert<uint32_t>(ret)); SetReg32(system, 1, Convert<uint32_t>(out_num_threads)); @@ -1655,7 +1655,7 @@ static void SvcWrap_QueryDebugProcessMemory64From32(Core::System& system) { process_handle = Convert<Handle>(GetReg32(system, 2)); address = Convert<uint32_t>(GetReg32(system, 3)); - ret = QueryDebugProcessMemory64From32(system, out_memory_info, &out_page_info, process_handle, address); + ret = QueryDebugProcessMemory64From32(system, out_memory_info, std::addressof(out_page_info), process_handle, address); SetReg32(system, 0, Convert<uint32_t>(ret)); SetReg32(system, 1, Convert<uint32_t>(out_page_info)); @@ -1735,7 +1735,7 @@ static void SvcWrap_GetDebugThreadParam64From32(Core::System& system) { thread_id = Convert<uint64_t>(thread_id_gather); param = Convert<DebugThreadParam>(GetReg32(system, 3)); - ret = GetDebugThreadParam64From32(system, &out_64, &out_32, debug_handle, thread_id, param); + ret = GetDebugThreadParam64From32(system, std::addressof(out_64), std::addressof(out_32), debug_handle, thread_id, param); SetReg32(system, 0, Convert<uint32_t>(ret)); auto out_64_scatter = Convert<std::array<uint32_t, 2>>(out_64); @@ -1759,7 +1759,7 @@ static void SvcWrap_GetSystemInfo64From32(Core::System& system) { info_subtype_gather[1] = GetReg32(system, 3); info_subtype = Convert<uint64_t>(info_subtype_gather); - ret = GetSystemInfo64From32(system, &out, info_type, handle, info_subtype); + ret = GetSystemInfo64From32(system, std::addressof(out), info_type, handle, info_subtype); SetReg32(system, 0, Convert<uint32_t>(ret)); auto out_scatter = Convert<std::array<uint32_t, 2>>(out); @@ -1780,7 +1780,7 @@ static void SvcWrap_CreatePort64From32(Core::System& system) { is_light = Convert<bool>(GetReg32(system, 3)); name = Convert<uint32_t>(GetReg32(system, 0)); - ret = CreatePort64From32(system, &out_server_handle, &out_client_handle, max_sessions, is_light, name); + ret = CreatePort64From32(system, std::addressof(out_server_handle), std::addressof(out_client_handle), max_sessions, is_light, name); SetReg32(system, 0, Convert<uint32_t>(ret)); SetReg32(system, 1, Convert<uint32_t>(out_server_handle)); @@ -1797,7 +1797,7 @@ static void SvcWrap_ManageNamedPort64From32(Core::System& system) { name = Convert<uint32_t>(GetReg32(system, 1)); max_sessions = Convert<int32_t>(GetReg32(system, 2)); - ret = ManageNamedPort64From32(system, &out_server_handle, name, max_sessions); + ret = ManageNamedPort64From32(system, std::addressof(out_server_handle), name, max_sessions); SetReg32(system, 0, Convert<uint32_t>(ret)); SetReg32(system, 1, Convert<uint32_t>(out_server_handle)); @@ -1811,7 +1811,7 @@ static void SvcWrap_ConnectToPort64From32(Core::System& system) { port = Convert<Handle>(GetReg32(system, 1)); - ret = ConnectToPort64From32(system, &out_handle, port); + ret = ConnectToPort64From32(system, std::addressof(out_handle), port); SetReg32(system, 0, Convert<uint32_t>(ret)); SetReg32(system, 1, Convert<uint32_t>(out_handle)); @@ -1898,7 +1898,7 @@ static void SvcWrap_QueryProcessMemory64From32(Core::System& system) { address_gather[1] = GetReg32(system, 3); address = Convert<uint64_t>(address_gather); - ret = QueryProcessMemory64From32(system, out_memory_info, &out_page_info, process_handle, address); + ret = QueryProcessMemory64From32(system, out_memory_info, std::addressof(out_page_info), process_handle, address); SetReg32(system, 0, Convert<uint32_t>(ret)); SetReg32(system, 1, Convert<uint32_t>(out_page_info)); @@ -1970,7 +1970,7 @@ static void SvcWrap_CreateProcess64From32(Core::System& system) { caps = Convert<uint32_t>(GetReg32(system, 2)); num_caps = Convert<int32_t>(GetReg32(system, 3)); - ret = CreateProcess64From32(system, &out_handle, parameters, caps, num_caps); + ret = CreateProcess64From32(system, std::addressof(out_handle), parameters, caps, num_caps); SetReg32(system, 0, Convert<uint32_t>(ret)); SetReg32(system, 1, Convert<uint32_t>(out_handle)); @@ -2019,7 +2019,7 @@ static void SvcWrap_GetProcessInfo64From32(Core::System& system) { process_handle = Convert<Handle>(GetReg32(system, 1)); info_type = Convert<ProcessInfoType>(GetReg32(system, 2)); - ret = GetProcessInfo64From32(system, &out_info, process_handle, info_type); + ret = GetProcessInfo64From32(system, std::addressof(out_info), process_handle, info_type); SetReg32(system, 0, Convert<uint32_t>(ret)); auto out_info_scatter = Convert<std::array<uint32_t, 2>>(out_info); @@ -2032,7 +2032,7 @@ static void SvcWrap_CreateResourceLimit64From32(Core::System& system) { Handle out_handle{}; - ret = CreateResourceLimit64From32(system, &out_handle); + ret = CreateResourceLimit64From32(system, std::addressof(out_handle)); SetReg32(system, 0, Convert<uint32_t>(ret)); SetReg32(system, 1, Convert<uint32_t>(out_handle)); @@ -2093,7 +2093,7 @@ static void SvcWrap_SetHeapSize64(Core::System& system) { size = Convert<uint64_t>(GetReg64(system, 1)); - ret = SetHeapSize64(system, &out_address, size); + ret = SetHeapSize64(system, std::addressof(out_address), size); SetReg64(system, 0, Convert<uint64_t>(ret)); SetReg64(system, 1, Convert<uint64_t>(out_address)); @@ -2175,7 +2175,7 @@ static void SvcWrap_QueryMemory64(Core::System& system) { out_memory_info = Convert<uint64_t>(GetReg64(system, 0)); address = Convert<uint64_t>(GetReg64(system, 2)); - ret = QueryMemory64(system, out_memory_info, &out_page_info, address); + ret = QueryMemory64(system, out_memory_info, std::addressof(out_page_info), address); SetReg64(system, 0, Convert<uint64_t>(ret)); SetReg64(system, 1, Convert<uint64_t>(out_page_info)); @@ -2201,7 +2201,7 @@ static void SvcWrap_CreateThread64(Core::System& system) { priority = Convert<int32_t>(GetReg64(system, 4)); core_id = Convert<int32_t>(GetReg64(system, 5)); - ret = CreateThread64(system, &out_handle, func, arg, stack_bottom, priority, core_id); + ret = CreateThread64(system, std::addressof(out_handle), func, arg, stack_bottom, priority, core_id); SetReg64(system, 0, Convert<uint64_t>(ret)); SetReg64(system, 1, Convert<uint64_t>(out_handle)); @@ -2239,7 +2239,7 @@ static void SvcWrap_GetThreadPriority64(Core::System& system) { thread_handle = Convert<Handle>(GetReg64(system, 1)); - ret = GetThreadPriority64(system, &out_priority, thread_handle); + ret = GetThreadPriority64(system, std::addressof(out_priority), thread_handle); SetReg64(system, 0, Convert<uint64_t>(ret)); SetReg64(system, 1, Convert<uint64_t>(out_priority)); @@ -2268,7 +2268,7 @@ static void SvcWrap_GetThreadCoreMask64(Core::System& system) { thread_handle = Convert<Handle>(GetReg64(system, 2)); - ret = GetThreadCoreMask64(system, &out_core_id, &out_affinity_mask, thread_handle); + ret = GetThreadCoreMask64(system, std::addressof(out_core_id), std::addressof(out_affinity_mask), thread_handle); SetReg64(system, 0, Convert<uint64_t>(ret)); SetReg64(system, 1, Convert<uint64_t>(out_core_id)); @@ -2369,7 +2369,7 @@ static void SvcWrap_CreateTransferMemory64(Core::System& system) { size = Convert<uint64_t>(GetReg64(system, 2)); map_perm = Convert<MemoryPermission>(GetReg64(system, 3)); - ret = CreateTransferMemory64(system, &out_handle, address, size, map_perm); + ret = CreateTransferMemory64(system, std::addressof(out_handle), address, size, map_perm); SetReg64(system, 0, Convert<uint64_t>(ret)); SetReg64(system, 1, Convert<uint64_t>(out_handle)); @@ -2411,7 +2411,7 @@ static void SvcWrap_WaitSynchronization64(Core::System& system) { num_handles = Convert<int32_t>(GetReg64(system, 2)); timeout_ns = Convert<int64_t>(GetReg64(system, 3)); - ret = WaitSynchronization64(system, &out_index, handles, num_handles, timeout_ns); + ret = WaitSynchronization64(system, std::addressof(out_index), handles, num_handles, timeout_ns); SetReg64(system, 0, Convert<uint64_t>(ret)); SetReg64(system, 1, Convert<uint64_t>(out_index)); @@ -2501,7 +2501,7 @@ static void SvcWrap_ConnectToNamedPort64(Core::System& system) { name = Convert<uint64_t>(GetReg64(system, 1)); - ret = ConnectToNamedPort64(system, &out_handle, name); + ret = ConnectToNamedPort64(system, std::addressof(out_handle), name); SetReg64(system, 0, Convert<uint64_t>(ret)); SetReg64(system, 1, Convert<uint64_t>(out_handle)); @@ -2547,7 +2547,7 @@ static void SvcWrap_SendAsyncRequestWithUserBuffer64(Core::System& system) { message_buffer_size = Convert<uint64_t>(GetReg64(system, 2)); session_handle = Convert<Handle>(GetReg64(system, 3)); - ret = SendAsyncRequestWithUserBuffer64(system, &out_event_handle, message_buffer, message_buffer_size, session_handle); + ret = SendAsyncRequestWithUserBuffer64(system, std::addressof(out_event_handle), message_buffer, message_buffer_size, session_handle); SetReg64(system, 0, Convert<uint64_t>(ret)); SetReg64(system, 1, Convert<uint64_t>(out_event_handle)); @@ -2561,7 +2561,7 @@ static void SvcWrap_GetProcessId64(Core::System& system) { process_handle = Convert<Handle>(GetReg64(system, 1)); - ret = GetProcessId64(system, &out_process_id, process_handle); + ret = GetProcessId64(system, std::addressof(out_process_id), process_handle); SetReg64(system, 0, Convert<uint64_t>(ret)); SetReg64(system, 1, Convert<uint64_t>(out_process_id)); @@ -2575,7 +2575,7 @@ static void SvcWrap_GetThreadId64(Core::System& system) { thread_handle = Convert<Handle>(GetReg64(system, 1)); - ret = GetThreadId64(system, &out_thread_id, thread_handle); + ret = GetThreadId64(system, std::addressof(out_thread_id), thread_handle); SetReg64(system, 0, Convert<uint64_t>(ret)); SetReg64(system, 1, Convert<uint64_t>(out_thread_id)); @@ -2627,7 +2627,7 @@ static void SvcWrap_GetInfo64(Core::System& system) { handle = Convert<Handle>(GetReg64(system, 2)); info_subtype = Convert<uint64_t>(GetReg64(system, 3)); - ret = GetInfo64(system, &out, info_type, handle, info_subtype); + ret = GetInfo64(system, std::addressof(out), info_type, handle, info_subtype); SetReg64(system, 0, Convert<uint64_t>(ret)); SetReg64(system, 1, Convert<uint64_t>(out)); @@ -2690,7 +2690,7 @@ static void SvcWrap_GetDebugFutureThreadInfo64(Core::System& system) { debug_handle = Convert<Handle>(GetReg64(system, 2)); ns = Convert<int64_t>(GetReg64(system, 3)); - ret = GetDebugFutureThreadInfo64(system, &out_context, &out_thread_id, debug_handle, ns); + ret = GetDebugFutureThreadInfo64(system, std::addressof(out_context), std::addressof(out_thread_id), debug_handle, ns); SetReg64(system, 0, Convert<uint64_t>(ret)); auto out_context_scatter = Convert<std::array<uint64_t, 4>>(out_context); @@ -2708,7 +2708,7 @@ static void SvcWrap_GetLastThreadInfo64(Core::System& system) { uint64_t out_tls_address{}; uint32_t out_flags{}; - ret = GetLastThreadInfo64(system, &out_context, &out_tls_address, &out_flags); + ret = GetLastThreadInfo64(system, std::addressof(out_context), std::addressof(out_tls_address), std::addressof(out_flags)); SetReg64(system, 0, Convert<uint64_t>(ret)); auto out_context_scatter = Convert<std::array<uint64_t, 4>>(out_context); @@ -2730,7 +2730,7 @@ static void SvcWrap_GetResourceLimitLimitValue64(Core::System& system) { resource_limit_handle = Convert<Handle>(GetReg64(system, 1)); which = Convert<LimitableResource>(GetReg64(system, 2)); - ret = GetResourceLimitLimitValue64(system, &out_limit_value, resource_limit_handle, which); + ret = GetResourceLimitLimitValue64(system, std::addressof(out_limit_value), resource_limit_handle, which); SetReg64(system, 0, Convert<uint64_t>(ret)); SetReg64(system, 1, Convert<uint64_t>(out_limit_value)); @@ -2746,7 +2746,7 @@ static void SvcWrap_GetResourceLimitCurrentValue64(Core::System& system) { resource_limit_handle = Convert<Handle>(GetReg64(system, 1)); which = Convert<LimitableResource>(GetReg64(system, 2)); - ret = GetResourceLimitCurrentValue64(system, &out_current_value, resource_limit_handle, which); + ret = GetResourceLimitCurrentValue64(system, std::addressof(out_current_value), resource_limit_handle, which); SetReg64(system, 0, Convert<uint64_t>(ret)); SetReg64(system, 1, Convert<uint64_t>(out_current_value)); @@ -2830,7 +2830,7 @@ static void SvcWrap_GetResourceLimitPeakValue64(Core::System& system) { resource_limit_handle = Convert<Handle>(GetReg64(system, 1)); which = Convert<LimitableResource>(GetReg64(system, 2)); - ret = GetResourceLimitPeakValue64(system, &out_peak_value, resource_limit_handle, which); + ret = GetResourceLimitPeakValue64(system, std::addressof(out_peak_value), resource_limit_handle, which); SetReg64(system, 0, Convert<uint64_t>(ret)); SetReg64(system, 1, Convert<uint64_t>(out_peak_value)); @@ -2844,7 +2844,7 @@ static void SvcWrap_CreateIoPool64(Core::System& system) { which = Convert<IoPoolType>(GetReg64(system, 1)); - ret = CreateIoPool64(system, &out_handle, which); + ret = CreateIoPool64(system, std::addressof(out_handle), which); SetReg64(system, 0, Convert<uint64_t>(ret)); SetReg64(system, 1, Convert<uint64_t>(out_handle)); @@ -2866,7 +2866,7 @@ static void SvcWrap_CreateIoRegion64(Core::System& system) { mapping = Convert<MemoryMapping>(GetReg64(system, 4)); perm = Convert<MemoryPermission>(GetReg64(system, 5)); - ret = CreateIoRegion64(system, &out_handle, io_pool, physical_address, size, mapping, perm); + ret = CreateIoRegion64(system, std::addressof(out_handle), io_pool, physical_address, size, mapping, perm); SetReg64(system, 0, Convert<uint64_t>(ret)); SetReg64(system, 1, Convert<uint64_t>(out_handle)); @@ -2905,7 +2905,7 @@ static void SvcWrap_CreateSession64(Core::System& system) { is_light = Convert<bool>(GetReg64(system, 2)); name = Convert<uint64_t>(GetReg64(system, 3)); - ret = CreateSession64(system, &out_server_session_handle, &out_client_session_handle, is_light, name); + ret = CreateSession64(system, std::addressof(out_server_session_handle), std::addressof(out_client_session_handle), is_light, name); SetReg64(system, 0, Convert<uint64_t>(ret)); SetReg64(system, 1, Convert<uint64_t>(out_server_session_handle)); @@ -2920,7 +2920,7 @@ static void SvcWrap_AcceptSession64(Core::System& system) { port = Convert<Handle>(GetReg64(system, 1)); - ret = AcceptSession64(system, &out_handle, port); + ret = AcceptSession64(system, std::addressof(out_handle), port); SetReg64(system, 0, Convert<uint64_t>(ret)); SetReg64(system, 1, Convert<uint64_t>(out_handle)); @@ -2940,7 +2940,7 @@ static void SvcWrap_ReplyAndReceive64(Core::System& system) { reply_target = Convert<Handle>(GetReg64(system, 3)); timeout_ns = Convert<int64_t>(GetReg64(system, 4)); - ret = ReplyAndReceive64(system, &out_index, handles, num_handles, reply_target, timeout_ns); + ret = ReplyAndReceive64(system, std::addressof(out_index), handles, num_handles, reply_target, timeout_ns); SetReg64(system, 0, Convert<uint64_t>(ret)); SetReg64(system, 1, Convert<uint64_t>(out_index)); @@ -2964,7 +2964,7 @@ static void SvcWrap_ReplyAndReceiveWithUserBuffer64(Core::System& system) { reply_target = Convert<Handle>(GetReg64(system, 5)); timeout_ns = Convert<int64_t>(GetReg64(system, 6)); - ret = ReplyAndReceiveWithUserBuffer64(system, &out_index, message_buffer, message_buffer_size, handles, num_handles, reply_target, timeout_ns); + ret = ReplyAndReceiveWithUserBuffer64(system, std::addressof(out_index), message_buffer, message_buffer_size, handles, num_handles, reply_target, timeout_ns); SetReg64(system, 0, Convert<uint64_t>(ret)); SetReg64(system, 1, Convert<uint64_t>(out_index)); @@ -2976,7 +2976,7 @@ static void SvcWrap_CreateEvent64(Core::System& system) { Handle out_write_handle{}; Handle out_read_handle{}; - ret = CreateEvent64(system, &out_write_handle, &out_read_handle); + ret = CreateEvent64(system, std::addressof(out_write_handle), std::addressof(out_read_handle)); SetReg64(system, 0, Convert<uint64_t>(ret)); SetReg64(system, 1, Convert<uint64_t>(out_write_handle)); @@ -3067,7 +3067,7 @@ static void SvcWrap_CreateCodeMemory64(Core::System& system) { address = Convert<uint64_t>(GetReg64(system, 1)); size = Convert<uint64_t>(GetReg64(system, 2)); - ret = CreateCodeMemory64(system, &out_handle, address, size); + ret = CreateCodeMemory64(system, std::addressof(out_handle), address, size); SetReg64(system, 0, Convert<uint64_t>(ret)); SetReg64(system, 1, Convert<uint64_t>(out_handle)); @@ -3109,7 +3109,7 @@ static void SvcWrap_ReadWriteRegister64(Core::System& system) { mask = Convert<uint32_t>(GetReg64(system, 2)); value = Convert<uint32_t>(GetReg64(system, 3)); - ret = ReadWriteRegister64(system, &out_value, address, mask, value); + ret = ReadWriteRegister64(system, std::addressof(out_value), address, mask, value); SetReg64(system, 0, Convert<uint64_t>(ret)); SetReg64(system, 1, Convert<uint64_t>(out_value)); @@ -3141,7 +3141,7 @@ static void SvcWrap_CreateSharedMemory64(Core::System& system) { owner_perm = Convert<MemoryPermission>(GetReg64(system, 2)); remote_perm = Convert<MemoryPermission>(GetReg64(system, 3)); - ret = CreateSharedMemory64(system, &out_handle, size, owner_perm, remote_perm); + ret = CreateSharedMemory64(system, std::addressof(out_handle), size, owner_perm, remote_perm); SetReg64(system, 0, Convert<uint64_t>(ret)); SetReg64(system, 1, Convert<uint64_t>(out_handle)); @@ -3191,7 +3191,7 @@ static void SvcWrap_CreateInterruptEvent64(Core::System& system) { interrupt_id = Convert<int32_t>(GetReg64(system, 1)); interrupt_type = Convert<InterruptType>(GetReg64(system, 2)); - ret = CreateInterruptEvent64(system, &out_read_handle, interrupt_id, interrupt_type); + ret = CreateInterruptEvent64(system, std::addressof(out_read_handle), interrupt_id, interrupt_type); SetReg64(system, 0, Convert<uint64_t>(ret)); SetReg64(system, 1, Convert<uint64_t>(out_read_handle)); @@ -3205,7 +3205,7 @@ static void SvcWrap_QueryPhysicalAddress64(Core::System& system) { address = Convert<uint64_t>(GetReg64(system, 1)); - ret = QueryPhysicalAddress64(system, &out_info, address); + ret = QueryPhysicalAddress64(system, std::addressof(out_info), address); SetReg64(system, 0, Convert<uint64_t>(ret)); auto out_info_scatter = Convert<std::array<uint64_t, 3>>(out_info); @@ -3225,7 +3225,7 @@ static void SvcWrap_QueryIoMapping64(Core::System& system) { physical_address = Convert<uint64_t>(GetReg64(system, 2)); size = Convert<uint64_t>(GetReg64(system, 3)); - ret = QueryIoMapping64(system, &out_address, &out_size, physical_address, size); + ret = QueryIoMapping64(system, std::addressof(out_address), std::addressof(out_size), physical_address, size); SetReg64(system, 0, Convert<uint64_t>(ret)); SetReg64(system, 1, Convert<uint64_t>(out_address)); @@ -3242,7 +3242,7 @@ static void SvcWrap_CreateDeviceAddressSpace64(Core::System& system) { das_address = Convert<uint64_t>(GetReg64(system, 1)); das_size = Convert<uint64_t>(GetReg64(system, 2)); - ret = CreateDeviceAddressSpace64(system, &out_handle, das_address, das_size); + ret = CreateDeviceAddressSpace64(system, std::addressof(out_handle), das_address, das_size); SetReg64(system, 0, Convert<uint64_t>(ret)); SetReg64(system, 1, Convert<uint64_t>(out_handle)); @@ -3396,7 +3396,7 @@ static void SvcWrap_DebugActiveProcess64(Core::System& system) { process_id = Convert<uint64_t>(GetReg64(system, 1)); - ret = DebugActiveProcess64(system, &out_handle, process_id); + ret = DebugActiveProcess64(system, std::addressof(out_handle), process_id); SetReg64(system, 0, Convert<uint64_t>(ret)); SetReg64(system, 1, Convert<uint64_t>(out_handle)); @@ -3468,7 +3468,7 @@ static void SvcWrap_GetProcessList64(Core::System& system) { out_process_ids = Convert<uint64_t>(GetReg64(system, 1)); max_out_count = Convert<int32_t>(GetReg64(system, 2)); - ret = GetProcessList64(system, &out_num_processes, out_process_ids, max_out_count); + ret = GetProcessList64(system, std::addressof(out_num_processes), out_process_ids, max_out_count); SetReg64(system, 0, Convert<uint64_t>(ret)); SetReg64(system, 1, Convert<uint64_t>(out_num_processes)); @@ -3486,7 +3486,7 @@ static void SvcWrap_GetThreadList64(Core::System& system) { max_out_count = Convert<int32_t>(GetReg64(system, 2)); debug_handle = Convert<Handle>(GetReg64(system, 3)); - ret = GetThreadList64(system, &out_num_threads, out_thread_ids, max_out_count, debug_handle); + ret = GetThreadList64(system, std::addressof(out_num_threads), out_thread_ids, max_out_count, debug_handle); SetReg64(system, 0, Convert<uint64_t>(ret)); SetReg64(system, 1, Convert<uint64_t>(out_num_threads)); @@ -3540,7 +3540,7 @@ static void SvcWrap_QueryDebugProcessMemory64(Core::System& system) { process_handle = Convert<Handle>(GetReg64(system, 2)); address = Convert<uint64_t>(GetReg64(system, 3)); - ret = QueryDebugProcessMemory64(system, out_memory_info, &out_page_info, process_handle, address); + ret = QueryDebugProcessMemory64(system, out_memory_info, std::addressof(out_page_info), process_handle, address); SetReg64(system, 0, Convert<uint64_t>(ret)); SetReg64(system, 1, Convert<uint64_t>(out_page_info)); @@ -3611,7 +3611,7 @@ static void SvcWrap_GetDebugThreadParam64(Core::System& system) { thread_id = Convert<uint64_t>(GetReg64(system, 3)); param = Convert<DebugThreadParam>(GetReg64(system, 4)); - ret = GetDebugThreadParam64(system, &out_64, &out_32, debug_handle, thread_id, param); + ret = GetDebugThreadParam64(system, std::addressof(out_64), std::addressof(out_32), debug_handle, thread_id, param); SetReg64(system, 0, Convert<uint64_t>(ret)); SetReg64(system, 1, Convert<uint64_t>(out_64)); @@ -3630,7 +3630,7 @@ static void SvcWrap_GetSystemInfo64(Core::System& system) { handle = Convert<Handle>(GetReg64(system, 2)); info_subtype = Convert<uint64_t>(GetReg64(system, 3)); - ret = GetSystemInfo64(system, &out, info_type, handle, info_subtype); + ret = GetSystemInfo64(system, std::addressof(out), info_type, handle, info_subtype); SetReg64(system, 0, Convert<uint64_t>(ret)); SetReg64(system, 1, Convert<uint64_t>(out)); @@ -3649,7 +3649,7 @@ static void SvcWrap_CreatePort64(Core::System& system) { is_light = Convert<bool>(GetReg64(system, 3)); name = Convert<uint64_t>(GetReg64(system, 4)); - ret = CreatePort64(system, &out_server_handle, &out_client_handle, max_sessions, is_light, name); + ret = CreatePort64(system, std::addressof(out_server_handle), std::addressof(out_client_handle), max_sessions, is_light, name); SetReg64(system, 0, Convert<uint64_t>(ret)); SetReg64(system, 1, Convert<uint64_t>(out_server_handle)); @@ -3666,7 +3666,7 @@ static void SvcWrap_ManageNamedPort64(Core::System& system) { name = Convert<uint64_t>(GetReg64(system, 1)); max_sessions = Convert<int32_t>(GetReg64(system, 2)); - ret = ManageNamedPort64(system, &out_server_handle, name, max_sessions); + ret = ManageNamedPort64(system, std::addressof(out_server_handle), name, max_sessions); SetReg64(system, 0, Convert<uint64_t>(ret)); SetReg64(system, 1, Convert<uint64_t>(out_server_handle)); @@ -3680,7 +3680,7 @@ static void SvcWrap_ConnectToPort64(Core::System& system) { port = Convert<Handle>(GetReg64(system, 1)); - ret = ConnectToPort64(system, &out_handle, port); + ret = ConnectToPort64(system, std::addressof(out_handle), port); SetReg64(system, 0, Convert<uint64_t>(ret)); SetReg64(system, 1, Convert<uint64_t>(out_handle)); @@ -3752,7 +3752,7 @@ static void SvcWrap_QueryProcessMemory64(Core::System& system) { process_handle = Convert<Handle>(GetReg64(system, 2)); address = Convert<uint64_t>(GetReg64(system, 3)); - ret = QueryProcessMemory64(system, out_memory_info, &out_page_info, process_handle, address); + ret = QueryProcessMemory64(system, out_memory_info, std::addressof(out_page_info), process_handle, address); SetReg64(system, 0, Convert<uint64_t>(ret)); SetReg64(system, 1, Convert<uint64_t>(out_page_info)); @@ -3806,7 +3806,7 @@ static void SvcWrap_CreateProcess64(Core::System& system) { caps = Convert<uint64_t>(GetReg64(system, 2)); num_caps = Convert<int32_t>(GetReg64(system, 3)); - ret = CreateProcess64(system, &out_handle, parameters, caps, num_caps); + ret = CreateProcess64(system, std::addressof(out_handle), parameters, caps, num_caps); SetReg64(system, 0, Convert<uint64_t>(ret)); SetReg64(system, 1, Convert<uint64_t>(out_handle)); @@ -3852,7 +3852,7 @@ static void SvcWrap_GetProcessInfo64(Core::System& system) { process_handle = Convert<Handle>(GetReg64(system, 1)); info_type = Convert<ProcessInfoType>(GetReg64(system, 2)); - ret = GetProcessInfo64(system, &out_info, process_handle, info_type); + ret = GetProcessInfo64(system, std::addressof(out_info), process_handle, info_type); SetReg64(system, 0, Convert<uint64_t>(ret)); SetReg64(system, 1, Convert<uint64_t>(out_info)); @@ -3863,7 +3863,7 @@ static void SvcWrap_CreateResourceLimit64(Core::System& system) { Handle out_handle{}; - ret = CreateResourceLimit64(system, &out_handle); + ret = CreateResourceLimit64(system, std::addressof(out_handle)); SetReg64(system, 0, Convert<uint64_t>(ret)); SetReg64(system, 1, Convert<uint64_t>(out_handle)); diff --git a/src/core/hle/kernel/svc/svc_address_arbiter.cpp b/src/core/hle/kernel/svc/svc_address_arbiter.cpp index 998bd3f22..22071731b 100644 --- a/src/core/hle/kernel/svc/svc_address_arbiter.cpp +++ b/src/core/hle/kernel/svc/svc_address_arbiter.cpp @@ -43,18 +43,9 @@ Result WaitForAddress(Core::System& system, VAddr address, ArbitrationType arb_t address, arb_type, value, timeout_ns); // Validate input. - if (IsKernelAddress(address)) { - LOG_ERROR(Kernel_SVC, "Attempting to wait on kernel address (address={:08X})", address); - return ResultInvalidCurrentMemory; - } - if (!Common::IsAligned(address, sizeof(s32))) { - LOG_ERROR(Kernel_SVC, "Wait address must be 4 byte aligned (address={:08X})", address); - return ResultInvalidAddress; - } - if (!IsValidArbitrationType(arb_type)) { - LOG_ERROR(Kernel_SVC, "Invalid arbitration type specified (type={})", arb_type); - return ResultInvalidEnumValue; - } + R_UNLESS(!IsKernelAddress(address), ResultInvalidCurrentMemory); + R_UNLESS(Common::IsAligned(address, sizeof(s32)), ResultInvalidAddress); + R_UNLESS(IsValidArbitrationType(arb_type), ResultInvalidEnumValue); // Convert timeout from nanoseconds to ticks. s64 timeout{}; @@ -72,7 +63,8 @@ Result WaitForAddress(Core::System& system, VAddr address, ArbitrationType arb_t timeout = timeout_ns; } - return GetCurrentProcess(system.Kernel()).WaitAddressArbiter(address, arb_type, value, timeout); + R_RETURN( + GetCurrentProcess(system.Kernel()).WaitAddressArbiter(address, arb_type, value, timeout)); } // Signals to an address (via Address Arbiter) @@ -82,41 +74,32 @@ Result SignalToAddress(Core::System& system, VAddr address, SignalType signal_ty address, signal_type, value, count); // Validate input. - if (IsKernelAddress(address)) { - LOG_ERROR(Kernel_SVC, "Attempting to signal to a kernel address (address={:08X})", address); - return ResultInvalidCurrentMemory; - } - if (!Common::IsAligned(address, sizeof(s32))) { - LOG_ERROR(Kernel_SVC, "Signaled address must be 4 byte aligned (address={:08X})", address); - return ResultInvalidAddress; - } - if (!IsValidSignalType(signal_type)) { - LOG_ERROR(Kernel_SVC, "Invalid signal type specified (type={})", signal_type); - return ResultInvalidEnumValue; - } + R_UNLESS(!IsKernelAddress(address), ResultInvalidCurrentMemory); + R_UNLESS(Common::IsAligned(address, sizeof(s32)), ResultInvalidAddress); + R_UNLESS(IsValidSignalType(signal_type), ResultInvalidEnumValue); - return GetCurrentProcess(system.Kernel()) - .SignalAddressArbiter(address, signal_type, value, count); + R_RETURN(GetCurrentProcess(system.Kernel()) + .SignalAddressArbiter(address, signal_type, value, count)); } Result WaitForAddress64(Core::System& system, VAddr address, ArbitrationType arb_type, s32 value, s64 timeout_ns) { - return WaitForAddress(system, address, arb_type, value, timeout_ns); + R_RETURN(WaitForAddress(system, address, arb_type, value, timeout_ns)); } Result SignalToAddress64(Core::System& system, VAddr address, SignalType signal_type, s32 value, s32 count) { - return SignalToAddress(system, address, signal_type, value, count); + R_RETURN(SignalToAddress(system, address, signal_type, value, count)); } Result WaitForAddress64From32(Core::System& system, u32 address, ArbitrationType arb_type, s32 value, s64 timeout_ns) { - return WaitForAddress(system, address, arb_type, value, timeout_ns); + R_RETURN(WaitForAddress(system, address, arb_type, value, timeout_ns)); } Result SignalToAddress64From32(Core::System& system, u32 address, SignalType signal_type, s32 value, s32 count) { - return SignalToAddress(system, address, signal_type, value, count); + R_RETURN(SignalToAddress(system, address, signal_type, value, count)); } } // namespace Kernel::Svc diff --git a/src/core/hle/kernel/svc/svc_code_memory.cpp b/src/core/hle/kernel/svc/svc_code_memory.cpp index 8bed747af..43feab986 100644 --- a/src/core/hle/kernel/svc/svc_code_memory.cpp +++ b/src/core/hle/kernel/svc/svc_code_memory.cpp @@ -1,6 +1,7 @@ // SPDX-FileCopyrightText: Copyright 2023 yuzu Emulator Project // SPDX-License-Identifier: GPL-2.0-or-later +#include "common/scope_exit.h" #include "core/core.h" #include "core/hle/kernel/k_code_memory.h" #include "core/hle/kernel/k_process.h" @@ -44,6 +45,7 @@ Result CreateCodeMemory(Core::System& system, Handle* out, VAddr address, uint64 KCodeMemory* code_mem = KCodeMemory::Create(kernel); R_UNLESS(code_mem != nullptr, ResultOutOfResource); + SCOPE_EXIT({ code_mem->Close(); }); // Verify that the region is in range. R_UNLESS(GetCurrentProcess(system.Kernel()).PageTable().Contains(address, size), @@ -58,9 +60,7 @@ Result CreateCodeMemory(Core::System& system, Handle* out, VAddr address, uint64 // Add the code memory to the handle table. R_TRY(GetCurrentProcess(system.Kernel()).GetHandleTable().Add(out, code_mem)); - code_mem->Close(); - - return ResultSuccess; + R_SUCCEED(); } Result ControlCodeMemory(Core::System& system, Handle code_memory_handle, @@ -140,10 +140,10 @@ Result ControlCodeMemory(Core::System& system, Handle code_memory_handle, R_TRY(code_mem->UnmapFromOwner(address, size)); } break; default: - return ResultInvalidEnumValue; + R_THROW(ResultInvalidEnumValue); } - return ResultSuccess; + R_SUCCEED(); } Result CreateCodeMemory64(Core::System& system, Handle* out_handle, uint64_t address, diff --git a/src/core/hle/kernel/svc/svc_condition_variable.cpp b/src/core/hle/kernel/svc/svc_condition_variable.cpp index 8ad1a0b8f..648ed23d0 100644 --- a/src/core/hle/kernel/svc/svc_condition_variable.cpp +++ b/src/core/hle/kernel/svc/svc_condition_variable.cpp @@ -17,14 +17,8 @@ Result WaitProcessWideKeyAtomic(Core::System& system, VAddr address, VAddr cv_ke cv_key, tag, timeout_ns); // Validate input. - if (IsKernelAddress(address)) { - LOG_ERROR(Kernel_SVC, "Attempted to wait on kernel address (address={:08X})", address); - return ResultInvalidCurrentMemory; - } - if (!Common::IsAligned(address, sizeof(s32))) { - LOG_ERROR(Kernel_SVC, "Address must be 4 byte aligned (address={:08X})", address); - return ResultInvalidAddress; - } + R_UNLESS(!IsKernelAddress(address), ResultInvalidCurrentMemory); + R_UNLESS(Common::IsAligned(address, sizeof(s32)), ResultInvalidAddress); // Convert timeout from nanoseconds to ticks. s64 timeout{}; @@ -43,8 +37,9 @@ Result WaitProcessWideKeyAtomic(Core::System& system, VAddr address, VAddr cv_ke } // Wait on the condition variable. - return GetCurrentProcess(system.Kernel()) - .WaitConditionVariable(address, Common::AlignDown(cv_key, sizeof(u32)), tag, timeout); + R_RETURN( + GetCurrentProcess(system.Kernel()) + .WaitConditionVariable(address, Common::AlignDown(cv_key, sizeof(u32)), tag, timeout)); } /// Signal process wide key diff --git a/src/core/hle/kernel/svc/svc_event.cpp b/src/core/hle/kernel/svc/svc_event.cpp index a948493e8..901202e6a 100644 --- a/src/core/hle/kernel/svc/svc_event.cpp +++ b/src/core/hle/kernel/svc/svc_event.cpp @@ -21,7 +21,7 @@ Result SignalEvent(Core::System& system, Handle event_handle) { KScopedAutoObject event = handle_table.GetObject<KEvent>(event_handle); R_UNLESS(event.IsNotNull(), ResultInvalidHandle); - return event->Signal(); + R_RETURN(event->Signal()); } Result ClearEvent(Core::System& system, Handle event_handle) { @@ -34,7 +34,7 @@ Result ClearEvent(Core::System& system, Handle event_handle) { { KScopedAutoObject event = handle_table.GetObject<KEvent>(event_handle); if (event.IsNotNull()) { - return event->Clear(); + R_RETURN(event->Clear()); } } @@ -42,13 +42,11 @@ Result ClearEvent(Core::System& system, Handle event_handle) { { KScopedAutoObject readable_event = handle_table.GetObject<KReadableEvent>(event_handle); if (readable_event.IsNotNull()) { - return readable_event->Clear(); + R_RETURN(readable_event->Clear()); } } - LOG_ERROR(Kernel_SVC, "Event handle does not exist, event_handle=0x{:08X}", event_handle); - - return ResultInvalidHandle; + R_THROW(ResultInvalidHandle); } Result CreateEvent(Core::System& system, Handle* out_write, Handle* out_read) { @@ -85,15 +83,13 @@ Result CreateEvent(Core::System& system, Handle* out_write, Handle* out_read) { // Add the event to the handle table. R_TRY(handle_table.Add(out_write, event)); - // Ensure that we maintaing a clean handle state on exit. - auto handle_guard = SCOPE_GUARD({ handle_table.Remove(*out_write); }); + // Ensure that we maintain a clean handle state on exit. + ON_RESULT_FAILURE { + handle_table.Remove(*out_write); + }; // Add the readable event to the handle table. - R_TRY(handle_table.Add(out_read, std::addressof(event->GetReadableEvent()))); - - // We succeeded. - handle_guard.Cancel(); - return ResultSuccess; + R_RETURN(handle_table.Add(out_read, std::addressof(event->GetReadableEvent()))); } Result SignalEvent64(Core::System& system, Handle event_handle) { diff --git a/src/core/hle/kernel/svc/svc_info.cpp b/src/core/hle/kernel/svc/svc_info.cpp index cbed4dc8c..04b6d6964 100644 --- a/src/core/hle/kernel/svc/svc_info.cpp +++ b/src/core/hle/kernel/svc/svc_info.cpp @@ -38,126 +38,110 @@ Result GetInfo(Core::System& system, u64* result, InfoType info_id_type, Handle case InfoType::UsedNonSystemMemorySize: case InfoType::IsApplication: case InfoType::FreeThreadCount: { - if (info_sub_id != 0) { - LOG_ERROR(Kernel_SVC, "Info sub id is non zero! info_id={}, info_sub_id={}", info_id, - info_sub_id); - return ResultInvalidEnumValue; - } + R_UNLESS(info_sub_id == 0, ResultInvalidEnumValue); const auto& handle_table = GetCurrentProcess(system.Kernel()).GetHandleTable(); KScopedAutoObject process = handle_table.GetObject<KProcess>(handle); - if (process.IsNull()) { - LOG_ERROR(Kernel_SVC, "Process is not valid! info_id={}, info_sub_id={}, handle={:08X}", - info_id, info_sub_id, handle); - return ResultInvalidHandle; - } + R_UNLESS(process.IsNotNull(), ResultInvalidHandle); switch (info_id_type) { case InfoType::CoreMask: *result = process->GetCoreMask(); - return ResultSuccess; + R_SUCCEED(); case InfoType::PriorityMask: *result = process->GetPriorityMask(); - return ResultSuccess; + R_SUCCEED(); case InfoType::AliasRegionAddress: *result = process->PageTable().GetAliasRegionStart(); - return ResultSuccess; + R_SUCCEED(); case InfoType::AliasRegionSize: *result = process->PageTable().GetAliasRegionSize(); - return ResultSuccess; + R_SUCCEED(); case InfoType::HeapRegionAddress: *result = process->PageTable().GetHeapRegionStart(); - return ResultSuccess; + R_SUCCEED(); case InfoType::HeapRegionSize: *result = process->PageTable().GetHeapRegionSize(); - return ResultSuccess; + R_SUCCEED(); case InfoType::AslrRegionAddress: *result = process->PageTable().GetAliasCodeRegionStart(); - return ResultSuccess; + R_SUCCEED(); case InfoType::AslrRegionSize: *result = process->PageTable().GetAliasCodeRegionSize(); - return ResultSuccess; + R_SUCCEED(); case InfoType::StackRegionAddress: *result = process->PageTable().GetStackRegionStart(); - return ResultSuccess; + R_SUCCEED(); case InfoType::StackRegionSize: *result = process->PageTable().GetStackRegionSize(); - return ResultSuccess; + R_SUCCEED(); case InfoType::TotalMemorySize: *result = process->GetTotalPhysicalMemoryAvailable(); - return ResultSuccess; + R_SUCCEED(); case InfoType::UsedMemorySize: *result = process->GetTotalPhysicalMemoryUsed(); - return ResultSuccess; + R_SUCCEED(); case InfoType::SystemResourceSizeTotal: *result = process->GetSystemResourceSize(); - return ResultSuccess; + R_SUCCEED(); case InfoType::SystemResourceSizeUsed: LOG_WARNING(Kernel_SVC, "(STUBBED) Attempted to query system resource usage"); *result = process->GetSystemResourceUsage(); - return ResultSuccess; + R_SUCCEED(); case InfoType::ProgramId: - *result = process->GetProgramID(); - return ResultSuccess; + *result = process->GetProgramId(); + R_SUCCEED(); case InfoType::UserExceptionContextAddress: *result = process->GetProcessLocalRegionAddress(); - return ResultSuccess; + R_SUCCEED(); case InfoType::TotalNonSystemMemorySize: *result = process->GetTotalPhysicalMemoryAvailableWithoutSystemResource(); - return ResultSuccess; + R_SUCCEED(); case InfoType::UsedNonSystemMemorySize: *result = process->GetTotalPhysicalMemoryUsedWithoutSystemResource(); - return ResultSuccess; + R_SUCCEED(); case InfoType::IsApplication: LOG_WARNING(Kernel_SVC, "(STUBBED) Assuming process is application"); *result = true; - return ResultSuccess; + R_SUCCEED(); case InfoType::FreeThreadCount: *result = process->GetFreeThreadCount(); - return ResultSuccess; + R_SUCCEED(); default: break; } LOG_ERROR(Kernel_SVC, "Unimplemented svcGetInfo id=0x{:016X}", info_id); - return ResultInvalidEnumValue; + R_THROW(ResultInvalidEnumValue); } case InfoType::DebuggerAttached: *result = 0; - return ResultSuccess; + R_SUCCEED(); case InfoType::ResourceLimit: { - if (handle != 0) { - LOG_ERROR(Kernel, "Handle is non zero! handle={:08X}", handle); - return ResultInvalidHandle; - } - - if (info_sub_id != 0) { - LOG_ERROR(Kernel, "Info sub id is non zero! info_id={}, info_sub_id={}", info_id, - info_sub_id); - return ResultInvalidCombination; - } + R_UNLESS(handle == 0, ResultInvalidHandle); + R_UNLESS(info_sub_id == 0, ResultInvalidCombination); KProcess* const current_process = GetCurrentProcessPointer(system.Kernel()); KHandleTable& handle_table = current_process->GetHandleTable(); @@ -165,44 +149,35 @@ Result GetInfo(Core::System& system, u64* result, InfoType info_id_type, Handle if (!resource_limit) { *result = Svc::InvalidHandle; // Yes, the kernel considers this a successful operation. - return ResultSuccess; + R_SUCCEED(); } Handle resource_handle{}; - R_TRY(handle_table.Add(&resource_handle, resource_limit)); + R_TRY(handle_table.Add(std::addressof(resource_handle), resource_limit)); *result = resource_handle; - return ResultSuccess; + R_SUCCEED(); } case InfoType::RandomEntropy: - if (handle != 0) { - LOG_ERROR(Kernel_SVC, "Process Handle is non zero, expected 0 result but got {:016X}", - handle); - return ResultInvalidHandle; - } - - if (info_sub_id >= KProcess::RANDOM_ENTROPY_SIZE) { - LOG_ERROR(Kernel_SVC, "Entropy size is out of range, expected {} but got {}", - KProcess::RANDOM_ENTROPY_SIZE, info_sub_id); - return ResultInvalidCombination; - } + R_UNLESS(handle == 0, ResultInvalidHandle); + R_UNLESS(info_sub_id < KProcess::RANDOM_ENTROPY_SIZE, ResultInvalidCombination); *result = GetCurrentProcess(system.Kernel()).GetRandomEntropy(info_sub_id); - return ResultSuccess; + R_SUCCEED(); case InfoType::InitialProcessIdRange: LOG_WARNING(Kernel_SVC, "(STUBBED) Attempted to query privileged process id bounds, returned 0"); *result = 0; - return ResultSuccess; + R_SUCCEED(); case InfoType::ThreadTickCount: { constexpr u64 num_cpus = 4; if (info_sub_id != 0xFFFFFFFFFFFFFFFF && info_sub_id >= num_cpus) { LOG_ERROR(Kernel_SVC, "Core count is out of range, expected {} but got {}", num_cpus, info_sub_id); - return ResultInvalidCombination; + R_THROW(ResultInvalidCombination); } KScopedAutoObject thread = GetCurrentProcess(system.Kernel()) @@ -211,7 +186,7 @@ Result GetInfo(Core::System& system, u64* result, InfoType info_id_type, Handle if (thread.IsNull()) { LOG_ERROR(Kernel_SVC, "Thread handle does not exist, handle=0x{:08X}", static_cast<Handle>(handle)); - return ResultInvalidHandle; + R_THROW(ResultInvalidHandle); } const auto& core_timing = system.CoreTiming(); @@ -230,7 +205,7 @@ Result GetInfo(Core::System& system, u64* result, InfoType info_id_type, Handle } *result = out_ticks; - return ResultSuccess; + R_SUCCEED(); } case InfoType::IdleTickCount: { // Verify the input handle is invalid. @@ -244,7 +219,7 @@ Result GetInfo(Core::System& system, u64* result, InfoType info_id_type, Handle // Get the idle tick count. *result = system.Kernel().CurrentScheduler()->GetIdleThread()->GetCpuTime(); - return ResultSuccess; + R_SUCCEED(); } case InfoType::MesosphereCurrentProcess: { // Verify the input handle is invalid. @@ -259,17 +234,17 @@ Result GetInfo(Core::System& system, u64* result, InfoType info_id_type, Handle // Get a new handle for the current process. Handle tmp; - R_TRY(handle_table.Add(&tmp, current_process)); + R_TRY(handle_table.Add(std::addressof(tmp), current_process)); // Set the output. *result = tmp; // We succeeded. - return ResultSuccess; + R_SUCCEED(); } default: LOG_ERROR(Kernel_SVC, "Unimplemented svcGetInfo id=0x{:016X}", info_id); - return ResultInvalidEnumValue; + R_THROW(ResultInvalidEnumValue); } } diff --git a/src/core/hle/kernel/svc/svc_ipc.cpp b/src/core/hle/kernel/svc/svc_ipc.cpp index a7a2c3b92..46fd0f2ea 100644 --- a/src/core/hle/kernel/svc/svc_ipc.cpp +++ b/src/core/hle/kernel/svc/svc_ipc.cpp @@ -19,7 +19,7 @@ Result SendSyncRequest(Core::System& system, Handle handle) { LOG_TRACE(Kernel_SVC, "called handle=0x{:08X}({})", handle, session->GetName()); - return session->SendSyncRequest(); + R_RETURN(session->SendSyncRequest()); } Result SendSyncRequestWithUserBuffer(Core::System& system, uint64_t message_buffer, @@ -79,10 +79,10 @@ Result ReplyAndReceive(Core::System& system, s32* out_index, uint64_t handles_ad while (true) { // Wait for an object. s32 index; - Result result = KSynchronizationObject::Wait(kernel, &index, objs.data(), + Result result = KSynchronizationObject::Wait(kernel, std::addressof(index), objs.data(), static_cast<s32>(objs.size()), timeout_ns); if (result == ResultTimedOut) { - return result; + R_RETURN(result); } // Receive the request. @@ -97,7 +97,7 @@ Result ReplyAndReceive(Core::System& system, s32* out_index, uint64_t handles_ad } *out_index = index; - return result; + R_RETURN(result); } } diff --git a/src/core/hle/kernel/svc/svc_lock.cpp b/src/core/hle/kernel/svc/svc_lock.cpp index f3d3e140b..3681279d6 100644 --- a/src/core/hle/kernel/svc/svc_lock.cpp +++ b/src/core/hle/kernel/svc/svc_lock.cpp @@ -14,17 +14,10 @@ Result ArbitrateLock(Core::System& system, Handle thread_handle, VAddr address, thread_handle, address, tag); // Validate the input address. - if (IsKernelAddress(address)) { - LOG_ERROR(Kernel_SVC, "Attempting to arbitrate a lock on a kernel address (address={:08X})", - address); - return ResultInvalidCurrentMemory; - } - if (!Common::IsAligned(address, sizeof(u32))) { - LOG_ERROR(Kernel_SVC, "Input address must be 4 byte aligned (address: {:08X})", address); - return ResultInvalidAddress; - } + R_UNLESS(!IsKernelAddress(address), ResultInvalidCurrentMemory); + R_UNLESS(Common::IsAligned(address, sizeof(u32)), ResultInvalidAddress); - return GetCurrentProcess(system.Kernel()).WaitForAddress(thread_handle, address, tag); + R_RETURN(GetCurrentProcess(system.Kernel()).WaitForAddress(thread_handle, address, tag)); } /// Unlock a mutex @@ -32,18 +25,10 @@ Result ArbitrateUnlock(Core::System& system, VAddr address) { LOG_TRACE(Kernel_SVC, "called address=0x{:X}", address); // Validate the input address. - if (IsKernelAddress(address)) { - LOG_ERROR(Kernel_SVC, - "Attempting to arbitrate an unlock on a kernel address (address={:08X})", - address); - return ResultInvalidCurrentMemory; - } - if (!Common::IsAligned(address, sizeof(u32))) { - LOG_ERROR(Kernel_SVC, "Input address must be 4 byte aligned (address: {:08X})", address); - return ResultInvalidAddress; - } + R_UNLESS(!IsKernelAddress(address), ResultInvalidCurrentMemory); + R_UNLESS(Common::IsAligned(address, sizeof(u32)), ResultInvalidAddress); - return GetCurrentProcess(system.Kernel()).SignalToAddress(address); + R_RETURN(GetCurrentProcess(system.Kernel()).SignalToAddress(address)); } Result ArbitrateLock64(Core::System& system, Handle thread_handle, uint64_t address, uint32_t tag) { diff --git a/src/core/hle/kernel/svc/svc_memory.cpp b/src/core/hle/kernel/svc/svc_memory.cpp index 214bcd073..4db25a3b7 100644 --- a/src/core/hle/kernel/svc/svc_memory.cpp +++ b/src/core/hle/kernel/svc/svc_memory.cpp @@ -33,49 +33,49 @@ Result MapUnmapMemorySanityChecks(const KPageTable& manager, VAddr dst_addr, VAd u64 size) { if (!Common::Is4KBAligned(dst_addr)) { LOG_ERROR(Kernel_SVC, "Destination address is not aligned to 4KB, 0x{:016X}", dst_addr); - return ResultInvalidAddress; + R_THROW(ResultInvalidAddress); } if (!Common::Is4KBAligned(src_addr)) { LOG_ERROR(Kernel_SVC, "Source address is not aligned to 4KB, 0x{:016X}", src_addr); - return ResultInvalidSize; + R_THROW(ResultInvalidSize); } if (size == 0) { LOG_ERROR(Kernel_SVC, "Size is 0"); - return ResultInvalidSize; + R_THROW(ResultInvalidSize); } if (!Common::Is4KBAligned(size)) { LOG_ERROR(Kernel_SVC, "Size is not aligned to 4KB, 0x{:016X}", size); - return ResultInvalidSize; + R_THROW(ResultInvalidSize); } if (!IsValidAddressRange(dst_addr, size)) { LOG_ERROR(Kernel_SVC, "Destination is not a valid address range, addr=0x{:016X}, size=0x{:016X}", dst_addr, size); - return ResultInvalidCurrentMemory; + R_THROW(ResultInvalidCurrentMemory); } if (!IsValidAddressRange(src_addr, size)) { LOG_ERROR(Kernel_SVC, "Source is not a valid address range, addr=0x{:016X}, size=0x{:016X}", src_addr, size); - return ResultInvalidCurrentMemory; + R_THROW(ResultInvalidCurrentMemory); } if (!manager.IsInsideAddressSpace(src_addr, size)) { LOG_ERROR(Kernel_SVC, "Source is not within the address space, addr=0x{:016X}, size=0x{:016X}", src_addr, size); - return ResultInvalidCurrentMemory; + R_THROW(ResultInvalidCurrentMemory); } if (manager.IsOutsideStackRegion(dst_addr, size)) { LOG_ERROR(Kernel_SVC, "Destination is not within the stack region, addr=0x{:016X}, size=0x{:016X}", dst_addr, size); - return ResultInvalidMemoryRegion; + R_THROW(ResultInvalidMemoryRegion); } if (manager.IsInsideHeapRegion(dst_addr, size)) { @@ -83,7 +83,7 @@ Result MapUnmapMemorySanityChecks(const KPageTable& manager, VAddr dst_addr, VAd "Destination does not fit within the heap region, addr=0x{:016X}, " "size=0x{:016X}", dst_addr, size); - return ResultInvalidMemoryRegion; + R_THROW(ResultInvalidMemoryRegion); } if (manager.IsInsideAliasRegion(dst_addr, size)) { @@ -91,10 +91,10 @@ Result MapUnmapMemorySanityChecks(const KPageTable& manager, VAddr dst_addr, VAd "Destination does not fit within the map region, addr=0x{:016X}, " "size=0x{:016X}", dst_addr, size); - return ResultInvalidMemoryRegion; + R_THROW(ResultInvalidMemoryRegion); } - return ResultSuccess; + R_SUCCEED(); } } // namespace @@ -117,7 +117,7 @@ Result SetMemoryPermission(Core::System& system, VAddr address, u64 size, Memory R_UNLESS(page_table.Contains(address, size), ResultInvalidCurrentMemory); // Set the memory attribute. - return page_table.SetMemoryPermission(address, size, perm); + R_RETURN(page_table.SetMemoryPermission(address, size, perm)); } Result SetMemoryAttribute(Core::System& system, VAddr address, u64 size, u32 mask, u32 attr) { @@ -141,7 +141,7 @@ Result SetMemoryAttribute(Core::System& system, VAddr address, u64 size, u32 mas R_UNLESS(page_table.Contains(address, size), ResultInvalidCurrentMemory); // Set the memory attribute. - return page_table.SetMemoryAttribute(address, size, mask, attr); + R_RETURN(page_table.SetMemoryAttribute(address, size, mask, attr)); } /// Maps a memory range into a different range. @@ -156,7 +156,7 @@ Result MapMemory(Core::System& system, VAddr dst_addr, VAddr src_addr, u64 size) return result; } - return page_table.MapMemory(dst_addr, src_addr, size); + R_RETURN(page_table.MapMemory(dst_addr, src_addr, size)); } /// Unmaps a region that was previously mapped with svcMapMemory @@ -171,7 +171,7 @@ Result UnmapMemory(Core::System& system, VAddr dst_addr, VAddr src_addr, u64 siz return result; } - return page_table.UnmapMemory(dst_addr, src_addr, size); + R_RETURN(page_table.UnmapMemory(dst_addr, src_addr, size)); } Result SetMemoryPermission64(Core::System& system, uint64_t address, uint64_t size, diff --git a/src/core/hle/kernel/svc/svc_physical_memory.cpp b/src/core/hle/kernel/svc/svc_physical_memory.cpp index ed6a624ac..63196e1ed 100644 --- a/src/core/hle/kernel/svc/svc_physical_memory.cpp +++ b/src/core/hle/kernel/svc/svc_physical_memory.cpp @@ -16,9 +16,7 @@ Result SetHeapSize(Core::System& system, VAddr* out_address, u64 size) { R_UNLESS(size < MainMemorySizeMax, ResultInvalidSize); // Set the heap size. - R_TRY(GetCurrentProcess(system.Kernel()).PageTable().SetHeapSize(out_address, size)); - - return ResultSuccess; + R_RETURN(GetCurrentProcess(system.Kernel()).PageTable().SetHeapSize(out_address, size)); } /// Maps memory at a desired address @@ -27,22 +25,22 @@ Result MapPhysicalMemory(Core::System& system, VAddr addr, u64 size) { if (!Common::Is4KBAligned(addr)) { LOG_ERROR(Kernel_SVC, "Address is not aligned to 4KB, 0x{:016X}", addr); - return ResultInvalidAddress; + R_THROW(ResultInvalidAddress); } if (!Common::Is4KBAligned(size)) { LOG_ERROR(Kernel_SVC, "Size is not aligned to 4KB, 0x{:X}", size); - return ResultInvalidSize; + R_THROW(ResultInvalidSize); } if (size == 0) { LOG_ERROR(Kernel_SVC, "Size is zero"); - return ResultInvalidSize; + R_THROW(ResultInvalidSize); } if (!(addr < addr + size)) { LOG_ERROR(Kernel_SVC, "Size causes 64-bit overflow of address"); - return ResultInvalidMemoryRegion; + R_THROW(ResultInvalidMemoryRegion); } KProcess* const current_process{GetCurrentProcessPointer(system.Kernel())}; @@ -50,24 +48,24 @@ Result MapPhysicalMemory(Core::System& system, VAddr addr, u64 size) { if (current_process->GetSystemResourceSize() == 0) { LOG_ERROR(Kernel_SVC, "System Resource Size is zero"); - return ResultInvalidState; + R_THROW(ResultInvalidState); } if (!page_table.IsInsideAddressSpace(addr, size)) { LOG_ERROR(Kernel_SVC, "Address is not within the address space, addr=0x{:016X}, size=0x{:016X}", addr, size); - return ResultInvalidMemoryRegion; + R_THROW(ResultInvalidMemoryRegion); } if (page_table.IsOutsideAliasRegion(addr, size)) { LOG_ERROR(Kernel_SVC, "Address is not within the alias region, addr=0x{:016X}, size=0x{:016X}", addr, size); - return ResultInvalidMemoryRegion; + R_THROW(ResultInvalidMemoryRegion); } - return page_table.MapPhysicalMemory(addr, size); + R_RETURN(page_table.MapPhysicalMemory(addr, size)); } /// Unmaps memory previously mapped via MapPhysicalMemory @@ -76,22 +74,22 @@ Result UnmapPhysicalMemory(Core::System& system, VAddr addr, u64 size) { if (!Common::Is4KBAligned(addr)) { LOG_ERROR(Kernel_SVC, "Address is not aligned to 4KB, 0x{:016X}", addr); - return ResultInvalidAddress; + R_THROW(ResultInvalidAddress); } if (!Common::Is4KBAligned(size)) { LOG_ERROR(Kernel_SVC, "Size is not aligned to 4KB, 0x{:X}", size); - return ResultInvalidSize; + R_THROW(ResultInvalidSize); } if (size == 0) { LOG_ERROR(Kernel_SVC, "Size is zero"); - return ResultInvalidSize; + R_THROW(ResultInvalidSize); } if (!(addr < addr + size)) { LOG_ERROR(Kernel_SVC, "Size causes 64-bit overflow of address"); - return ResultInvalidMemoryRegion; + R_THROW(ResultInvalidMemoryRegion); } KProcess* const current_process{GetCurrentProcessPointer(system.Kernel())}; @@ -99,24 +97,24 @@ Result UnmapPhysicalMemory(Core::System& system, VAddr addr, u64 size) { if (current_process->GetSystemResourceSize() == 0) { LOG_ERROR(Kernel_SVC, "System Resource Size is zero"); - return ResultInvalidState; + R_THROW(ResultInvalidState); } if (!page_table.IsInsideAddressSpace(addr, size)) { LOG_ERROR(Kernel_SVC, "Address is not within the address space, addr=0x{:016X}, size=0x{:016X}", addr, size); - return ResultInvalidMemoryRegion; + R_THROW(ResultInvalidMemoryRegion); } if (page_table.IsOutsideAliasRegion(addr, size)) { LOG_ERROR(Kernel_SVC, "Address is not within the alias region, addr=0x{:016X}, size=0x{:016X}", addr, size); - return ResultInvalidMemoryRegion; + R_THROW(ResultInvalidMemoryRegion); } - return page_table.UnmapPhysicalMemory(addr, size); + R_RETURN(page_table.UnmapPhysicalMemory(addr, size)); } Result MapPhysicalMemoryUnsafe(Core::System& system, uint64_t address, uint64_t size) { diff --git a/src/core/hle/kernel/svc/svc_port.cpp b/src/core/hle/kernel/svc/svc_port.cpp index 78c2a8d17..0b5556bc4 100644 --- a/src/core/hle/kernel/svc/svc_port.cpp +++ b/src/core/hle/kernel/svc/svc_port.cpp @@ -81,7 +81,7 @@ Result ManageNamedPort(Core::System& system, Handle* out_server_handle, uint64_t R_UNLESS(port != nullptr, ResultOutOfResource); // Initialize the new port. - port->Initialize(max_sessions, false, ""); + port->Initialize(max_sessions, false, 0); // Register the port. KPort::Register(system.Kernel(), port); diff --git a/src/core/hle/kernel/svc/svc_process.cpp b/src/core/hle/kernel/svc/svc_process.cpp index c35d2be76..b538c37e7 100644 --- a/src/core/hle/kernel/svc/svc_process.cpp +++ b/src/core/hle/kernel/svc/svc_process.cpp @@ -11,7 +11,7 @@ namespace Kernel::Svc { void ExitProcess(Core::System& system) { auto* current_process = GetCurrentProcessPointer(system.Kernel()); - LOG_INFO(Kernel_SVC, "Process {} exiting", current_process->GetProcessID()); + LOG_INFO(Kernel_SVC, "Process {} exiting", current_process->GetProcessId()); ASSERT_MSG(current_process->GetState() == KProcess::State::Running, "Process has already exited"); @@ -47,7 +47,7 @@ Result GetProcessId(Core::System& system, u64* out_process_id, Handle handle) { // Get the process id. *out_process_id = process->GetId(); - return ResultSuccess; + R_SUCCEED(); } Result GetProcessList(Core::System& system, s32* out_num_processes, VAddr out_process_ids, @@ -60,7 +60,7 @@ Result GetProcessList(Core::System& system, s32* out_num_processes, VAddr out_pr LOG_ERROR(Kernel_SVC, "Supplied size outside [0, 0x0FFFFFFF] range. out_process_ids_size={}", out_process_ids_size); - return ResultOutOfRange; + R_THROW(ResultOutOfRange); } auto& kernel = system.Kernel(); @@ -70,7 +70,7 @@ Result GetProcessList(Core::System& system, s32* out_num_processes, VAddr out_pr out_process_ids, total_copy_size)) { LOG_ERROR(Kernel_SVC, "Address range outside address space. begin=0x{:016X}, end=0x{:016X}", out_process_ids, out_process_ids + total_copy_size); - return ResultInvalidCurrentMemory; + R_THROW(ResultInvalidCurrentMemory); } auto& memory = system.Memory(); @@ -80,12 +80,12 @@ Result GetProcessList(Core::System& system, s32* out_num_processes, VAddr out_pr std::min(static_cast<std::size_t>(out_process_ids_size), num_processes); for (std::size_t i = 0; i < copy_amount; ++i) { - memory.Write64(out_process_ids, process_list[i]->GetProcessID()); + memory.Write64(out_process_ids, process_list[i]->GetProcessId()); out_process_ids += sizeof(u64); } *out_num_processes = static_cast<u32>(num_processes); - return ResultSuccess; + R_SUCCEED(); } Result GetProcessInfo(Core::System& system, s64* out, Handle process_handle, @@ -97,17 +97,17 @@ Result GetProcessInfo(Core::System& system, s64* out, Handle process_handle, if (process.IsNull()) { LOG_ERROR(Kernel_SVC, "Process handle does not exist, process_handle=0x{:08X}", process_handle); - return ResultInvalidHandle; + R_THROW(ResultInvalidHandle); } if (info_type != ProcessInfoType::ProcessState) { LOG_ERROR(Kernel_SVC, "Expected info_type to be ProcessState but got {} instead", info_type); - return ResultInvalidEnumValue; + R_THROW(ResultInvalidEnumValue); } *out = static_cast<s64>(process->GetState()); - return ResultSuccess; + R_SUCCEED(); } Result CreateProcess(Core::System& system, Handle* out_handle, uint64_t parameters, uint64_t caps, diff --git a/src/core/hle/kernel/svc/svc_process_memory.cpp b/src/core/hle/kernel/svc/svc_process_memory.cpp index 8e2fb4092..f9210ca1e 100644 --- a/src/core/hle/kernel/svc/svc_process_memory.cpp +++ b/src/core/hle/kernel/svc/svc_process_memory.cpp @@ -53,7 +53,7 @@ Result SetProcessMemoryPermission(Core::System& system, Handle process_handle, V R_UNLESS(page_table.Contains(address, size), ResultInvalidCurrentMemory); // Set the memory permission. - return page_table.SetProcessMemoryPermission(address, size, perm); + R_RETURN(page_table.SetProcessMemoryPermission(address, size, perm)); } Result MapProcessMemory(Core::System& system, VAddr dst_address, Handle process_handle, @@ -93,10 +93,8 @@ Result MapProcessMemory(Core::System& system, VAddr dst_address, Handle process_ KMemoryAttribute::All, KMemoryAttribute::None)); // Map the group. - R_TRY(dst_pt.MapPageGroup(dst_address, pg, KMemoryState::SharedCode, - KMemoryPermission::UserReadWrite)); - - return ResultSuccess; + R_RETURN(dst_pt.MapPageGroup(dst_address, pg, KMemoryState::SharedCode, + KMemoryPermission::UserReadWrite)); } Result UnmapProcessMemory(Core::System& system, VAddr dst_address, Handle process_handle, @@ -129,9 +127,7 @@ Result UnmapProcessMemory(Core::System& system, VAddr dst_address, Handle proces ResultInvalidMemoryRegion); // Unmap the memory. - R_TRY(dst_pt.UnmapProcessMemory(dst_address, size, src_pt, src_address)); - - return ResultSuccess; + R_RETURN(dst_pt.UnmapProcessMemory(dst_address, size, src_pt, src_address)); } Result MapProcessCodeMemory(Core::System& system, Handle process_handle, u64 dst_address, @@ -144,18 +140,18 @@ Result MapProcessCodeMemory(Core::System& system, Handle process_handle, u64 dst if (!Common::Is4KBAligned(src_address)) { LOG_ERROR(Kernel_SVC, "src_address is not page-aligned (src_address=0x{:016X}).", src_address); - return ResultInvalidAddress; + R_THROW(ResultInvalidAddress); } if (!Common::Is4KBAligned(dst_address)) { LOG_ERROR(Kernel_SVC, "dst_address is not page-aligned (dst_address=0x{:016X}).", dst_address); - return ResultInvalidAddress; + R_THROW(ResultInvalidAddress); } if (size == 0 || !Common::Is4KBAligned(size)) { LOG_ERROR(Kernel_SVC, "Size is zero or not page-aligned (size=0x{:016X})", size); - return ResultInvalidSize; + R_THROW(ResultInvalidSize); } if (!IsValidAddressRange(dst_address, size)) { @@ -163,7 +159,7 @@ Result MapProcessCodeMemory(Core::System& system, Handle process_handle, u64 dst "Destination address range overflows the address space (dst_address=0x{:016X}, " "size=0x{:016X}).", dst_address, size); - return ResultInvalidCurrentMemory; + R_THROW(ResultInvalidCurrentMemory); } if (!IsValidAddressRange(src_address, size)) { @@ -171,7 +167,7 @@ Result MapProcessCodeMemory(Core::System& system, Handle process_handle, u64 dst "Source address range overflows the address space (src_address=0x{:016X}, " "size=0x{:016X}).", src_address, size); - return ResultInvalidCurrentMemory; + R_THROW(ResultInvalidCurrentMemory); } const auto& handle_table = GetCurrentProcess(system.Kernel()).GetHandleTable(); @@ -179,7 +175,7 @@ Result MapProcessCodeMemory(Core::System& system, Handle process_handle, u64 dst if (process.IsNull()) { LOG_ERROR(Kernel_SVC, "Invalid process handle specified (handle=0x{:08X}).", process_handle); - return ResultInvalidHandle; + R_THROW(ResultInvalidHandle); } auto& page_table = process->PageTable(); @@ -188,7 +184,7 @@ Result MapProcessCodeMemory(Core::System& system, Handle process_handle, u64 dst "Source address range is not within the address space (src_address=0x{:016X}, " "size=0x{:016X}).", src_address, size); - return ResultInvalidCurrentMemory; + R_THROW(ResultInvalidCurrentMemory); } if (!page_table.IsInsideASLRRegion(dst_address, size)) { @@ -196,10 +192,10 @@ Result MapProcessCodeMemory(Core::System& system, Handle process_handle, u64 dst "Destination address range is not within the ASLR region (dst_address=0x{:016X}, " "size=0x{:016X}).", dst_address, size); - return ResultInvalidMemoryRegion; + R_THROW(ResultInvalidMemoryRegion); } - return page_table.MapCodeMemory(dst_address, src_address, size); + R_RETURN(page_table.MapCodeMemory(dst_address, src_address, size)); } Result UnmapProcessCodeMemory(Core::System& system, Handle process_handle, u64 dst_address, @@ -212,18 +208,18 @@ Result UnmapProcessCodeMemory(Core::System& system, Handle process_handle, u64 d if (!Common::Is4KBAligned(dst_address)) { LOG_ERROR(Kernel_SVC, "dst_address is not page-aligned (dst_address=0x{:016X}).", dst_address); - return ResultInvalidAddress; + R_THROW(ResultInvalidAddress); } if (!Common::Is4KBAligned(src_address)) { LOG_ERROR(Kernel_SVC, "src_address is not page-aligned (src_address=0x{:016X}).", src_address); - return ResultInvalidAddress; + R_THROW(ResultInvalidAddress); } if (size == 0 || !Common::Is4KBAligned(size)) { LOG_ERROR(Kernel_SVC, "Size is zero or not page-aligned (size=0x{:016X}).", size); - return ResultInvalidSize; + R_THROW(ResultInvalidSize); } if (!IsValidAddressRange(dst_address, size)) { @@ -231,7 +227,7 @@ Result UnmapProcessCodeMemory(Core::System& system, Handle process_handle, u64 d "Destination address range overflows the address space (dst_address=0x{:016X}, " "size=0x{:016X}).", dst_address, size); - return ResultInvalidCurrentMemory; + R_THROW(ResultInvalidCurrentMemory); } if (!IsValidAddressRange(src_address, size)) { @@ -239,7 +235,7 @@ Result UnmapProcessCodeMemory(Core::System& system, Handle process_handle, u64 d "Source address range overflows the address space (src_address=0x{:016X}, " "size=0x{:016X}).", src_address, size); - return ResultInvalidCurrentMemory; + R_THROW(ResultInvalidCurrentMemory); } const auto& handle_table = GetCurrentProcess(system.Kernel()).GetHandleTable(); @@ -247,7 +243,7 @@ Result UnmapProcessCodeMemory(Core::System& system, Handle process_handle, u64 d if (process.IsNull()) { LOG_ERROR(Kernel_SVC, "Invalid process handle specified (handle=0x{:08X}).", process_handle); - return ResultInvalidHandle; + R_THROW(ResultInvalidHandle); } auto& page_table = process->PageTable(); @@ -256,7 +252,7 @@ Result UnmapProcessCodeMemory(Core::System& system, Handle process_handle, u64 d "Source address range is not within the address space (src_address=0x{:016X}, " "size=0x{:016X}).", src_address, size); - return ResultInvalidCurrentMemory; + R_THROW(ResultInvalidCurrentMemory); } if (!page_table.IsInsideASLRRegion(dst_address, size)) { @@ -264,11 +260,11 @@ Result UnmapProcessCodeMemory(Core::System& system, Handle process_handle, u64 d "Destination address range is not within the ASLR region (dst_address=0x{:016X}, " "size=0x{:016X}).", dst_address, size); - return ResultInvalidMemoryRegion; + R_THROW(ResultInvalidMemoryRegion); } - return page_table.UnmapCodeMemory(dst_address, src_address, size, - KPageTable::ICacheInvalidationStrategy::InvalidateAll); + R_RETURN(page_table.UnmapCodeMemory(dst_address, src_address, size, + KPageTable::ICacheInvalidationStrategy::InvalidateAll)); } Result SetProcessMemoryPermission64(Core::System& system, Handle process_handle, uint64_t address, diff --git a/src/core/hle/kernel/svc/svc_query_memory.cpp b/src/core/hle/kernel/svc/svc_query_memory.cpp index ee75ad370..457ebf950 100644 --- a/src/core/hle/kernel/svc/svc_query_memory.cpp +++ b/src/core/hle/kernel/svc/svc_query_memory.cpp @@ -15,8 +15,8 @@ Result QueryMemory(Core::System& system, uint64_t out_memory_info, PageInfo* out out_memory_info, query_address); // Query memory is just QueryProcessMemory on the current process. - return QueryProcessMemory(system, out_memory_info, out_page_info, CurrentProcess, - query_address); + R_RETURN( + QueryProcessMemory(system, out_memory_info, out_page_info, CurrentProcess, query_address)); } Result QueryProcessMemory(Core::System& system, uint64_t out_memory_info, PageInfo* out_page_info, @@ -27,13 +27,13 @@ Result QueryProcessMemory(Core::System& system, uint64_t out_memory_info, PageIn if (process.IsNull()) { LOG_ERROR(Kernel_SVC, "Process handle does not exist, process_handle=0x{:08X}", process_handle); - return ResultInvalidHandle; + R_THROW(ResultInvalidHandle); } auto& memory{system.Memory()}; const auto memory_info{process->PageTable().QueryInfo(address).GetSvcMemoryInfo()}; - memory.WriteBlock(out_memory_info, &memory_info, sizeof(memory_info)); + memory.WriteBlock(out_memory_info, std::addressof(memory_info), sizeof(memory_info)); //! This is supposed to be part of the QueryInfo call. *out_page_info = {}; diff --git a/src/core/hle/kernel/svc/svc_resource_limit.cpp b/src/core/hle/kernel/svc/svc_resource_limit.cpp index 88166299e..732bc017e 100644 --- a/src/core/hle/kernel/svc/svc_resource_limit.cpp +++ b/src/core/hle/kernel/svc/svc_resource_limit.cpp @@ -21,15 +21,13 @@ Result CreateResourceLimit(Core::System& system, Handle* out_handle) { SCOPE_EXIT({ resource_limit->Close(); }); // Initialize the resource limit. - resource_limit->Initialize(&system.CoreTiming()); + resource_limit->Initialize(std::addressof(system.CoreTiming())); // Register the limit. KResourceLimit::Register(kernel, resource_limit); // Add the limit to the handle table. - R_TRY(GetCurrentProcess(kernel).GetHandleTable().Add(out_handle, resource_limit)); - - return ResultSuccess; + R_RETURN(GetCurrentProcess(kernel).GetHandleTable().Add(out_handle, resource_limit)); } Result GetResourceLimitLimitValue(Core::System& system, s64* out_limit_value, @@ -49,7 +47,7 @@ Result GetResourceLimitLimitValue(Core::System& system, s64* out_limit_value, // Get the limit value. *out_limit_value = resource_limit->GetLimitValue(which); - return ResultSuccess; + R_SUCCEED(); } Result GetResourceLimitCurrentValue(Core::System& system, s64* out_current_value, @@ -69,7 +67,7 @@ Result GetResourceLimitCurrentValue(Core::System& system, s64* out_current_value // Get the current value. *out_current_value = resource_limit->GetCurrentValue(which); - return ResultSuccess; + R_SUCCEED(); } Result SetResourceLimitLimitValue(Core::System& system, Handle resource_limit_handle, @@ -87,9 +85,7 @@ Result SetResourceLimitLimitValue(Core::System& system, Handle resource_limit_ha R_UNLESS(resource_limit.IsNotNull(), ResultInvalidHandle); // Set the limit value. - R_TRY(resource_limit->SetLimitValue(which, limit_value)); - - return ResultSuccess; + R_RETURN(resource_limit->SetLimitValue(which, limit_value)); } Result GetResourceLimitPeakValue(Core::System& system, int64_t* out_peak_value, diff --git a/src/core/hle/kernel/svc/svc_secure_monitor_call.cpp b/src/core/hle/kernel/svc/svc_secure_monitor_call.cpp index 20f6ec643..62c781551 100644 --- a/src/core/hle/kernel/svc/svc_secure_monitor_call.cpp +++ b/src/core/hle/kernel/svc/svc_secure_monitor_call.cpp @@ -29,7 +29,7 @@ void SvcWrap_CallSecureMonitor64(Core::System& system) { args.r[i] = core.GetReg(i); } - CallSecureMonitor64(system, &args); + CallSecureMonitor64(system, std::addressof(args)); for (int i = 0; i < 8; i++) { core.SetReg(i, args.r[i]); @@ -43,7 +43,7 @@ void SvcWrap_CallSecureMonitor64From32(Core::System& system) { args.r[i] = static_cast<u32>(core.GetReg(i)); } - CallSecureMonitor64From32(system, &args); + CallSecureMonitor64From32(system, std::addressof(args)); for (int i = 0; i < 8; i++) { core.SetReg(i, args.r[i]); diff --git a/src/core/hle/kernel/svc/svc_session.cpp b/src/core/hle/kernel/svc/svc_session.cpp index 00fd1605e..01b8a52ad 100644 --- a/src/core/hle/kernel/svc/svc_session.cpp +++ b/src/core/hle/kernel/svc/svc_session.cpp @@ -12,7 +12,7 @@ namespace Kernel::Svc { namespace { template <typename T> -Result CreateSession(Core::System& system, Handle* out_server, Handle* out_client, u64 name) { +Result CreateSession(Core::System& system, Handle* out_server, Handle* out_client, uint64_t name) { auto& process = GetCurrentProcess(system.Kernel()); auto& handle_table = process.GetHandleTable(); @@ -21,16 +21,17 @@ Result CreateSession(Core::System& system, Handle* out_server, Handle* out_clien // Reserve a new session from the process resource limit. // FIXME: LimitableResource_SessionCountMax - KScopedResourceReservation session_reservation(&process, LimitableResource::SessionCountMax); + KScopedResourceReservation session_reservation(std::addressof(process), + LimitableResource::SessionCountMax); if (session_reservation.Succeeded()) { session = T::Create(system.Kernel()); } else { - return ResultLimitReached; + R_THROW(ResultLimitReached); // // We couldn't reserve a session. Check that we support dynamically expanding the // // resource limit. // R_UNLESS(process.GetResourceLimit() == - // &system.Kernel().GetSystemResourceLimit(), ResultLimitReached); + // std::addressof(system.Kernel().GetSystemResourceLimit()), ResultLimitReached); // R_UNLESS(KTargetSystem::IsDynamicResourceLimitsEnabled(), ResultLimitReached()); // // Try to allocate a session from unused slab memory. @@ -59,7 +60,7 @@ Result CreateSession(Core::System& system, Handle* out_server, Handle* out_clien R_UNLESS(session != nullptr, ResultOutOfResource); // Initialize the session. - session->Initialize(nullptr, fmt::format("{}", name)); + session->Initialize(nullptr, name); // Commit the session reservation. session_reservation.Commit(); @@ -75,17 +76,15 @@ Result CreateSession(Core::System& system, Handle* out_server, Handle* out_clien T::Register(system.Kernel(), session); // Add the server session to the handle table. - R_TRY(handle_table.Add(out_server, &session->GetServerSession())); + R_TRY(handle_table.Add(out_server, std::addressof(session->GetServerSession()))); - // Add the client session to the handle table. - const auto result = handle_table.Add(out_client, &session->GetClientSession()); - - if (!R_SUCCEEDED(result)) { - // Ensure that we maintaing a clean handle state on exit. + // Ensure that we maintain a clean handle state on exit. + ON_RESULT_FAILURE { handle_table.Remove(*out_server); - } + }; - return result; + // Add the client session to the handle table. + R_RETURN(handle_table.Add(out_client, std::addressof(session->GetClientSession()))); } } // namespace @@ -94,9 +93,9 @@ Result CreateSession(Core::System& system, Handle* out_server, Handle* out_clien u64 name) { if (is_light) { // return CreateSession<KLightSession>(system, out_server, out_client, name); - return ResultNotImplemented; + R_THROW(ResultNotImplemented); } else { - return CreateSession<KSession>(system, out_server, out_client, name); + R_RETURN(CreateSession<KSession>(system, out_server, out_client, name)); } } diff --git a/src/core/hle/kernel/svc/svc_shared_memory.cpp b/src/core/hle/kernel/svc/svc_shared_memory.cpp index 18e0dc904..40d878f17 100644 --- a/src/core/hle/kernel/svc/svc_shared_memory.cpp +++ b/src/core/hle/kernel/svc/svc_shared_memory.cpp @@ -56,15 +56,12 @@ Result MapSharedMemory(Core::System& system, Handle shmem_handle, VAddr address, R_TRY(process.AddSharedMemory(shmem.GetPointerUnsafe(), address, size)); // Ensure that we clean up the shared memory if we fail to map it. - auto guard = - SCOPE_GUARD({ process.RemoveSharedMemory(shmem.GetPointerUnsafe(), address, size); }); + ON_RESULT_FAILURE { + process.RemoveSharedMemory(shmem.GetPointerUnsafe(), address, size); + }; // Map the shared memory. - R_TRY(shmem->Map(process, address, size, map_perm)); - - // We succeeded. - guard.Cancel(); - return ResultSuccess; + R_RETURN(shmem->Map(process, address, size, map_perm)); } Result UnmapSharedMemory(Core::System& system, Handle shmem_handle, VAddr address, u64 size) { @@ -91,7 +88,7 @@ Result UnmapSharedMemory(Core::System& system, Handle shmem_handle, VAddr addres // Remove the shared memory from the process. process.RemoveSharedMemory(shmem.GetPointerUnsafe(), address, size); - return ResultSuccess; + R_SUCCEED(); } Result CreateSharedMemory(Core::System& system, Handle* out_handle, uint64_t size, diff --git a/src/core/hle/kernel/svc/svc_synchronization.cpp b/src/core/hle/kernel/svc/svc_synchronization.cpp index 1a8f7e191..660b45c23 100644 --- a/src/core/hle/kernel/svc/svc_synchronization.cpp +++ b/src/core/hle/kernel/svc/svc_synchronization.cpp @@ -17,7 +17,7 @@ Result CloseHandle(Core::System& system, Handle handle) { R_UNLESS(GetCurrentProcess(system.Kernel()).GetHandleTable().Remove(handle), ResultInvalidHandle); - return ResultSuccess; + R_SUCCEED(); } /// Clears the signaled state of an event or process. @@ -31,7 +31,7 @@ Result ResetSignal(Core::System& system, Handle handle) { { KScopedAutoObject readable_event = handle_table.GetObject<KReadableEvent>(handle); if (readable_event.IsNotNull()) { - return readable_event->Reset(); + R_RETURN(readable_event->Reset()); } } @@ -39,28 +39,22 @@ Result ResetSignal(Core::System& system, Handle handle) { { KScopedAutoObject process = handle_table.GetObject<KProcess>(handle); if (process.IsNotNull()) { - return process->Reset(); + R_RETURN(process->Reset()); } } - LOG_ERROR(Kernel_SVC, "invalid handle (0x{:08X})", handle); - - return ResultInvalidHandle; + R_THROW(ResultInvalidHandle); } -/// Wait for the given handles to synchronize, timeout after the specified nanoseconds -Result WaitSynchronization(Core::System& system, s32* index, VAddr handles_address, s32 num_handles, - s64 nano_seconds) { - LOG_TRACE(Kernel_SVC, "called handles_address=0x{:X}, num_handles={}, nano_seconds={}", - handles_address, num_handles, nano_seconds); - +static Result WaitSynchronization(Core::System& system, int32_t* out_index, const Handle* handles, + int32_t num_handles, int64_t timeout_ns) { // Ensure number of handles is valid. - R_UNLESS(0 <= num_handles && num_handles <= ArgumentHandleCountMax, ResultOutOfRange); + R_UNLESS(0 <= num_handles && num_handles <= Svc::ArgumentHandleCountMax, ResultOutOfRange); + // Get the synchronization context. auto& kernel = system.Kernel(); + auto& handle_table = GetCurrentProcess(kernel).GetHandleTable(); std::vector<KSynchronizationObject*> objs(num_handles); - const auto& handle_table = GetCurrentProcess(kernel).GetHandleTable(); - Handle* handles = system.Memory().GetPointer<Handle>(handles_address); // Copy user handles. if (num_handles > 0) { @@ -68,21 +62,38 @@ Result WaitSynchronization(Core::System& system, s32* index, VAddr handles_addre R_UNLESS(handle_table.GetMultipleObjects<KSynchronizationObject>(objs.data(), handles, num_handles), ResultInvalidHandle); - for (const auto& obj : objs) { - kernel.RegisterInUseObject(obj); - } } // Ensure handles are closed when we're done. SCOPE_EXIT({ - for (s32 i = 0; i < num_handles; ++i) { - kernel.UnregisterInUseObject(objs[i]); + for (auto i = 0; i < num_handles; ++i) { objs[i]->Close(); } }); - return KSynchronizationObject::Wait(kernel, index, objs.data(), static_cast<s32>(objs.size()), - nano_seconds); + // Wait on the objects. + Result res = KSynchronizationObject::Wait(kernel, out_index, objs.data(), + static_cast<s32>(objs.size()), timeout_ns); + + R_SUCCEED_IF(res == ResultSessionClosed); + R_RETURN(res); +} + +/// Wait for the given handles to synchronize, timeout after the specified nanoseconds +Result WaitSynchronization(Core::System& system, int32_t* out_index, VAddr user_handles, + int32_t num_handles, int64_t timeout_ns) { + LOG_TRACE(Kernel_SVC, "called user_handles={:#x}, num_handles={}, timeout_ns={}", user_handles, + num_handles, timeout_ns); + + // Ensure number of handles is valid. + R_UNLESS(0 <= num_handles && num_handles <= Svc::ArgumentHandleCountMax, ResultOutOfRange); + + std::vector<Handle> handles(num_handles); + if (num_handles > 0) { + system.Memory().ReadBlock(user_handles, handles.data(), num_handles * sizeof(Handle)); + } + + R_RETURN(WaitSynchronization(system, out_index, handles.data(), num_handles, timeout_ns)); } /// Resumes a thread waiting on WaitSynchronization @@ -96,7 +107,7 @@ Result CancelSynchronization(Core::System& system, Handle handle) { // Cancel the thread's wait. thread->WaitCancel(); - return ResultSuccess; + R_SUCCEED(); } void SynchronizePreemptionState(Core::System& system) { diff --git a/src/core/hle/kernel/svc/svc_thread.cpp b/src/core/hle/kernel/svc/svc_thread.cpp index b39807841..50991fb62 100644 --- a/src/core/hle/kernel/svc/svc_thread.cpp +++ b/src/core/hle/kernel/svc/svc_thread.cpp @@ -34,61 +34,42 @@ Result CreateThread(Core::System& system, Handle* out_handle, VAddr entry_point, } // Validate arguments. - if (!IsValidVirtualCoreId(core_id)) { - LOG_ERROR(Kernel_SVC, "Invalid Core ID specified (id={})", core_id); - return ResultInvalidCoreId; - } - if (((1ULL << core_id) & process.GetCoreMask()) == 0) { - LOG_ERROR(Kernel_SVC, "Core ID doesn't fall within allowable cores (id={})", core_id); - return ResultInvalidCoreId; - } + R_UNLESS(IsValidVirtualCoreId(core_id), ResultInvalidCoreId); + R_UNLESS(((1ull << core_id) & process.GetCoreMask()) != 0, ResultInvalidCoreId); - if (HighestThreadPriority > priority || priority > LowestThreadPriority) { - LOG_ERROR(Kernel_SVC, "Invalid priority specified (priority={})", priority); - return ResultInvalidPriority; - } - if (!process.CheckThreadPriority(priority)) { - LOG_ERROR(Kernel_SVC, "Invalid allowable thread priority (priority={})", priority); - return ResultInvalidPriority; - } + R_UNLESS(HighestThreadPriority <= priority && priority <= LowestThreadPriority, + ResultInvalidPriority); + R_UNLESS(process.CheckThreadPriority(priority), ResultInvalidPriority); // Reserve a new thread from the process resource limit (waiting up to 100ms). - KScopedResourceReservation thread_reservation(&process, LimitableResource::ThreadCountMax, 1, - system.CoreTiming().GetGlobalTimeNs().count() + - 100000000); - if (!thread_reservation.Succeeded()) { - LOG_ERROR(Kernel_SVC, "Could not reserve a new thread"); - return ResultLimitReached; - } + KScopedResourceReservation thread_reservation( + std::addressof(process), LimitableResource::ThreadCountMax, 1, + system.CoreTiming().GetGlobalTimeNs().count() + 100000000); + R_UNLESS(thread_reservation.Succeeded(), ResultLimitReached); // Create the thread. KThread* thread = KThread::Create(kernel); - if (!thread) { - LOG_ERROR(Kernel_SVC, "Unable to create new threads. Thread creation limit reached."); - return ResultOutOfResource; - } + R_UNLESS(thread != nullptr, ResultOutOfResource) SCOPE_EXIT({ thread->Close(); }); // Initialize the thread. { KScopedLightLock lk{process.GetStateLock()}; R_TRY(KThread::InitializeUserThread(system, thread, entry_point, arg, stack_bottom, - priority, core_id, &process)); + priority, core_id, std::addressof(process))); } - // Set the thread name for debugging purposes. - thread->SetName(fmt::format("thread[entry_point={:X}, handle={:X}]", entry_point, *out_handle)); - // Commit the thread reservation. thread_reservation.Commit(); + // Clone the current fpu status to the new thread. + thread->CloneFpuStatus(); + // Register the new thread. KThread::Register(kernel, thread); // Add the thread to the handle table. - R_TRY(process.GetHandleTable().Add(out_handle, thread)); - - return ResultSuccess; + R_RETURN(process.GetHandleTable().Add(out_handle, thread)); } /// Starts the thread for the provided handle @@ -107,7 +88,7 @@ Result StartThread(Core::System& system, Handle thread_handle) { thread->Open(); system.Kernel().RegisterInUseObject(thread.GetPointerUnsafe()); - return ResultSuccess; + R_SUCCEED(); } /// Called when a thread exits @@ -199,10 +180,8 @@ Result GetThreadContext3(Core::System& system, VAddr out_context, Handle thread_ // Copy the thread context to user space. system.Memory().WriteBlock(out_context, context.data(), context.size()); - return ResultSuccess; + R_SUCCEED(); } - - return ResultSuccess; } /// Gets the priority for the specified thread @@ -216,7 +195,7 @@ Result GetThreadPriority(Core::System& system, s32* out_priority, Handle handle) // Get the thread's priority. *out_priority = thread->GetPriority(); - return ResultSuccess; + R_SUCCEED(); } /// Sets the priority for the specified thread @@ -235,7 +214,7 @@ Result SetThreadPriority(Core::System& system, Handle thread_handle, s32 priorit // Set the thread priority. thread->SetBasePriority(priority); - return ResultSuccess; + R_SUCCEED(); } Result GetThreadList(Core::System& system, s32* out_num_threads, VAddr out_thread_ids, @@ -250,7 +229,7 @@ Result GetThreadList(Core::System& system, s32* out_num_threads, VAddr out_threa if ((out_thread_ids_size & 0xF0000000) != 0) { LOG_ERROR(Kernel_SVC, "Supplied size outside [0, 0x0FFFFFFF] range. size={}", out_thread_ids_size); - return ResultOutOfRange; + R_THROW(ResultOutOfRange); } auto* const current_process = GetCurrentProcessPointer(system.Kernel()); @@ -260,7 +239,7 @@ Result GetThreadList(Core::System& system, s32* out_num_threads, VAddr out_threa !current_process->PageTable().IsInsideAddressSpace(out_thread_ids, total_copy_size)) { LOG_ERROR(Kernel_SVC, "Address range outside address space. begin=0x{:016X}, end=0x{:016X}", out_thread_ids, out_thread_ids + total_copy_size); - return ResultInvalidCurrentMemory; + R_THROW(ResultInvalidCurrentMemory); } auto& memory = system.Memory(); @@ -270,12 +249,12 @@ Result GetThreadList(Core::System& system, s32* out_num_threads, VAddr out_threa auto list_iter = thread_list.cbegin(); for (std::size_t i = 0; i < copy_amount; ++i, ++list_iter) { - memory.Write64(out_thread_ids, (*list_iter)->GetThreadID()); + memory.Write64(out_thread_ids, (*list_iter)->GetThreadId()); out_thread_ids += sizeof(u64); } *out_num_threads = static_cast<u32>(num_threads); - return ResultSuccess; + R_SUCCEED(); } Result GetThreadCoreMask(Core::System& system, s32* out_core_id, u64* out_affinity_mask, @@ -288,9 +267,7 @@ Result GetThreadCoreMask(Core::System& system, s32* out_core_id, u64* out_affini R_UNLESS(thread.IsNotNull(), ResultInvalidHandle); // Get the core mask. - R_TRY(thread->GetCoreMask(out_core_id, out_affinity_mask)); - - return ResultSuccess; + R_RETURN(thread->GetCoreMask(out_core_id, out_affinity_mask)); } Result SetThreadCoreMask(Core::System& system, Handle thread_handle, s32 core_id, @@ -320,9 +297,7 @@ Result SetThreadCoreMask(Core::System& system, Handle thread_handle, s32 core_id R_UNLESS(thread.IsNotNull(), ResultInvalidHandle); // Set the core mask. - R_TRY(thread->SetCoreMask(core_id, affinity_mask)); - - return ResultSuccess; + R_RETURN(thread->SetCoreMask(core_id, affinity_mask)); } /// Get the ID for the specified thread. @@ -334,7 +309,7 @@ Result GetThreadId(Core::System& system, u64* out_thread_id, Handle thread_handl // Get the thread's id. *out_thread_id = thread->GetId(); - return ResultSuccess; + R_SUCCEED(); } Result CreateThread64(Core::System& system, Handle* out_handle, uint64_t func, uint64_t arg, diff --git a/src/core/hle/kernel/svc/svc_transfer_memory.cpp b/src/core/hle/kernel/svc/svc_transfer_memory.cpp index 7ffc24adf..394f06728 100644 --- a/src/core/hle/kernel/svc/svc_transfer_memory.cpp +++ b/src/core/hle/kernel/svc/svc_transfer_memory.cpp @@ -43,7 +43,7 @@ Result CreateTransferMemory(Core::System& system, Handle* out, VAddr address, u6 auto& handle_table = process.GetHandleTable(); // Reserve a new transfer memory from the process resource limit. - KScopedResourceReservation trmem_reservation(&process, + KScopedResourceReservation trmem_reservation(std::addressof(process), LimitableResource::TransferMemoryCountMax); R_UNLESS(trmem_reservation.Succeeded(), ResultLimitReached); @@ -67,9 +67,7 @@ Result CreateTransferMemory(Core::System& system, Handle* out, VAddr address, u6 KTransferMemory::Register(kernel, trmem); // Add the transfer memory to the handle table. - R_TRY(handle_table.Add(out, trmem)); - - return ResultSuccess; + R_RETURN(handle_table.Add(out, trmem)); } Result MapTransferMemory(Core::System& system, Handle trmem_handle, uint64_t address, uint64_t size, diff --git a/src/core/hle/kernel/svc_generator.py b/src/core/hle/kernel/svc_generator.py index 0cce69e85..7fcbb1ba1 100644 --- a/src/core/hle/kernel/svc_generator.py +++ b/src/core/hle/kernel/svc_generator.py @@ -460,7 +460,7 @@ def emit_wrapper(wrapped_fn, suffix, register_info, arguments, byte_size): call_arguments = ["system"] for arg in arguments: if arg.is_output and not arg.is_outptr: - call_arguments.append(f"&{arg.var_name}") + call_arguments.append(f"std::addressof({arg.var_name})") else: call_arguments.append(arg.var_name) @@ -574,9 +574,9 @@ static To Convert(const From& from) { To to{}; if constexpr (sizeof(To) >= sizeof(From)) { - std::memcpy(&to, &from, sizeof(From)); + std::memcpy(std::addressof(to), std::addressof(from), sizeof(From)); } else { - std::memcpy(&to, &from, sizeof(To)); + std::memcpy(std::addressof(to), std::addressof(from), sizeof(To)); } return to; diff --git a/src/core/hle/service/acc/acc.cpp b/src/core/hle/service/acc/acc.cpp index c3e5c4462..6c29cb613 100644 --- a/src/core/hle/service/acc/acc.cpp +++ b/src/core/hle/service/acc/acc.cpp @@ -15,7 +15,6 @@ #include "core/core_timing.h" #include "core/file_sys/control_metadata.h" #include "core/file_sys/patch_manager.h" -#include "core/hle/ipc_helpers.h" #include "core/hle/service/acc/acc.h" #include "core/hle/service/acc/acc_aa.h" #include "core/hle/service/acc/acc_su.h" @@ -25,17 +24,12 @@ #include "core/hle/service/acc/errors.h" #include "core/hle/service/acc/profile_manager.h" #include "core/hle/service/glue/glue_manager.h" +#include "core/hle/service/ipc_helpers.h" #include "core/hle/service/server_manager.h" #include "core/loader/loader.h" namespace Service::Account { -constexpr Result ERR_INVALID_USER_ID{ErrorModule::Account, 20}; -constexpr Result ERR_INVALID_APPLICATION_ID{ErrorModule::Account, 22}; -constexpr Result ERR_INVALID_BUFFER{ErrorModule::Account, 30}; -constexpr Result ERR_INVALID_BUFFER_SIZE{ErrorModule::Account, 31}; -constexpr Result ERR_FAILED_SAVE_DATA{ErrorModule::Account, 100}; - // Thumbnails are hard coded to be at least this size constexpr std::size_t THUMBNAIL_SIZE = 0x24000; @@ -295,7 +289,7 @@ public: } protected: - void Get(Kernel::HLERequestContext& ctx) { + void Get(HLERequestContext& ctx) { LOG_DEBUG(Service_ACC, "called user_id=0x{}", user_id.RawString()); ProfileBase profile_base{}; UserData data{}; @@ -312,7 +306,7 @@ protected: } } - void GetBase(Kernel::HLERequestContext& ctx) { + void GetBase(HLERequestContext& ctx) { LOG_DEBUG(Service_ACC, "called user_id=0x{}", user_id.RawString()); ProfileBase profile_base{}; if (profile_manager.GetProfileBase(user_id, profile_base)) { @@ -326,7 +320,7 @@ protected: } } - void LoadImage(Kernel::HLERequestContext& ctx) { + void LoadImage(HLERequestContext& ctx) { LOG_DEBUG(Service_ACC, "called"); IPC::ResponseBuilder rb{ctx, 3}; @@ -353,7 +347,7 @@ protected: rb.Push<u32>(size); } - void GetImageSize(Kernel::HLERequestContext& ctx) { + void GetImageSize(HLERequestContext& ctx) { LOG_DEBUG(Service_ACC, "called"); IPC::ResponseBuilder rb{ctx, 3}; rb.Push(ResultSuccess); @@ -370,7 +364,7 @@ protected: } } - void Store(Kernel::HLERequestContext& ctx) { + void Store(HLERequestContext& ctx) { IPC::RequestParser rp{ctx}; const auto base = rp.PopRaw<ProfileBase>(); @@ -384,7 +378,7 @@ protected: if (user_data.size() < sizeof(UserData)) { LOG_ERROR(Service_ACC, "UserData buffer too small!"); IPC::ResponseBuilder rb{ctx, 2}; - rb.Push(ERR_INVALID_BUFFER); + rb.Push(Account::ResultInvalidArrayLength); return; } @@ -394,7 +388,7 @@ protected: if (!profile_manager.SetProfileBaseAndData(user_id, base, data)) { LOG_ERROR(Service_ACC, "Failed to update user data and base!"); IPC::ResponseBuilder rb{ctx, 2}; - rb.Push(ERR_FAILED_SAVE_DATA); + rb.Push(Account::ResultAccountUpdateFailed); return; } @@ -402,7 +396,7 @@ protected: rb.Push(ResultSuccess); } - void StoreWithImage(Kernel::HLERequestContext& ctx) { + void StoreWithImage(HLERequestContext& ctx) { IPC::RequestParser rp{ctx}; const auto base = rp.PopRaw<ProfileBase>(); @@ -417,7 +411,7 @@ protected: if (user_data.size() < sizeof(UserData)) { LOG_ERROR(Service_ACC, "UserData buffer too small!"); IPC::ResponseBuilder rb{ctx, 2}; - rb.Push(ERR_INVALID_BUFFER); + rb.Push(Account::ResultInvalidArrayLength); return; } @@ -432,7 +426,7 @@ protected: !profile_manager.SetProfileBaseAndData(user_id, base, data)) { LOG_ERROR(Service_ACC, "Failed to update profile data, base, and image!"); IPC::ResponseBuilder rb{ctx, 2}; - rb.Push(ERR_FAILED_SAVE_DATA); + rb.Push(Account::ResultAccountUpdateFailed); return; } @@ -499,7 +493,7 @@ public: } ~EnsureTokenIdCacheAsyncInterface() = default; - void LoadIdTokenCache(Kernel::HLERequestContext& ctx) { + void LoadIdTokenCache(HLERequestContext& ctx) { LOG_WARNING(Service_ACC, "(STUBBED) called"); IPC::ResponseBuilder rb{ctx, 2}; @@ -542,14 +536,14 @@ public: } private: - void CheckAvailability(Kernel::HLERequestContext& ctx) { + void CheckAvailability(HLERequestContext& ctx) { LOG_DEBUG(Service_ACC, "(STUBBED) called"); IPC::ResponseBuilder rb{ctx, 3}; rb.Push(ResultSuccess); rb.Push(false); // TODO: Check when this is supposed to return true and when not } - void GetAccountId(Kernel::HLERequestContext& ctx) { + void GetAccountId(HLERequestContext& ctx) { LOG_DEBUG(Service_ACC, "called"); IPC::ResponseBuilder rb{ctx, 4}; @@ -557,7 +551,7 @@ private: rb.PushRaw<u64>(profile_manager->GetLastOpenedUser().Hash()); } - void EnsureIdTokenCacheAsync(Kernel::HLERequestContext& ctx) { + void EnsureIdTokenCacheAsync(HLERequestContext& ctx) { LOG_WARNING(Service_ACC, "(STUBBED) called"); IPC::ResponseBuilder rb{ctx, 2, 0, 1}; @@ -565,13 +559,13 @@ private: rb.PushIpcInterface(ensure_token_id); } - void LoadIdTokenCache(Kernel::HLERequestContext& ctx) { + void LoadIdTokenCache(HLERequestContext& ctx) { LOG_WARNING(Service_ACC, "(STUBBED) called"); ensure_token_id->LoadIdTokenCache(ctx); } - void GetNintendoAccountUserResourceCacheForApplication(Kernel::HLERequestContext& ctx) { + void GetNintendoAccountUserResourceCacheForApplication(HLERequestContext& ctx) { LOG_WARNING(Service_ACC, "(STUBBED) called"); std::vector<u8> nas_user_base_for_application(0x68); @@ -587,7 +581,7 @@ private: rb.PushRaw<u64>(profile_manager->GetLastOpenedUser().Hash()); } - void StoreOpenContext(Kernel::HLERequestContext& ctx) { + void StoreOpenContext(HLERequestContext& ctx) { LOG_DEBUG(Service_ACC, "called"); profile_manager->StoreOpenedUsers(); @@ -689,14 +683,14 @@ public: } }; -void Module::Interface::GetUserCount(Kernel::HLERequestContext& ctx) { +void Module::Interface::GetUserCount(HLERequestContext& ctx) { LOG_DEBUG(Service_ACC, "called"); IPC::ResponseBuilder rb{ctx, 3}; rb.Push(ResultSuccess); rb.Push<u32>(static_cast<u32>(profile_manager->GetUserCount())); } -void Module::Interface::GetUserExistence(Kernel::HLERequestContext& ctx) { +void Module::Interface::GetUserExistence(HLERequestContext& ctx) { IPC::RequestParser rp{ctx}; Common::UUID user_id = rp.PopRaw<Common::UUID>(); LOG_DEBUG(Service_ACC, "called user_id=0x{}", user_id.RawString()); @@ -706,28 +700,28 @@ void Module::Interface::GetUserExistence(Kernel::HLERequestContext& ctx) { rb.Push(profile_manager->UserExists(user_id)); } -void Module::Interface::ListAllUsers(Kernel::HLERequestContext& ctx) { +void Module::Interface::ListAllUsers(HLERequestContext& ctx) { LOG_DEBUG(Service_ACC, "called"); ctx.WriteBuffer(profile_manager->GetAllUsers()); IPC::ResponseBuilder rb{ctx, 2}; rb.Push(ResultSuccess); } -void Module::Interface::ListOpenUsers(Kernel::HLERequestContext& ctx) { +void Module::Interface::ListOpenUsers(HLERequestContext& ctx) { LOG_DEBUG(Service_ACC, "called"); ctx.WriteBuffer(profile_manager->GetOpenUsers()); IPC::ResponseBuilder rb{ctx, 2}; rb.Push(ResultSuccess); } -void Module::Interface::GetLastOpenedUser(Kernel::HLERequestContext& ctx) { +void Module::Interface::GetLastOpenedUser(HLERequestContext& ctx) { LOG_DEBUG(Service_ACC, "called"); IPC::ResponseBuilder rb{ctx, 6}; rb.Push(ResultSuccess); rb.PushRaw<Common::UUID>(profile_manager->GetLastOpenedUser()); } -void Module::Interface::GetProfile(Kernel::HLERequestContext& ctx) { +void Module::Interface::GetProfile(HLERequestContext& ctx) { IPC::RequestParser rp{ctx}; Common::UUID user_id = rp.PopRaw<Common::UUID>(); LOG_DEBUG(Service_ACC, "called user_id=0x{}", user_id.RawString()); @@ -737,20 +731,20 @@ void Module::Interface::GetProfile(Kernel::HLERequestContext& ctx) { rb.PushIpcInterface<IProfile>(system, user_id, *profile_manager); } -void Module::Interface::IsUserRegistrationRequestPermitted(Kernel::HLERequestContext& ctx) { +void Module::Interface::IsUserRegistrationRequestPermitted(HLERequestContext& ctx) { LOG_WARNING(Service_ACC, "(STUBBED) called"); IPC::ResponseBuilder rb{ctx, 3}; rb.Push(ResultSuccess); rb.Push(profile_manager->CanSystemRegisterUser()); } -void Module::Interface::InitializeApplicationInfo(Kernel::HLERequestContext& ctx) { +void Module::Interface::InitializeApplicationInfo(HLERequestContext& ctx) { LOG_DEBUG(Service_ACC, "called"); IPC::ResponseBuilder rb{ctx, 2}; rb.Push(InitializeApplicationInfoBase()); } -void Module::Interface::InitializeApplicationInfoRestricted(Kernel::HLERequestContext& ctx) { +void Module::Interface::InitializeApplicationInfoRestricted(HLERequestContext& ctx) { LOG_WARNING(Service_ACC, "(Partial implementation) called"); // TODO(ogniK): We require checking if the user actually owns the title and what not. As of @@ -764,7 +758,7 @@ void Module::Interface::InitializeApplicationInfoRestricted(Kernel::HLERequestCo Result Module::Interface::InitializeApplicationInfoBase() { if (application_info) { LOG_ERROR(Service_ACC, "Application already initialized"); - return ERR_ACCOUNTINFO_ALREADY_INITIALIZED; + return Account::ResultApplicationInfoAlreadyInitialized; } // TODO(ogniK): This should be changed to reflect the target process for when we have multiple @@ -775,7 +769,7 @@ Result Module::Interface::InitializeApplicationInfoBase() { if (launch_property.Failed()) { LOG_ERROR(Service_ACC, "Failed to get launch property"); - return ERR_ACCOUNTINFO_BAD_APPLICATION; + return Account::ResultInvalidApplication; } switch (launch_property->base_game_storage_id) { @@ -791,23 +785,23 @@ Result Module::Interface::InitializeApplicationInfoBase() { default: LOG_ERROR(Service_ACC, "Invalid game storage ID! storage_id={}", launch_property->base_game_storage_id); - return ERR_ACCOUNTINFO_BAD_APPLICATION; + return Account::ResultInvalidApplication; } LOG_WARNING(Service_ACC, "ApplicationInfo init required"); - // TODO(ogniK): Actual initalization here + // TODO(ogniK): Actual initialization here return ResultSuccess; } -void Module::Interface::GetBaasAccountManagerForApplication(Kernel::HLERequestContext& ctx) { +void Module::Interface::GetBaasAccountManagerForApplication(HLERequestContext& ctx) { LOG_DEBUG(Service_ACC, "called"); IPC::ResponseBuilder rb{ctx, 2, 0, 1}; rb.Push(ResultSuccess); rb.PushIpcInterface<IManagerForApplication>(system, profile_manager); } -void Module::Interface::IsUserAccountSwitchLocked(Kernel::HLERequestContext& ctx) { +void Module::Interface::IsUserAccountSwitchLocked(HLERequestContext& ctx) { LOG_DEBUG(Service_ACC, "called"); FileSys::NACP nacp; const auto res = system.GetAppLoader().ReadControlData(nacp); @@ -834,14 +828,14 @@ void Module::Interface::IsUserAccountSwitchLocked(Kernel::HLERequestContext& ctx rb.Push(is_locked); } -void Module::Interface::InitializeApplicationInfoV2(Kernel::HLERequestContext& ctx) { +void Module::Interface::InitializeApplicationInfoV2(HLERequestContext& ctx) { LOG_WARNING(Service_ACC, "(STUBBED) called"); IPC::ResponseBuilder rb{ctx, 2}; rb.Push(ResultSuccess); } -void Module::Interface::GetProfileEditor(Kernel::HLERequestContext& ctx) { +void Module::Interface::GetProfileEditor(HLERequestContext& ctx) { IPC::RequestParser rp{ctx}; Common::UUID user_id = rp.PopRaw<Common::UUID>(); @@ -852,7 +846,7 @@ void Module::Interface::GetProfileEditor(Kernel::HLERequestContext& ctx) { rb.PushIpcInterface<IProfileEditor>(system, user_id, *profile_manager); } -void Module::Interface::ListQualifiedUsers(Kernel::HLERequestContext& ctx) { +void Module::Interface::ListQualifiedUsers(HLERequestContext& ctx) { LOG_DEBUG(Service_ACC, "called"); // All users should be qualified. We don't actually have parental control or anything to do with @@ -863,7 +857,7 @@ void Module::Interface::ListQualifiedUsers(Kernel::HLERequestContext& ctx) { rb.Push(ResultSuccess); } -void Module::Interface::ListOpenContextStoredUsers(Kernel::HLERequestContext& ctx) { +void Module::Interface::ListOpenContextStoredUsers(HLERequestContext& ctx) { LOG_DEBUG(Service_ACC, "called"); ctx.WriteBuffer(profile_manager->GetStoredOpenedUsers()); @@ -871,7 +865,7 @@ void Module::Interface::ListOpenContextStoredUsers(Kernel::HLERequestContext& ct rb.Push(ResultSuccess); } -void Module::Interface::StoreSaveDataThumbnailApplication(Kernel::HLERequestContext& ctx) { +void Module::Interface::StoreSaveDataThumbnailApplication(HLERequestContext& ctx) { IPC::RequestParser rp{ctx}; const auto uuid = rp.PopRaw<Common::UUID>(); @@ -884,7 +878,7 @@ void Module::Interface::StoreSaveDataThumbnailApplication(Kernel::HLERequestCont StoreSaveDataThumbnail(ctx, uuid, tid); } -void Module::Interface::StoreSaveDataThumbnailSystem(Kernel::HLERequestContext& ctx) { +void Module::Interface::StoreSaveDataThumbnailSystem(HLERequestContext& ctx) { IPC::RequestParser rp{ctx}; const auto uuid = rp.PopRaw<Common::UUID>(); const auto tid = rp.Pop<u64_le>(); @@ -893,26 +887,26 @@ void Module::Interface::StoreSaveDataThumbnailSystem(Kernel::HLERequestContext& StoreSaveDataThumbnail(ctx, uuid, tid); } -void Module::Interface::StoreSaveDataThumbnail(Kernel::HLERequestContext& ctx, - const Common::UUID& uuid, const u64 tid) { +void Module::Interface::StoreSaveDataThumbnail(HLERequestContext& ctx, const Common::UUID& uuid, + const u64 tid) { IPC::ResponseBuilder rb{ctx, 2}; if (tid == 0) { LOG_ERROR(Service_ACC, "TitleID is not valid!"); - rb.Push(ERR_INVALID_APPLICATION_ID); + rb.Push(Account::ResultInvalidApplication); return; } if (uuid.IsInvalid()) { LOG_ERROR(Service_ACC, "User ID is not valid!"); - rb.Push(ERR_INVALID_USER_ID); + rb.Push(Account::ResultInvalidUserId); return; } const auto thumbnail_size = ctx.GetReadBufferSize(); if (thumbnail_size != THUMBNAIL_SIZE) { LOG_ERROR(Service_ACC, "Buffer size is empty! size={:X} expecting {:X}", thumbnail_size, THUMBNAIL_SIZE); - rb.Push(ERR_INVALID_BUFFER_SIZE); + rb.Push(Account::ResultInvalidArrayLength); return; } @@ -920,7 +914,7 @@ void Module::Interface::StoreSaveDataThumbnail(Kernel::HLERequestContext& ctx, rb.Push(ResultSuccess); } -void Module::Interface::TrySelectUserWithoutInteraction(Kernel::HLERequestContext& ctx) { +void Module::Interface::TrySelectUserWithoutInteraction(HLERequestContext& ctx) { LOG_DEBUG(Service_ACC, "called"); // A u8 is passed into this function which we can safely ignore. It's to determine if we have // access to use the network or not by the looks of it diff --git a/src/core/hle/service/acc/acc.h b/src/core/hle/service/acc/acc.h index a2fdafd82..6b4735c2f 100644 --- a/src/core/hle/service/acc/acc.h +++ b/src/core/hle/service/acc/acc.h @@ -20,28 +20,28 @@ public: const char* name); ~Interface() override; - void GetUserCount(Kernel::HLERequestContext& ctx); - void GetUserExistence(Kernel::HLERequestContext& ctx); - void ListAllUsers(Kernel::HLERequestContext& ctx); - void ListOpenUsers(Kernel::HLERequestContext& ctx); - void GetLastOpenedUser(Kernel::HLERequestContext& ctx); - void GetProfile(Kernel::HLERequestContext& ctx); - void InitializeApplicationInfo(Kernel::HLERequestContext& ctx); - void InitializeApplicationInfoRestricted(Kernel::HLERequestContext& ctx); - void GetBaasAccountManagerForApplication(Kernel::HLERequestContext& ctx); - void IsUserRegistrationRequestPermitted(Kernel::HLERequestContext& ctx); - void TrySelectUserWithoutInteraction(Kernel::HLERequestContext& ctx); - void IsUserAccountSwitchLocked(Kernel::HLERequestContext& ctx); - void InitializeApplicationInfoV2(Kernel::HLERequestContext& ctx); - void GetProfileEditor(Kernel::HLERequestContext& ctx); - void ListQualifiedUsers(Kernel::HLERequestContext& ctx); - void ListOpenContextStoredUsers(Kernel::HLERequestContext& ctx); - void StoreSaveDataThumbnailApplication(Kernel::HLERequestContext& ctx); - void StoreSaveDataThumbnailSystem(Kernel::HLERequestContext& ctx); + void GetUserCount(HLERequestContext& ctx); + void GetUserExistence(HLERequestContext& ctx); + void ListAllUsers(HLERequestContext& ctx); + void ListOpenUsers(HLERequestContext& ctx); + void GetLastOpenedUser(HLERequestContext& ctx); + void GetProfile(HLERequestContext& ctx); + void InitializeApplicationInfo(HLERequestContext& ctx); + void InitializeApplicationInfoRestricted(HLERequestContext& ctx); + void GetBaasAccountManagerForApplication(HLERequestContext& ctx); + void IsUserRegistrationRequestPermitted(HLERequestContext& ctx); + void TrySelectUserWithoutInteraction(HLERequestContext& ctx); + void IsUserAccountSwitchLocked(HLERequestContext& ctx); + void InitializeApplicationInfoV2(HLERequestContext& ctx); + void GetProfileEditor(HLERequestContext& ctx); + void ListQualifiedUsers(HLERequestContext& ctx); + void ListOpenContextStoredUsers(HLERequestContext& ctx); + void StoreSaveDataThumbnailApplication(HLERequestContext& ctx); + void StoreSaveDataThumbnailSystem(HLERequestContext& ctx); private: Result InitializeApplicationInfoBase(); - void StoreSaveDataThumbnail(Kernel::HLERequestContext& ctx, const Common::UUID& uuid, + void StoreSaveDataThumbnail(HLERequestContext& ctx, const Common::UUID& uuid, const u64 tid); enum class ApplicationType : u32_le { diff --git a/src/core/hle/service/acc/async_context.cpp b/src/core/hle/service/acc/async_context.cpp index 713689d8f..c9e0af90c 100644 --- a/src/core/hle/service/acc/async_context.cpp +++ b/src/core/hle/service/acc/async_context.cpp @@ -2,9 +2,9 @@ // SPDX-License-Identifier: GPL-2.0-or-later #include "core/core.h" -#include "core/hle/ipc_helpers.h" #include "core/hle/kernel/k_event.h" #include "core/hle/service/acc/async_context.h" +#include "core/hle/service/ipc_helpers.h" namespace Service::Account { IAsyncContext::IAsyncContext(Core::System& system_) @@ -27,7 +27,7 @@ IAsyncContext::~IAsyncContext() { service_context.CloseEvent(completion_event); } -void IAsyncContext::GetSystemEvent(Kernel::HLERequestContext& ctx) { +void IAsyncContext::GetSystemEvent(HLERequestContext& ctx) { LOG_DEBUG(Service_ACC, "called"); IPC::ResponseBuilder rb{ctx, 2, 1}; @@ -35,7 +35,7 @@ void IAsyncContext::GetSystemEvent(Kernel::HLERequestContext& ctx) { rb.PushCopyObjects(completion_event->GetReadableEvent()); } -void IAsyncContext::Cancel(Kernel::HLERequestContext& ctx) { +void IAsyncContext::Cancel(HLERequestContext& ctx) { LOG_DEBUG(Service_ACC, "called"); Cancel(); @@ -45,7 +45,7 @@ void IAsyncContext::Cancel(Kernel::HLERequestContext& ctx) { rb.Push(ResultSuccess); } -void IAsyncContext::HasDone(Kernel::HLERequestContext& ctx) { +void IAsyncContext::HasDone(HLERequestContext& ctx) { LOG_DEBUG(Service_ACC, "called"); is_complete.store(IsComplete()); @@ -55,7 +55,7 @@ void IAsyncContext::HasDone(Kernel::HLERequestContext& ctx) { rb.Push(is_complete.load()); } -void IAsyncContext::GetResult(Kernel::HLERequestContext& ctx) { +void IAsyncContext::GetResult(HLERequestContext& ctx) { LOG_DEBUG(Service_ACC, "called"); IPC::ResponseBuilder rb{ctx, 3}; diff --git a/src/core/hle/service/acc/async_context.h b/src/core/hle/service/acc/async_context.h index 26332d241..d7bffc055 100644 --- a/src/core/hle/service/acc/async_context.h +++ b/src/core/hle/service/acc/async_context.h @@ -18,10 +18,10 @@ public: explicit IAsyncContext(Core::System& system_); ~IAsyncContext() override; - void GetSystemEvent(Kernel::HLERequestContext& ctx); - void Cancel(Kernel::HLERequestContext& ctx); - void HasDone(Kernel::HLERequestContext& ctx); - void GetResult(Kernel::HLERequestContext& ctx); + void GetSystemEvent(HLERequestContext& ctx); + void Cancel(HLERequestContext& ctx); + void HasDone(HLERequestContext& ctx); + void GetResult(HLERequestContext& ctx); protected: virtual bool IsComplete() const = 0; diff --git a/src/core/hle/service/acc/errors.h b/src/core/hle/service/acc/errors.h index e9c16b951..433ebfe9d 100644 --- a/src/core/hle/service/acc/errors.h +++ b/src/core/hle/service/acc/errors.h @@ -7,7 +7,13 @@ namespace Service::Account { -constexpr Result ERR_ACCOUNTINFO_BAD_APPLICATION{ErrorModule::Account, 22}; -constexpr Result ERR_ACCOUNTINFO_ALREADY_INITIALIZED{ErrorModule::Account, 41}; +constexpr Result ResultCancelledByUser{ErrorModule::Account, 1}; +constexpr Result ResultNoNotifications{ErrorModule::Account, 15}; +constexpr Result ResultInvalidUserId{ErrorModule::Account, 20}; +constexpr Result ResultInvalidApplication{ErrorModule::Account, 22}; +constexpr Result ResultNullptr{ErrorModule::Account, 30}; +constexpr Result ResultInvalidArrayLength{ErrorModule::Account, 32}; +constexpr Result ResultApplicationInfoAlreadyInitialized{ErrorModule::Account, 41}; +constexpr Result ResultAccountUpdateFailed{ErrorModule::Account, 100}; } // namespace Service::Account diff --git a/src/core/hle/service/acc/profile_manager.cpp b/src/core/hle/service/acc/profile_manager.cpp index 97f7c6688..63fd5bfd6 100644 --- a/src/core/hle/service/acc/profile_manager.cpp +++ b/src/core/hle/service/acc/profile_manager.cpp @@ -287,7 +287,7 @@ void ProfileManager::StoreOpenedUsers() { }); } -/// Return the users profile base and the unknown arbitary data. +/// Return the users profile base and the unknown arbitrary data. bool ProfileManager::GetProfileBaseAndData(std::optional<std::size_t> index, ProfileBase& profile, UserData& data) const { if (GetProfileBase(index, profile)) { @@ -297,13 +297,13 @@ bool ProfileManager::GetProfileBaseAndData(std::optional<std::size_t> index, Pro return false; } -/// Return the users profile base and the unknown arbitary data. +/// Return the users profile base and the unknown arbitrary data. bool ProfileManager::GetProfileBaseAndData(UUID uuid, ProfileBase& profile, UserData& data) const { const auto idx = GetUserIndex(uuid); return GetProfileBaseAndData(idx, profile, data); } -/// Return the users profile base and the unknown arbitary data. +/// Return the users profile base and the unknown arbitrary data. bool ProfileManager::GetProfileBaseAndData(const ProfileInfo& user, ProfileBase& profile, UserData& data) const { return GetProfileBaseAndData(user.user_uuid, profile, data); diff --git a/src/core/hle/service/am/am.cpp b/src/core/hle/service/am/am.cpp index 3cd772b83..deeca925d 100644 --- a/src/core/hle/service/am/am.cpp +++ b/src/core/hle/service/am/am.cpp @@ -11,7 +11,6 @@ #include "core/file_sys/patch_manager.h" #include "core/file_sys/registered_cache.h" #include "core/file_sys/savedata_factory.h" -#include "core/hle/ipc_helpers.h" #include "core/hle/kernel/k_event.h" #include "core/hle/kernel/k_transfer_memory.h" #include "core/hle/service/acc/profile_manager.h" @@ -29,8 +28,9 @@ #include "core/hle/service/bcat/backend/backend.h" #include "core/hle/service/caps/caps.h" #include "core/hle/service/filesystem/filesystem.h" +#include "core/hle/service/ipc_helpers.h" #include "core/hle/service/ns/ns.h" -#include "core/hle/service/nvflinger/nvflinger.h" +#include "core/hle/service/nvnflinger/nvnflinger.h" #include "core/hle/service/pm/pm.h" #include "core/hle/service/server_manager.h" #include "core/hle/service/sm/sm.h" @@ -39,9 +39,9 @@ namespace Service::AM { -constexpr Result ERR_NO_DATA_IN_CHANNEL{ErrorModule::AM, 2}; -constexpr Result ERR_NO_MESSAGES{ErrorModule::AM, 3}; -constexpr Result ERR_SIZE_OUT_OF_BOUNDS{ErrorModule::AM, 503}; +constexpr Result ResultNoDataInChannel{ErrorModule::AM, 2}; +constexpr Result ResultNoMessages{ErrorModule::AM, 3}; +constexpr Result ResultInvalidOffset{ErrorModule::AM, 503}; enum class LaunchParameterKind : u32 { ApplicationSpecific = 1, @@ -78,8 +78,8 @@ IWindowController::IWindowController(Core::System& system_) IWindowController::~IWindowController() = default; -void IWindowController::GetAppletResourceUserId(Kernel::HLERequestContext& ctx) { - const u64 process_id = system.ApplicationProcess()->GetProcessID(); +void IWindowController::GetAppletResourceUserId(HLERequestContext& ctx) { + const u64 process_id = system.ApplicationProcess()->GetProcessId(); LOG_DEBUG(Service_AM, "called. Process ID=0x{:016X}", process_id); @@ -88,7 +88,7 @@ void IWindowController::GetAppletResourceUserId(Kernel::HLERequestContext& ctx) rb.Push<u64>(process_id); } -void IWindowController::AcquireForegroundRights(Kernel::HLERequestContext& ctx) { +void IWindowController::AcquireForegroundRights(HLERequestContext& ctx) { LOG_WARNING(Service_AM, "(STUBBED) called"); IPC::ResponseBuilder rb{ctx, 2}; rb.Push(ResultSuccess); @@ -111,7 +111,7 @@ IAudioController::IAudioController(Core::System& system_) IAudioController::~IAudioController() = default; -void IAudioController::SetExpectedMasterVolume(Kernel::HLERequestContext& ctx) { +void IAudioController::SetExpectedMasterVolume(HLERequestContext& ctx) { IPC::RequestParser rp{ctx}; const float main_applet_volume_tmp = rp.Pop<float>(); const float library_applet_volume_tmp = rp.Pop<float>(); @@ -128,21 +128,21 @@ void IAudioController::SetExpectedMasterVolume(Kernel::HLERequestContext& ctx) { rb.Push(ResultSuccess); } -void IAudioController::GetMainAppletExpectedMasterVolume(Kernel::HLERequestContext& ctx) { +void IAudioController::GetMainAppletExpectedMasterVolume(HLERequestContext& ctx) { LOG_DEBUG(Service_AM, "called. main_applet_volume={}", main_applet_volume); IPC::ResponseBuilder rb{ctx, 3}; rb.Push(ResultSuccess); rb.Push(main_applet_volume); } -void IAudioController::GetLibraryAppletExpectedMasterVolume(Kernel::HLERequestContext& ctx) { +void IAudioController::GetLibraryAppletExpectedMasterVolume(HLERequestContext& ctx) { LOG_DEBUG(Service_AM, "called. library_applet_volume={}", library_applet_volume); IPC::ResponseBuilder rb{ctx, 3}; rb.Push(ResultSuccess); rb.Push(library_applet_volume); } -void IAudioController::ChangeMainAppletMasterVolume(Kernel::HLERequestContext& ctx) { +void IAudioController::ChangeMainAppletMasterVolume(HLERequestContext& ctx) { struct Parameters { float volume; s64 fade_time_ns; @@ -162,7 +162,7 @@ void IAudioController::ChangeMainAppletMasterVolume(Kernel::HLERequestContext& c rb.Push(ResultSuccess); } -void IAudioController::SetTransparentAudioRate(Kernel::HLERequestContext& ctx) { +void IAudioController::SetTransparentAudioRate(HLERequestContext& ctx) { IPC::RequestParser rp{ctx}; const float transparent_volume_rate_tmp = rp.Pop<float>(); @@ -251,10 +251,9 @@ IDebugFunctions::IDebugFunctions(Core::System& system_) IDebugFunctions::~IDebugFunctions() = default; -ISelfController::ISelfController(Core::System& system_, NVFlinger::NVFlinger& nvflinger_) - : ServiceFramework{system_, "ISelfController"}, nvflinger{nvflinger_}, service_context{ - system, - "ISelfController"} { +ISelfController::ISelfController(Core::System& system_, Nvnflinger::Nvnflinger& nvnflinger_) + : ServiceFramework{system_, "ISelfController"}, nvnflinger{nvnflinger_}, + service_context{system, "ISelfController"} { // clang-format off static const FunctionInfo functions[] = { {0, &ISelfController::Exit, "Exit"}, @@ -328,7 +327,7 @@ ISelfController::~ISelfController() { service_context.CloseEvent(accumulated_suspended_tick_changed_event); } -void ISelfController::Exit(Kernel::HLERequestContext& ctx) { +void ISelfController::Exit(HLERequestContext& ctx) { LOG_DEBUG(Service_AM, "called"); IPC::ResponseBuilder rb{ctx, 2}; @@ -337,7 +336,7 @@ void ISelfController::Exit(Kernel::HLERequestContext& ctx) { system.Exit(); } -void ISelfController::LockExit(Kernel::HLERequestContext& ctx) { +void ISelfController::LockExit(HLERequestContext& ctx) { LOG_DEBUG(Service_AM, "called"); system.SetExitLock(true); @@ -346,7 +345,7 @@ void ISelfController::LockExit(Kernel::HLERequestContext& ctx) { rb.Push(ResultSuccess); } -void ISelfController::UnlockExit(Kernel::HLERequestContext& ctx) { +void ISelfController::UnlockExit(HLERequestContext& ctx) { LOG_DEBUG(Service_AM, "called"); system.SetExitLock(false); @@ -355,7 +354,7 @@ void ISelfController::UnlockExit(Kernel::HLERequestContext& ctx) { rb.Push(ResultSuccess); } -void ISelfController::EnterFatalSection(Kernel::HLERequestContext& ctx) { +void ISelfController::EnterFatalSection(HLERequestContext& ctx) { ++num_fatal_sections_entered; LOG_DEBUG(Service_AM, "called. Num fatal sections entered: {}", num_fatal_sections_entered); @@ -363,7 +362,7 @@ void ISelfController::EnterFatalSection(Kernel::HLERequestContext& ctx) { rb.Push(ResultSuccess); } -void ISelfController::LeaveFatalSection(Kernel::HLERequestContext& ctx) { +void ISelfController::LeaveFatalSection(HLERequestContext& ctx) { LOG_DEBUG(Service_AM, "called."); // Entry and exit of fatal sections must be balanced. @@ -379,7 +378,7 @@ void ISelfController::LeaveFatalSection(Kernel::HLERequestContext& ctx) { rb.Push(ResultSuccess); } -void ISelfController::GetLibraryAppletLaunchableEvent(Kernel::HLERequestContext& ctx) { +void ISelfController::GetLibraryAppletLaunchableEvent(HLERequestContext& ctx) { LOG_WARNING(Service_AM, "(STUBBED) called"); launchable_event->Signal(); @@ -389,7 +388,7 @@ void ISelfController::GetLibraryAppletLaunchableEvent(Kernel::HLERequestContext& rb.PushCopyObjects(launchable_event->GetReadableEvent()); } -void ISelfController::SetScreenShotPermission(Kernel::HLERequestContext& ctx) { +void ISelfController::SetScreenShotPermission(HLERequestContext& ctx) { IPC::RequestParser rp{ctx}; const auto permission = rp.PopEnum<ScreenshotPermission>(); LOG_DEBUG(Service_AM, "called, permission={}", permission); @@ -400,7 +399,7 @@ void ISelfController::SetScreenShotPermission(Kernel::HLERequestContext& ctx) { rb.Push(ResultSuccess); } -void ISelfController::SetOperationModeChangedNotification(Kernel::HLERequestContext& ctx) { +void ISelfController::SetOperationModeChangedNotification(HLERequestContext& ctx) { IPC::RequestParser rp{ctx}; bool flag = rp.Pop<bool>(); @@ -410,7 +409,7 @@ void ISelfController::SetOperationModeChangedNotification(Kernel::HLERequestCont rb.Push(ResultSuccess); } -void ISelfController::SetPerformanceModeChangedNotification(Kernel::HLERequestContext& ctx) { +void ISelfController::SetPerformanceModeChangedNotification(HLERequestContext& ctx) { IPC::RequestParser rp{ctx}; bool flag = rp.Pop<bool>(); @@ -420,7 +419,7 @@ void ISelfController::SetPerformanceModeChangedNotification(Kernel::HLERequestCo rb.Push(ResultSuccess); } -void ISelfController::SetFocusHandlingMode(Kernel::HLERequestContext& ctx) { +void ISelfController::SetFocusHandlingMode(HLERequestContext& ctx) { // Takes 3 input u8s with each field located immediately after the previous // u8, these are bool flags. No output. IPC::RequestParser rp{ctx}; @@ -439,14 +438,14 @@ void ISelfController::SetFocusHandlingMode(Kernel::HLERequestContext& ctx) { rb.Push(ResultSuccess); } -void ISelfController::SetRestartMessageEnabled(Kernel::HLERequestContext& ctx) { +void ISelfController::SetRestartMessageEnabled(HLERequestContext& ctx) { LOG_WARNING(Service_AM, "(STUBBED) called"); IPC::ResponseBuilder rb{ctx, 2}; rb.Push(ResultSuccess); } -void ISelfController::SetOutOfFocusSuspendingEnabled(Kernel::HLERequestContext& ctx) { +void ISelfController::SetOutOfFocusSuspendingEnabled(HLERequestContext& ctx) { // Takes 3 input u8s with each field located immediately after the previous // u8, these are bool flags. No output. IPC::RequestParser rp{ctx}; @@ -458,27 +457,27 @@ void ISelfController::SetOutOfFocusSuspendingEnabled(Kernel::HLERequestContext& rb.Push(ResultSuccess); } -void ISelfController::SetAlbumImageOrientation(Kernel::HLERequestContext& ctx) { +void ISelfController::SetAlbumImageOrientation(HLERequestContext& ctx) { LOG_WARNING(Service_AM, "(STUBBED) called"); IPC::ResponseBuilder rb{ctx, 2}; rb.Push(ResultSuccess); } -void ISelfController::CreateManagedDisplayLayer(Kernel::HLERequestContext& ctx) { +void ISelfController::CreateManagedDisplayLayer(HLERequestContext& ctx) { LOG_WARNING(Service_AM, "(STUBBED) called"); // TODO(Subv): Find out how AM determines the display to use, for now just // create the layer in the Default display. - const auto display_id = nvflinger.OpenDisplay("Default"); - const auto layer_id = nvflinger.CreateLayer(*display_id); + const auto display_id = nvnflinger.OpenDisplay("Default"); + const auto layer_id = nvnflinger.CreateLayer(*display_id); IPC::ResponseBuilder rb{ctx, 4}; rb.Push(ResultSuccess); rb.Push(*layer_id); } -void ISelfController::CreateManagedDisplaySeparableLayer(Kernel::HLERequestContext& ctx) { +void ISelfController::CreateManagedDisplaySeparableLayer(HLERequestContext& ctx) { LOG_WARNING(Service_AM, "(STUBBED) called"); // TODO(Subv): Find out how AM determines the display to use, for now just @@ -488,22 +487,22 @@ void ISelfController::CreateManagedDisplaySeparableLayer(Kernel::HLERequestConte // Outputting 1 layer id instead of the expected 2 has not been observed to cause any adverse // side effects. // TODO: Support multiple layers - const auto display_id = nvflinger.OpenDisplay("Default"); - const auto layer_id = nvflinger.CreateLayer(*display_id); + const auto display_id = nvnflinger.OpenDisplay("Default"); + const auto layer_id = nvnflinger.CreateLayer(*display_id); IPC::ResponseBuilder rb{ctx, 4}; rb.Push(ResultSuccess); rb.Push(*layer_id); } -void ISelfController::SetHandlesRequestToDisplay(Kernel::HLERequestContext& ctx) { +void ISelfController::SetHandlesRequestToDisplay(HLERequestContext& ctx) { LOG_WARNING(Service_AM, "(STUBBED) called"); IPC::ResponseBuilder rb{ctx, 2}; rb.Push(ResultSuccess); } -void ISelfController::SetIdleTimeDetectionExtension(Kernel::HLERequestContext& ctx) { +void ISelfController::SetIdleTimeDetectionExtension(HLERequestContext& ctx) { IPC::RequestParser rp{ctx}; idle_time_detection_extension = rp.Pop<u32>(); LOG_WARNING(Service_AM, "(STUBBED) called idle_time_detection_extension={}", @@ -513,7 +512,7 @@ void ISelfController::SetIdleTimeDetectionExtension(Kernel::HLERequestContext& c rb.Push(ResultSuccess); } -void ISelfController::GetIdleTimeDetectionExtension(Kernel::HLERequestContext& ctx) { +void ISelfController::GetIdleTimeDetectionExtension(HLERequestContext& ctx) { LOG_WARNING(Service_AM, "(STUBBED) called"); IPC::ResponseBuilder rb{ctx, 3}; @@ -521,14 +520,14 @@ void ISelfController::GetIdleTimeDetectionExtension(Kernel::HLERequestContext& c rb.Push<u32>(idle_time_detection_extension); } -void ISelfController::ReportUserIsActive(Kernel::HLERequestContext& ctx) { +void ISelfController::ReportUserIsActive(HLERequestContext& ctx) { LOG_WARNING(Service_AM, "(STUBBED) called"); IPC::ResponseBuilder rb{ctx, 2}; rb.Push(ResultSuccess); } -void ISelfController::SetAutoSleepDisabled(Kernel::HLERequestContext& ctx) { +void ISelfController::SetAutoSleepDisabled(HLERequestContext& ctx) { IPC::RequestParser rp{ctx}; is_auto_sleep_disabled = rp.Pop<bool>(); @@ -548,7 +547,7 @@ void ISelfController::SetAutoSleepDisabled(Kernel::HLERequestContext& ctx) { rb.Push(ResultSuccess); } -void ISelfController::IsAutoSleepDisabled(Kernel::HLERequestContext& ctx) { +void ISelfController::IsAutoSleepDisabled(HLERequestContext& ctx) { LOG_DEBUG(Service_AM, "called."); IPC::ResponseBuilder rb{ctx, 3}; @@ -556,7 +555,7 @@ void ISelfController::IsAutoSleepDisabled(Kernel::HLERequestContext& ctx) { rb.Push(is_auto_sleep_disabled); } -void ISelfController::GetAccumulatedSuspendedTickValue(Kernel::HLERequestContext& ctx) { +void ISelfController::GetAccumulatedSuspendedTickValue(HLERequestContext& ctx) { LOG_DEBUG(Service_AM, "called."); // This command returns the total number of system ticks since ISelfController creation @@ -567,7 +566,7 @@ void ISelfController::GetAccumulatedSuspendedTickValue(Kernel::HLERequestContext rb.Push<u64>(0); } -void ISelfController::GetAccumulatedSuspendedTickChangedEvent(Kernel::HLERequestContext& ctx) { +void ISelfController::GetAccumulatedSuspendedTickChangedEvent(HLERequestContext& ctx) { LOG_DEBUG(Service_AM, "called."); IPC::ResponseBuilder rb{ctx, 2, 1}; @@ -575,7 +574,7 @@ void ISelfController::GetAccumulatedSuspendedTickChangedEvent(Kernel::HLERequest rb.PushCopyObjects(accumulated_suspended_tick_changed_event->GetReadableEvent()); } -void ISelfController::SetAlbumImageTakenNotificationEnabled(Kernel::HLERequestContext& ctx) { +void ISelfController::SetAlbumImageTakenNotificationEnabled(HLERequestContext& ctx) { IPC::RequestParser rp{ctx}; // This service call sets an internal flag whether a notification is shown when an image is @@ -590,7 +589,7 @@ void ISelfController::SetAlbumImageTakenNotificationEnabled(Kernel::HLERequestCo rb.Push(ResultSuccess); } -void ISelfController::SaveCurrentScreenshot(Kernel::HLERequestContext& ctx) { +void ISelfController::SaveCurrentScreenshot(HLERequestContext& ctx) { IPC::RequestParser rp{ctx}; const auto album_report_option = rp.PopEnum<Capture::AlbumReportOption>(); @@ -601,7 +600,7 @@ void ISelfController::SaveCurrentScreenshot(Kernel::HLERequestContext& ctx) { rb.Push(ResultSuccess); } -void ISelfController::SetRecordVolumeMuted(Kernel::HLERequestContext& ctx) { +void ISelfController::SetRecordVolumeMuted(HLERequestContext& ctx) { IPC::RequestParser rp{ctx}; const auto is_record_volume_muted = rp.Pop<bool>(); @@ -735,7 +734,7 @@ ICommonStateGetter::ICommonStateGetter(Core::System& system_, ICommonStateGetter::~ICommonStateGetter() = default; -void ICommonStateGetter::GetBootMode(Kernel::HLERequestContext& ctx) { +void ICommonStateGetter::GetBootMode(HLERequestContext& ctx) { LOG_DEBUG(Service_AM, "called"); IPC::ResponseBuilder rb{ctx, 3}; @@ -743,7 +742,7 @@ void ICommonStateGetter::GetBootMode(Kernel::HLERequestContext& ctx) { rb.Push<u8>(static_cast<u8>(Service::PM::SystemBootMode::Normal)); // Normal boot mode } -void ICommonStateGetter::GetEventHandle(Kernel::HLERequestContext& ctx) { +void ICommonStateGetter::GetEventHandle(HLERequestContext& ctx) { LOG_DEBUG(Service_AM, "called"); IPC::ResponseBuilder rb{ctx, 2, 1}; @@ -751,7 +750,7 @@ void ICommonStateGetter::GetEventHandle(Kernel::HLERequestContext& ctx) { rb.PushCopyObjects(msg_queue->GetMessageReceiveEvent()); } -void ICommonStateGetter::ReceiveMessage(Kernel::HLERequestContext& ctx) { +void ICommonStateGetter::ReceiveMessage(HLERequestContext& ctx) { LOG_DEBUG(Service_AM, "called"); const auto message = msg_queue->PopMessage(); @@ -759,7 +758,7 @@ void ICommonStateGetter::ReceiveMessage(Kernel::HLERequestContext& ctx) { if (message == AppletMessageQueue::AppletMessage::None) { LOG_ERROR(Service_AM, "Message queue is empty"); - rb.Push(ERR_NO_MESSAGES); + rb.Push(AM::ResultNoMessages); rb.PushEnum<AppletMessageQueue::AppletMessage>(message); return; } @@ -768,7 +767,7 @@ void ICommonStateGetter::ReceiveMessage(Kernel::HLERequestContext& ctx) { rb.PushEnum<AppletMessageQueue::AppletMessage>(message); } -void ICommonStateGetter::GetCurrentFocusState(Kernel::HLERequestContext& ctx) { +void ICommonStateGetter::GetCurrentFocusState(HLERequestContext& ctx) { LOG_DEBUG(Service_AM, "(STUBBED) called"); IPC::ResponseBuilder rb{ctx, 3}; @@ -776,7 +775,7 @@ void ICommonStateGetter::GetCurrentFocusState(Kernel::HLERequestContext& ctx) { rb.Push(static_cast<u8>(FocusState::InFocus)); } -void ICommonStateGetter::IsVrModeEnabled(Kernel::HLERequestContext& ctx) { +void ICommonStateGetter::IsVrModeEnabled(HLERequestContext& ctx) { LOG_DEBUG(Service_AM, "called"); IPC::ResponseBuilder rb{ctx, 3}; @@ -784,7 +783,7 @@ void ICommonStateGetter::IsVrModeEnabled(Kernel::HLERequestContext& ctx) { rb.Push(vr_mode_state); } -void ICommonStateGetter::SetVrModeEnabled(Kernel::HLERequestContext& ctx) { +void ICommonStateGetter::SetVrModeEnabled(HLERequestContext& ctx) { IPC::RequestParser rp{ctx}; vr_mode_state = rp.Pop<bool>(); @@ -794,7 +793,7 @@ void ICommonStateGetter::SetVrModeEnabled(Kernel::HLERequestContext& ctx) { rb.Push(ResultSuccess); } -void ICommonStateGetter::SetLcdBacklighOffEnabled(Kernel::HLERequestContext& ctx) { +void ICommonStateGetter::SetLcdBacklighOffEnabled(HLERequestContext& ctx) { IPC::RequestParser rp{ctx}; const auto is_lcd_backlight_off_enabled = rp.Pop<bool>(); @@ -805,21 +804,21 @@ void ICommonStateGetter::SetLcdBacklighOffEnabled(Kernel::HLERequestContext& ctx rb.Push(ResultSuccess); } -void ICommonStateGetter::BeginVrModeEx(Kernel::HLERequestContext& ctx) { +void ICommonStateGetter::BeginVrModeEx(HLERequestContext& ctx) { LOG_WARNING(Service_AM, "(STUBBED) called"); IPC::ResponseBuilder rb{ctx, 2}; rb.Push(ResultSuccess); } -void ICommonStateGetter::EndVrModeEx(Kernel::HLERequestContext& ctx) { +void ICommonStateGetter::EndVrModeEx(HLERequestContext& ctx) { LOG_WARNING(Service_AM, "(STUBBED) called"); IPC::ResponseBuilder rb{ctx, 2}; rb.Push(ResultSuccess); } -void ICommonStateGetter::GetDefaultDisplayResolutionChangeEvent(Kernel::HLERequestContext& ctx) { +void ICommonStateGetter::GetDefaultDisplayResolutionChangeEvent(HLERequestContext& ctx) { LOG_DEBUG(Service_AM, "called"); IPC::ResponseBuilder rb{ctx, 2, 1}; @@ -827,7 +826,7 @@ void ICommonStateGetter::GetDefaultDisplayResolutionChangeEvent(Kernel::HLEReque rb.PushCopyObjects(msg_queue->GetOperationModeChangedEvent()); } -void ICommonStateGetter::GetDefaultDisplayResolution(Kernel::HLERequestContext& ctx) { +void ICommonStateGetter::GetDefaultDisplayResolution(HLERequestContext& ctx) { LOG_DEBUG(Service_AM, "called"); IPC::ResponseBuilder rb{ctx, 4}; @@ -842,7 +841,7 @@ void ICommonStateGetter::GetDefaultDisplayResolution(Kernel::HLERequestContext& } } -void ICommonStateGetter::SetCpuBoostMode(Kernel::HLERequestContext& ctx) { +void ICommonStateGetter::SetCpuBoostMode(HLERequestContext& ctx) { LOG_DEBUG(Service_AM, "called, forwarding to APM:SYS"); const auto& sm = system.ServiceManager(); @@ -852,7 +851,7 @@ void ICommonStateGetter::SetCpuBoostMode(Kernel::HLERequestContext& ctx) { apm_sys->SetCpuBoostMode(ctx); } -void ICommonStateGetter::PerformSystemButtonPressingIfInFocus(Kernel::HLERequestContext& ctx) { +void ICommonStateGetter::PerformSystemButtonPressingIfInFocus(HLERequestContext& ctx) { IPC::RequestParser rp{ctx}; const auto system_button{rp.PopEnum<SystemButtonType>()}; @@ -863,7 +862,7 @@ void ICommonStateGetter::PerformSystemButtonPressingIfInFocus(Kernel::HLERequest } void ICommonStateGetter::SetRequestExitToLibraryAppletAtExecuteNextProgramEnabled( - Kernel::HLERequestContext& ctx) { + HLERequestContext& ctx) { LOG_WARNING(Service_AM, "(STUBBED) called"); IPC::ResponseBuilder rb{ctx, 2}; @@ -911,7 +910,7 @@ void IStorage::Register() { IStorage::~IStorage() = default; -void IStorage::Open(Kernel::HLERequestContext& ctx) { +void IStorage::Open(HLERequestContext& ctx) { LOG_DEBUG(Service_AM, "called"); IPC::ResponseBuilder rb{ctx, 2, 0, 1}; @@ -920,7 +919,7 @@ void IStorage::Open(Kernel::HLERequestContext& ctx) { rb.PushIpcInterface<IStorageAccessor>(system, *this); } -void ICommonStateGetter::GetOperationMode(Kernel::HLERequestContext& ctx) { +void ICommonStateGetter::GetOperationMode(HLERequestContext& ctx) { const bool use_docked_mode{Settings::values.use_docked_mode.GetValue()}; LOG_DEBUG(Service_AM, "called, use_docked_mode={}", use_docked_mode); @@ -929,7 +928,7 @@ void ICommonStateGetter::GetOperationMode(Kernel::HLERequestContext& ctx) { rb.Push(static_cast<u8>(use_docked_mode ? OperationMode::Docked : OperationMode::Handheld)); } -void ICommonStateGetter::GetPerformanceMode(Kernel::HLERequestContext& ctx) { +void ICommonStateGetter::GetPerformanceMode(HLERequestContext& ctx) { LOG_DEBUG(Service_AM, "called"); IPC::ResponseBuilder rb{ctx, 3}; @@ -969,7 +968,7 @@ public: } private: - void GetAppletStateChangedEvent(Kernel::HLERequestContext& ctx) { + void GetAppletStateChangedEvent(HLERequestContext& ctx) { LOG_DEBUG(Service_AM, "called"); IPC::ResponseBuilder rb{ctx, 2, 1}; @@ -977,7 +976,7 @@ private: rb.PushCopyObjects(applet->GetBroker().GetStateChangedEvent()); } - void IsCompleted(Kernel::HLERequestContext& ctx) { + void IsCompleted(HLERequestContext& ctx) { LOG_DEBUG(Service_AM, "called"); IPC::ResponseBuilder rb{ctx, 3}; @@ -985,21 +984,21 @@ private: rb.Push<u32>(applet->TransactionComplete()); } - void GetResult(Kernel::HLERequestContext& ctx) { + void GetResult(HLERequestContext& ctx) { LOG_DEBUG(Service_AM, "called"); IPC::ResponseBuilder rb{ctx, 2}; rb.Push(applet->GetStatus()); } - void PresetLibraryAppletGpuTimeSliceZero(Kernel::HLERequestContext& ctx) { + void PresetLibraryAppletGpuTimeSliceZero(HLERequestContext& ctx) { LOG_WARNING(Service_AM, "(STUBBED) called"); IPC::ResponseBuilder rb{ctx, 2}; rb.Push(ResultSuccess); } - void Start(Kernel::HLERequestContext& ctx) { + void Start(HLERequestContext& ctx) { LOG_DEBUG(Service_AM, "called"); ASSERT(applet != nullptr); @@ -1011,7 +1010,7 @@ private: rb.Push(ResultSuccess); } - void PushInData(Kernel::HLERequestContext& ctx) { + void PushInData(HLERequestContext& ctx) { LOG_DEBUG(Service_AM, "called"); IPC::RequestParser rp{ctx}; @@ -1021,7 +1020,7 @@ private: rb.Push(ResultSuccess); } - void PopOutData(Kernel::HLERequestContext& ctx) { + void PopOutData(HLERequestContext& ctx) { LOG_DEBUG(Service_AM, "called"); auto storage = applet->GetBroker().PopNormalDataToGame(); @@ -1029,7 +1028,7 @@ private: LOG_DEBUG(Service_AM, "storage is a nullptr. There is no data in the current normal channel"); IPC::ResponseBuilder rb{ctx, 2}; - rb.Push(ERR_NO_DATA_IN_CHANNEL); + rb.Push(AM::ResultNoDataInChannel); return; } @@ -1038,7 +1037,7 @@ private: rb.PushIpcInterface<IStorage>(std::move(storage)); } - void PushInteractiveInData(Kernel::HLERequestContext& ctx) { + void PushInteractiveInData(HLERequestContext& ctx) { LOG_DEBUG(Service_AM, "called"); IPC::RequestParser rp{ctx}; @@ -1052,7 +1051,7 @@ private: rb.Push(ResultSuccess); } - void PopInteractiveOutData(Kernel::HLERequestContext& ctx) { + void PopInteractiveOutData(HLERequestContext& ctx) { LOG_DEBUG(Service_AM, "called"); auto storage = applet->GetBroker().PopInteractiveDataToGame(); @@ -1060,7 +1059,7 @@ private: LOG_DEBUG(Service_AM, "storage is a nullptr. There is no data in the current interactive channel"); IPC::ResponseBuilder rb{ctx, 2}; - rb.Push(ERR_NO_DATA_IN_CHANNEL); + rb.Push(AM::ResultNoDataInChannel); return; } @@ -1069,7 +1068,7 @@ private: rb.PushIpcInterface<IStorage>(std::move(storage)); } - void GetPopOutDataEvent(Kernel::HLERequestContext& ctx) { + void GetPopOutDataEvent(HLERequestContext& ctx) { LOG_DEBUG(Service_AM, "called"); IPC::ResponseBuilder rb{ctx, 2, 1}; @@ -1077,7 +1076,7 @@ private: rb.PushCopyObjects(applet->GetBroker().GetNormalDataEvent()); } - void GetPopInteractiveOutDataEvent(Kernel::HLERequestContext& ctx) { + void GetPopInteractiveOutDataEvent(HLERequestContext& ctx) { LOG_DEBUG(Service_AM, "called"); IPC::ResponseBuilder rb{ctx, 2, 1}; @@ -1085,7 +1084,7 @@ private: rb.PushCopyObjects(applet->GetBroker().GetInteractiveDataEvent()); } - void GetIndirectLayerConsumerHandle(Kernel::HLERequestContext& ctx) { + void GetIndirectLayerConsumerHandle(HLERequestContext& ctx) { LOG_WARNING(Service_AM, "(STUBBED) called"); // We require a non-zero handle to be valid. Using 0xdeadbeef allows us to trace if this is @@ -1115,7 +1114,7 @@ IStorageAccessor::IStorageAccessor(Core::System& system_, IStorage& backing_) IStorageAccessor::~IStorageAccessor() = default; -void IStorageAccessor::GetSize(Kernel::HLERequestContext& ctx) { +void IStorageAccessor::GetSize(HLERequestContext& ctx) { LOG_DEBUG(Service_AM, "called"); IPC::ResponseBuilder rb{ctx, 4}; @@ -1124,7 +1123,7 @@ void IStorageAccessor::GetSize(Kernel::HLERequestContext& ctx) { rb.Push(static_cast<u64>(backing.GetSize())); } -void IStorageAccessor::Write(Kernel::HLERequestContext& ctx) { +void IStorageAccessor::Write(HLERequestContext& ctx) { IPC::RequestParser rp{ctx}; const u64 offset{rp.Pop<u64>()}; @@ -1139,7 +1138,7 @@ void IStorageAccessor::Write(Kernel::HLERequestContext& ctx) { backing.GetSize(), size, offset); IPC::ResponseBuilder rb{ctx, 2}; - rb.Push(ERR_SIZE_OUT_OF_BOUNDS); + rb.Push(AM::ResultInvalidOffset); return; } @@ -1149,7 +1148,7 @@ void IStorageAccessor::Write(Kernel::HLERequestContext& ctx) { rb.Push(ResultSuccess); } -void IStorageAccessor::Read(Kernel::HLERequestContext& ctx) { +void IStorageAccessor::Read(HLERequestContext& ctx) { IPC::RequestParser rp{ctx}; const u64 offset{rp.Pop<u64>()}; @@ -1162,7 +1161,7 @@ void IStorageAccessor::Read(Kernel::HLERequestContext& ctx) { backing.GetSize(), size, offset); IPC::ResponseBuilder rb{ctx, 2}; - rb.Push(ERR_SIZE_OUT_OF_BOUNDS); + rb.Push(AM::ResultInvalidOffset); return; } @@ -1187,7 +1186,7 @@ ILibraryAppletCreator::ILibraryAppletCreator(Core::System& system_) ILibraryAppletCreator::~ILibraryAppletCreator() = default; -void ILibraryAppletCreator::CreateLibraryApplet(Kernel::HLERequestContext& ctx) { +void ILibraryAppletCreator::CreateLibraryApplet(HLERequestContext& ctx) { IPC::RequestParser rp{ctx}; const auto applet_id = rp.PopRaw<Applets::AppletId>(); @@ -1213,7 +1212,7 @@ void ILibraryAppletCreator::CreateLibraryApplet(Kernel::HLERequestContext& ctx) rb.PushIpcInterface<ILibraryAppletAccessor>(system, applet); } -void ILibraryAppletCreator::CreateStorage(Kernel::HLERequestContext& ctx) { +void ILibraryAppletCreator::CreateStorage(HLERequestContext& ctx) { IPC::RequestParser rp{ctx}; const s64 size{rp.Pop<s64>()}; @@ -1234,7 +1233,7 @@ void ILibraryAppletCreator::CreateStorage(Kernel::HLERequestContext& ctx) { rb.PushIpcInterface<IStorage>(system, std::move(buffer)); } -void ILibraryAppletCreator::CreateTransferMemoryStorage(Kernel::HLERequestContext& ctx) { +void ILibraryAppletCreator::CreateTransferMemoryStorage(HLERequestContext& ctx) { IPC::RequestParser rp{ctx}; struct Parameters { @@ -1273,7 +1272,7 @@ void ILibraryAppletCreator::CreateTransferMemoryStorage(Kernel::HLERequestContex rb.PushIpcInterface<IStorage>(system, std::move(memory)); } -void ILibraryAppletCreator::CreateHandleStorage(Kernel::HLERequestContext& ctx) { +void ILibraryAppletCreator::CreateHandleStorage(HLERequestContext& ctx) { IPC::RequestParser rp{ctx}; const s64 size{rp.Pop<s64>()}; @@ -1395,29 +1394,28 @@ IApplicationFunctions::~IApplicationFunctions() { service_context.CloseEvent(health_warning_disappeared_system_event); } -void IApplicationFunctions::EnableApplicationCrashReport(Kernel::HLERequestContext& ctx) { +void IApplicationFunctions::EnableApplicationCrashReport(HLERequestContext& ctx) { LOG_WARNING(Service_AM, "(STUBBED) called"); IPC::ResponseBuilder rb{ctx, 2}; rb.Push(ResultSuccess); } -void IApplicationFunctions::InitializeApplicationCopyrightFrameBuffer( - Kernel::HLERequestContext& ctx) { +void IApplicationFunctions::InitializeApplicationCopyrightFrameBuffer(HLERequestContext& ctx) { LOG_WARNING(Service_AM, "(STUBBED) called"); IPC::ResponseBuilder rb{ctx, 2}; rb.Push(ResultSuccess); } -void IApplicationFunctions::SetApplicationCopyrightImage(Kernel::HLERequestContext& ctx) { +void IApplicationFunctions::SetApplicationCopyrightImage(HLERequestContext& ctx) { LOG_WARNING(Service_AM, "(STUBBED) called"); IPC::ResponseBuilder rb{ctx, 2}; rb.Push(ResultSuccess); } -void IApplicationFunctions::SetApplicationCopyrightVisibility(Kernel::HLERequestContext& ctx) { +void IApplicationFunctions::SetApplicationCopyrightVisibility(HLERequestContext& ctx) { IPC::RequestParser rp{ctx}; const auto is_visible = rp.Pop<bool>(); @@ -1427,37 +1425,35 @@ void IApplicationFunctions::SetApplicationCopyrightVisibility(Kernel::HLERequest rb.Push(ResultSuccess); } -void IApplicationFunctions::BeginBlockingHomeButtonShortAndLongPressed( - Kernel::HLERequestContext& ctx) { +void IApplicationFunctions::BeginBlockingHomeButtonShortAndLongPressed(HLERequestContext& ctx) { LOG_WARNING(Service_AM, "(STUBBED) called"); IPC::ResponseBuilder rb{ctx, 2}; rb.Push(ResultSuccess); } -void IApplicationFunctions::EndBlockingHomeButtonShortAndLongPressed( - Kernel::HLERequestContext& ctx) { +void IApplicationFunctions::EndBlockingHomeButtonShortAndLongPressed(HLERequestContext& ctx) { LOG_WARNING(Service_AM, "(STUBBED) called"); IPC::ResponseBuilder rb{ctx, 2}; rb.Push(ResultSuccess); } -void IApplicationFunctions::BeginBlockingHomeButton(Kernel::HLERequestContext& ctx) { +void IApplicationFunctions::BeginBlockingHomeButton(HLERequestContext& ctx) { LOG_WARNING(Service_AM, "(STUBBED) called"); IPC::ResponseBuilder rb{ctx, 2}; rb.Push(ResultSuccess); } -void IApplicationFunctions::EndBlockingHomeButton(Kernel::HLERequestContext& ctx) { +void IApplicationFunctions::EndBlockingHomeButton(HLERequestContext& ctx) { LOG_WARNING(Service_AM, "(STUBBED) called"); IPC::ResponseBuilder rb{ctx, 2}; rb.Push(ResultSuccess); } -void IApplicationFunctions::PopLaunchParameter(Kernel::HLERequestContext& ctx) { +void IApplicationFunctions::PopLaunchParameter(HLERequestContext& ctx) { IPC::RequestParser rp{ctx}; const auto kind = rp.PopEnum<LaunchParameterKind>(); @@ -1506,18 +1502,17 @@ void IApplicationFunctions::PopLaunchParameter(Kernel::HLERequestContext& ctx) { LOG_ERROR(Service_AM, "Attempted to load launch parameter but none was found!"); IPC::ResponseBuilder rb{ctx, 2}; - rb.Push(ERR_NO_DATA_IN_CHANNEL); + rb.Push(AM::ResultNoDataInChannel); } -void IApplicationFunctions::CreateApplicationAndRequestToStartForQuest( - Kernel::HLERequestContext& ctx) { +void IApplicationFunctions::CreateApplicationAndRequestToStartForQuest(HLERequestContext& ctx) { LOG_WARNING(Service_AM, "(STUBBED) called"); IPC::ResponseBuilder rb{ctx, 2}; rb.Push(ResultSuccess); } -void IApplicationFunctions::EnsureSaveData(Kernel::HLERequestContext& ctx) { +void IApplicationFunctions::EnsureSaveData(HLERequestContext& ctx) { IPC::RequestParser rp{ctx}; u128 user_id = rp.PopRaw<u128>(); @@ -1535,7 +1530,7 @@ void IApplicationFunctions::EnsureSaveData(Kernel::HLERequestContext& ctx) { rb.Push<u64>(0); } -void IApplicationFunctions::SetTerminateResult(Kernel::HLERequestContext& ctx) { +void IApplicationFunctions::SetTerminateResult(HLERequestContext& ctx) { // Takes an input u32 Result, no output. // For example, in some cases official apps use this with error 0x2A2 then // uses svcBreak. @@ -1548,7 +1543,7 @@ void IApplicationFunctions::SetTerminateResult(Kernel::HLERequestContext& ctx) { rb.Push(ResultSuccess); } -void IApplicationFunctions::GetDisplayVersion(Kernel::HLERequestContext& ctx) { +void IApplicationFunctions::GetDisplayVersion(HLERequestContext& ctx) { LOG_DEBUG(Service_AM, "called"); std::array<u8, 0x10> version_string{}; @@ -1582,7 +1577,7 @@ void IApplicationFunctions::GetDisplayVersion(Kernel::HLERequestContext& ctx) { rb.PushRaw(version_string); } -void IApplicationFunctions::GetDesiredLanguage(Kernel::HLERequestContext& ctx) { +void IApplicationFunctions::GetDesiredLanguage(HLERequestContext& ctx) { // TODO(bunnei): This should be configurable LOG_DEBUG(Service_AM, "called"); @@ -1638,7 +1633,7 @@ void IApplicationFunctions::GetDesiredLanguage(Kernel::HLERequestContext& ctx) { rb.Push(*res_code); } -void IApplicationFunctions::IsGamePlayRecordingSupported(Kernel::HLERequestContext& ctx) { +void IApplicationFunctions::IsGamePlayRecordingSupported(HLERequestContext& ctx) { LOG_WARNING(Service_AM, "(STUBBED) called"); constexpr bool gameplay_recording_supported = false; @@ -1648,21 +1643,21 @@ void IApplicationFunctions::IsGamePlayRecordingSupported(Kernel::HLERequestConte rb.Push(gameplay_recording_supported); } -void IApplicationFunctions::InitializeGamePlayRecording(Kernel::HLERequestContext& ctx) { +void IApplicationFunctions::InitializeGamePlayRecording(HLERequestContext& ctx) { LOG_WARNING(Service_AM, "(STUBBED) called"); IPC::ResponseBuilder rb{ctx, 2}; rb.Push(ResultSuccess); } -void IApplicationFunctions::SetGamePlayRecordingState(Kernel::HLERequestContext& ctx) { +void IApplicationFunctions::SetGamePlayRecordingState(HLERequestContext& ctx) { LOG_WARNING(Service_AM, "(STUBBED) called"); IPC::ResponseBuilder rb{ctx, 2}; rb.Push(ResultSuccess); } -void IApplicationFunctions::NotifyRunning(Kernel::HLERequestContext& ctx) { +void IApplicationFunctions::NotifyRunning(HLERequestContext& ctx) { LOG_WARNING(Service_AM, "(STUBBED) called"); IPC::ResponseBuilder rb{ctx, 3}; @@ -1670,7 +1665,7 @@ void IApplicationFunctions::NotifyRunning(Kernel::HLERequestContext& ctx) { rb.Push<u8>(0); // Unknown, seems to be ignored by official processes } -void IApplicationFunctions::GetPseudoDeviceId(Kernel::HLERequestContext& ctx) { +void IApplicationFunctions::GetPseudoDeviceId(HLERequestContext& ctx) { LOG_WARNING(Service_AM, "(STUBBED) called"); IPC::ResponseBuilder rb{ctx, 6}; @@ -1681,7 +1676,7 @@ void IApplicationFunctions::GetPseudoDeviceId(Kernel::HLERequestContext& ctx) { rb.Push<u64>(0); } -void IApplicationFunctions::ExtendSaveData(Kernel::HLERequestContext& ctx) { +void IApplicationFunctions::ExtendSaveData(HLERequestContext& ctx) { struct Parameters { FileSys::SaveDataType type; u128 user_id; @@ -1710,7 +1705,7 @@ void IApplicationFunctions::ExtendSaveData(Kernel::HLERequestContext& ctx) { rb.Push<u64>(0); } -void IApplicationFunctions::GetSaveDataSize(Kernel::HLERequestContext& ctx) { +void IApplicationFunctions::GetSaveDataSize(HLERequestContext& ctx) { struct Parameters { FileSys::SaveDataType type; u128 user_id; @@ -1732,7 +1727,7 @@ void IApplicationFunctions::GetSaveDataSize(Kernel::HLERequestContext& ctx) { rb.Push(size.journal); } -void IApplicationFunctions::QueryApplicationPlayStatistics(Kernel::HLERequestContext& ctx) { +void IApplicationFunctions::QueryApplicationPlayStatistics(HLERequestContext& ctx) { LOG_WARNING(Service_AM, "(STUBBED) called"); IPC::ResponseBuilder rb{ctx, 3}; @@ -1740,7 +1735,7 @@ void IApplicationFunctions::QueryApplicationPlayStatistics(Kernel::HLERequestCon rb.Push<u32>(0); } -void IApplicationFunctions::QueryApplicationPlayStatisticsByUid(Kernel::HLERequestContext& ctx) { +void IApplicationFunctions::QueryApplicationPlayStatisticsByUid(HLERequestContext& ctx) { LOG_WARNING(Service_AM, "(STUBBED) called"); IPC::ResponseBuilder rb{ctx, 3}; @@ -1748,7 +1743,7 @@ void IApplicationFunctions::QueryApplicationPlayStatisticsByUid(Kernel::HLEReque rb.Push<u32>(0); } -void IApplicationFunctions::ExecuteProgram(Kernel::HLERequestContext& ctx) { +void IApplicationFunctions::ExecuteProgram(HLERequestContext& ctx) { LOG_WARNING(Service_AM, "(STUBBED) called"); IPC::RequestParser rp{ctx}; @@ -1762,21 +1757,21 @@ void IApplicationFunctions::ExecuteProgram(Kernel::HLERequestContext& ctx) { system.ExecuteProgram(program_index); } -void IApplicationFunctions::ClearUserChannel(Kernel::HLERequestContext& ctx) { +void IApplicationFunctions::ClearUserChannel(HLERequestContext& ctx) { LOG_WARNING(Service_AM, "(STUBBED) called"); IPC::ResponseBuilder rb{ctx, 2}; rb.Push(ResultSuccess); } -void IApplicationFunctions::UnpopToUserChannel(Kernel::HLERequestContext& ctx) { +void IApplicationFunctions::UnpopToUserChannel(HLERequestContext& ctx) { LOG_WARNING(Service_AM, "(STUBBED) called"); IPC::ResponseBuilder rb{ctx, 2}; rb.Push(ResultSuccess); } -void IApplicationFunctions::GetPreviousProgramIndex(Kernel::HLERequestContext& ctx) { +void IApplicationFunctions::GetPreviousProgramIndex(HLERequestContext& ctx) { LOG_WARNING(Service_AM, "(STUBBED) called"); IPC::ResponseBuilder rb{ctx, 3}; @@ -1784,7 +1779,7 @@ void IApplicationFunctions::GetPreviousProgramIndex(Kernel::HLERequestContext& c rb.Push<s32>(previous_program_index); } -void IApplicationFunctions::GetGpuErrorDetectedSystemEvent(Kernel::HLERequestContext& ctx) { +void IApplicationFunctions::GetGpuErrorDetectedSystemEvent(HLERequestContext& ctx) { LOG_WARNING(Service_AM, "(STUBBED) called"); IPC::ResponseBuilder rb{ctx, 2, 1}; @@ -1792,7 +1787,7 @@ void IApplicationFunctions::GetGpuErrorDetectedSystemEvent(Kernel::HLERequestCon rb.PushCopyObjects(gpu_error_detected_event->GetReadableEvent()); } -void IApplicationFunctions::GetFriendInvitationStorageChannelEvent(Kernel::HLERequestContext& ctx) { +void IApplicationFunctions::GetFriendInvitationStorageChannelEvent(HLERequestContext& ctx) { LOG_DEBUG(Service_AM, "called"); IPC::ResponseBuilder rb{ctx, 2, 1}; @@ -1800,15 +1795,14 @@ void IApplicationFunctions::GetFriendInvitationStorageChannelEvent(Kernel::HLERe rb.PushCopyObjects(friend_invitation_storage_channel_event->GetReadableEvent()); } -void IApplicationFunctions::TryPopFromFriendInvitationStorageChannel( - Kernel::HLERequestContext& ctx) { +void IApplicationFunctions::TryPopFromFriendInvitationStorageChannel(HLERequestContext& ctx) { LOG_WARNING(Service_AM, "(STUBBED) called"); IPC::ResponseBuilder rb{ctx, 2}; - rb.Push(ERR_NO_DATA_IN_CHANNEL); + rb.Push(AM::ResultNoDataInChannel); } -void IApplicationFunctions::GetNotificationStorageChannelEvent(Kernel::HLERequestContext& ctx) { +void IApplicationFunctions::GetNotificationStorageChannelEvent(HLERequestContext& ctx) { LOG_DEBUG(Service_AM, "called"); IPC::ResponseBuilder rb{ctx, 2, 1}; @@ -1816,7 +1810,7 @@ void IApplicationFunctions::GetNotificationStorageChannelEvent(Kernel::HLEReques rb.PushCopyObjects(notification_storage_channel_event->GetReadableEvent()); } -void IApplicationFunctions::GetHealthWarningDisappearedSystemEvent(Kernel::HLERequestContext& ctx) { +void IApplicationFunctions::GetHealthWarningDisappearedSystemEvent(HLERequestContext& ctx) { LOG_DEBUG(Service_AM, "called"); IPC::ResponseBuilder rb{ctx, 2, 1}; @@ -1824,14 +1818,14 @@ void IApplicationFunctions::GetHealthWarningDisappearedSystemEvent(Kernel::HLERe rb.PushCopyObjects(health_warning_disappeared_system_event->GetReadableEvent()); } -void IApplicationFunctions::PrepareForJit(Kernel::HLERequestContext& ctx) { +void IApplicationFunctions::PrepareForJit(HLERequestContext& ctx) { LOG_WARNING(Service_AM, "(STUBBED) called"); IPC::ResponseBuilder rb{ctx, 2}; rb.Push(ResultSuccess); } -void LoopProcess(NVFlinger::NVFlinger& nvflinger, Core::System& system) { +void LoopProcess(Nvnflinger::Nvnflinger& nvnflinger, Core::System& system) { auto message_queue = std::make_shared<AppletMessageQueue>(system); // Needed on game boot message_queue->PushMessage(AppletMessageQueue::AppletMessage::FocusStateChanged); @@ -1839,9 +1833,9 @@ void LoopProcess(NVFlinger::NVFlinger& nvflinger, Core::System& system) { auto server_manager = std::make_unique<ServerManager>(system); server_manager->RegisterNamedService( - "appletAE", std::make_shared<AppletAE>(nvflinger, message_queue, system)); + "appletAE", std::make_shared<AppletAE>(nvnflinger, message_queue, system)); server_manager->RegisterNamedService( - "appletOE", std::make_shared<AppletOE>(nvflinger, message_queue, system)); + "appletOE", std::make_shared<AppletOE>(nvnflinger, message_queue, system)); server_manager->RegisterNamedService("idle:sys", std::make_shared<IdleSys>(system)); server_manager->RegisterNamedService("omm", std::make_shared<OMM>(system)); server_manager->RegisterNamedService("spsm", std::make_shared<SPSM>(system)); @@ -1881,14 +1875,14 @@ IHomeMenuFunctions::~IHomeMenuFunctions() { service_context.CloseEvent(pop_from_general_channel_event); } -void IHomeMenuFunctions::RequestToGetForeground(Kernel::HLERequestContext& ctx) { +void IHomeMenuFunctions::RequestToGetForeground(HLERequestContext& ctx) { LOG_WARNING(Service_AM, "(STUBBED) called"); IPC::ResponseBuilder rb{ctx, 2}; rb.Push(ResultSuccess); } -void IHomeMenuFunctions::GetPopFromGeneralChannelEvent(Kernel::HLERequestContext& ctx) { +void IHomeMenuFunctions::GetPopFromGeneralChannelEvent(HLERequestContext& ctx) { LOG_WARNING(Service_AM, "(STUBBED) called"); IPC::ResponseBuilder rb{ctx, 2, 1}; diff --git a/src/core/hle/service/am/am.h b/src/core/hle/service/am/am.h index 79e2263d7..0dbc6485e 100644 --- a/src/core/hle/service/am/am.h +++ b/src/core/hle/service/am/am.h @@ -12,11 +12,12 @@ namespace Kernel { class KernelCore; +class KReadableEvent; class KTransferMemory; } // namespace Kernel -namespace Service::NVFlinger { -class NVFlinger; +namespace Service::Nvnflinger { +class Nvnflinger; } namespace Service::AM { @@ -109,8 +110,8 @@ public: ~IWindowController() override; private: - void GetAppletResourceUserId(Kernel::HLERequestContext& ctx); - void AcquireForegroundRights(Kernel::HLERequestContext& ctx); + void GetAppletResourceUserId(HLERequestContext& ctx); + void AcquireForegroundRights(HLERequestContext& ctx); }; class IAudioController final : public ServiceFramework<IAudioController> { @@ -119,11 +120,11 @@ public: ~IAudioController() override; private: - void SetExpectedMasterVolume(Kernel::HLERequestContext& ctx); - void GetMainAppletExpectedMasterVolume(Kernel::HLERequestContext& ctx); - void GetLibraryAppletExpectedMasterVolume(Kernel::HLERequestContext& ctx); - void ChangeMainAppletMasterVolume(Kernel::HLERequestContext& ctx); - void SetTransparentAudioRate(Kernel::HLERequestContext& ctx); + void SetExpectedMasterVolume(HLERequestContext& ctx); + void GetMainAppletExpectedMasterVolume(HLERequestContext& ctx); + void GetLibraryAppletExpectedMasterVolume(HLERequestContext& ctx); + void ChangeMainAppletMasterVolume(HLERequestContext& ctx); + void SetTransparentAudioRate(HLERequestContext& ctx); static constexpr float min_allowed_volume = 0.0f; static constexpr float max_allowed_volume = 1.0f; @@ -153,36 +154,36 @@ public: class ISelfController final : public ServiceFramework<ISelfController> { public: - explicit ISelfController(Core::System& system_, NVFlinger::NVFlinger& nvflinger_); + explicit ISelfController(Core::System& system_, Nvnflinger::Nvnflinger& nvnflinger_); ~ISelfController() override; private: - void Exit(Kernel::HLERequestContext& ctx); - void LockExit(Kernel::HLERequestContext& ctx); - void UnlockExit(Kernel::HLERequestContext& ctx); - void EnterFatalSection(Kernel::HLERequestContext& ctx); - void LeaveFatalSection(Kernel::HLERequestContext& ctx); - void GetLibraryAppletLaunchableEvent(Kernel::HLERequestContext& ctx); - void SetScreenShotPermission(Kernel::HLERequestContext& ctx); - void SetOperationModeChangedNotification(Kernel::HLERequestContext& ctx); - void SetPerformanceModeChangedNotification(Kernel::HLERequestContext& ctx); - void SetFocusHandlingMode(Kernel::HLERequestContext& ctx); - void SetRestartMessageEnabled(Kernel::HLERequestContext& ctx); - void SetOutOfFocusSuspendingEnabled(Kernel::HLERequestContext& ctx); - void SetAlbumImageOrientation(Kernel::HLERequestContext& ctx); - void CreateManagedDisplayLayer(Kernel::HLERequestContext& ctx); - void CreateManagedDisplaySeparableLayer(Kernel::HLERequestContext& ctx); - void SetHandlesRequestToDisplay(Kernel::HLERequestContext& ctx); - void SetIdleTimeDetectionExtension(Kernel::HLERequestContext& ctx); - void GetIdleTimeDetectionExtension(Kernel::HLERequestContext& ctx); - void ReportUserIsActive(Kernel::HLERequestContext& ctx); - void SetAutoSleepDisabled(Kernel::HLERequestContext& ctx); - void IsAutoSleepDisabled(Kernel::HLERequestContext& ctx); - void GetAccumulatedSuspendedTickValue(Kernel::HLERequestContext& ctx); - void GetAccumulatedSuspendedTickChangedEvent(Kernel::HLERequestContext& ctx); - void SetAlbumImageTakenNotificationEnabled(Kernel::HLERequestContext& ctx); - void SaveCurrentScreenshot(Kernel::HLERequestContext& ctx); - void SetRecordVolumeMuted(Kernel::HLERequestContext& ctx); + void Exit(HLERequestContext& ctx); + void LockExit(HLERequestContext& ctx); + void UnlockExit(HLERequestContext& ctx); + void EnterFatalSection(HLERequestContext& ctx); + void LeaveFatalSection(HLERequestContext& ctx); + void GetLibraryAppletLaunchableEvent(HLERequestContext& ctx); + void SetScreenShotPermission(HLERequestContext& ctx); + void SetOperationModeChangedNotification(HLERequestContext& ctx); + void SetPerformanceModeChangedNotification(HLERequestContext& ctx); + void SetFocusHandlingMode(HLERequestContext& ctx); + void SetRestartMessageEnabled(HLERequestContext& ctx); + void SetOutOfFocusSuspendingEnabled(HLERequestContext& ctx); + void SetAlbumImageOrientation(HLERequestContext& ctx); + void CreateManagedDisplayLayer(HLERequestContext& ctx); + void CreateManagedDisplaySeparableLayer(HLERequestContext& ctx); + void SetHandlesRequestToDisplay(HLERequestContext& ctx); + void SetIdleTimeDetectionExtension(HLERequestContext& ctx); + void GetIdleTimeDetectionExtension(HLERequestContext& ctx); + void ReportUserIsActive(HLERequestContext& ctx); + void SetAutoSleepDisabled(HLERequestContext& ctx); + void IsAutoSleepDisabled(HLERequestContext& ctx); + void GetAccumulatedSuspendedTickValue(HLERequestContext& ctx); + void GetAccumulatedSuspendedTickChangedEvent(HLERequestContext& ctx); + void SetAlbumImageTakenNotificationEnabled(HLERequestContext& ctx); + void SaveCurrentScreenshot(HLERequestContext& ctx); + void SetRecordVolumeMuted(HLERequestContext& ctx); enum class ScreenshotPermission : u32 { Inherit = 0, @@ -190,7 +191,7 @@ private: Disable = 2, }; - NVFlinger::NVFlinger& nvflinger; + Nvnflinger::Nvnflinger& nvnflinger; KernelHelpers::ServiceContext service_context; @@ -235,22 +236,22 @@ private: CaptureButtonLongPressing, }; - void GetEventHandle(Kernel::HLERequestContext& ctx); - void ReceiveMessage(Kernel::HLERequestContext& ctx); - void GetCurrentFocusState(Kernel::HLERequestContext& ctx); - void GetDefaultDisplayResolutionChangeEvent(Kernel::HLERequestContext& ctx); - void GetOperationMode(Kernel::HLERequestContext& ctx); - void GetPerformanceMode(Kernel::HLERequestContext& ctx); - void GetBootMode(Kernel::HLERequestContext& ctx); - void IsVrModeEnabled(Kernel::HLERequestContext& ctx); - void SetVrModeEnabled(Kernel::HLERequestContext& ctx); - void SetLcdBacklighOffEnabled(Kernel::HLERequestContext& ctx); - void BeginVrModeEx(Kernel::HLERequestContext& ctx); - void EndVrModeEx(Kernel::HLERequestContext& ctx); - void GetDefaultDisplayResolution(Kernel::HLERequestContext& ctx); - void SetCpuBoostMode(Kernel::HLERequestContext& ctx); - void PerformSystemButtonPressingIfInFocus(Kernel::HLERequestContext& ctx); - void SetRequestExitToLibraryAppletAtExecuteNextProgramEnabled(Kernel::HLERequestContext& ctx); + void GetEventHandle(HLERequestContext& ctx); + void ReceiveMessage(HLERequestContext& ctx); + void GetCurrentFocusState(HLERequestContext& ctx); + void GetDefaultDisplayResolutionChangeEvent(HLERequestContext& ctx); + void GetOperationMode(HLERequestContext& ctx); + void GetPerformanceMode(HLERequestContext& ctx); + void GetBootMode(HLERequestContext& ctx); + void IsVrModeEnabled(HLERequestContext& ctx); + void SetVrModeEnabled(HLERequestContext& ctx); + void SetLcdBacklighOffEnabled(HLERequestContext& ctx); + void BeginVrModeEx(HLERequestContext& ctx); + void EndVrModeEx(HLERequestContext& ctx); + void GetDefaultDisplayResolution(HLERequestContext& ctx); + void SetCpuBoostMode(HLERequestContext& ctx); + void PerformSystemButtonPressingIfInFocus(HLERequestContext& ctx); + void SetRequestExitToLibraryAppletAtExecuteNextProgramEnabled(HLERequestContext& ctx); std::shared_ptr<AppletMessageQueue> msg_queue; bool vr_mode_state{}; @@ -283,7 +284,7 @@ public: private: void Register(); - void Open(Kernel::HLERequestContext& ctx); + void Open(HLERequestContext& ctx); std::shared_ptr<IStorageImpl> impl; }; @@ -294,9 +295,9 @@ public: ~IStorageAccessor() override; private: - void GetSize(Kernel::HLERequestContext& ctx); - void Write(Kernel::HLERequestContext& ctx); - void Read(Kernel::HLERequestContext& ctx); + void GetSize(HLERequestContext& ctx); + void Write(HLERequestContext& ctx); + void Read(HLERequestContext& ctx); IStorage& backing; }; @@ -307,10 +308,10 @@ public: ~ILibraryAppletCreator() override; private: - void CreateLibraryApplet(Kernel::HLERequestContext& ctx); - void CreateStorage(Kernel::HLERequestContext& ctx); - void CreateTransferMemoryStorage(Kernel::HLERequestContext& ctx); - void CreateHandleStorage(Kernel::HLERequestContext& ctx); + void CreateLibraryApplet(HLERequestContext& ctx); + void CreateStorage(HLERequestContext& ctx); + void CreateTransferMemoryStorage(HLERequestContext& ctx); + void CreateHandleStorage(HLERequestContext& ctx); }; class IApplicationFunctions final : public ServiceFramework<IApplicationFunctions> { @@ -319,39 +320,39 @@ public: ~IApplicationFunctions() override; private: - void PopLaunchParameter(Kernel::HLERequestContext& ctx); - void CreateApplicationAndRequestToStartForQuest(Kernel::HLERequestContext& ctx); - void EnsureSaveData(Kernel::HLERequestContext& ctx); - void SetTerminateResult(Kernel::HLERequestContext& ctx); - void GetDisplayVersion(Kernel::HLERequestContext& ctx); - void GetDesiredLanguage(Kernel::HLERequestContext& ctx); - void IsGamePlayRecordingSupported(Kernel::HLERequestContext& ctx); - void InitializeGamePlayRecording(Kernel::HLERequestContext& ctx); - void SetGamePlayRecordingState(Kernel::HLERequestContext& ctx); - void NotifyRunning(Kernel::HLERequestContext& ctx); - void GetPseudoDeviceId(Kernel::HLERequestContext& ctx); - void ExtendSaveData(Kernel::HLERequestContext& ctx); - void GetSaveDataSize(Kernel::HLERequestContext& ctx); - void BeginBlockingHomeButtonShortAndLongPressed(Kernel::HLERequestContext& ctx); - void EndBlockingHomeButtonShortAndLongPressed(Kernel::HLERequestContext& ctx); - void BeginBlockingHomeButton(Kernel::HLERequestContext& ctx); - void EndBlockingHomeButton(Kernel::HLERequestContext& ctx); - void EnableApplicationCrashReport(Kernel::HLERequestContext& ctx); - void InitializeApplicationCopyrightFrameBuffer(Kernel::HLERequestContext& ctx); - void SetApplicationCopyrightImage(Kernel::HLERequestContext& ctx); - void SetApplicationCopyrightVisibility(Kernel::HLERequestContext& ctx); - void QueryApplicationPlayStatistics(Kernel::HLERequestContext& ctx); - void QueryApplicationPlayStatisticsByUid(Kernel::HLERequestContext& ctx); - void ExecuteProgram(Kernel::HLERequestContext& ctx); - void ClearUserChannel(Kernel::HLERequestContext& ctx); - void UnpopToUserChannel(Kernel::HLERequestContext& ctx); - void GetPreviousProgramIndex(Kernel::HLERequestContext& ctx); - void GetGpuErrorDetectedSystemEvent(Kernel::HLERequestContext& ctx); - void GetFriendInvitationStorageChannelEvent(Kernel::HLERequestContext& ctx); - void TryPopFromFriendInvitationStorageChannel(Kernel::HLERequestContext& ctx); - void GetNotificationStorageChannelEvent(Kernel::HLERequestContext& ctx); - void GetHealthWarningDisappearedSystemEvent(Kernel::HLERequestContext& ctx); - void PrepareForJit(Kernel::HLERequestContext& ctx); + void PopLaunchParameter(HLERequestContext& ctx); + void CreateApplicationAndRequestToStartForQuest(HLERequestContext& ctx); + void EnsureSaveData(HLERequestContext& ctx); + void SetTerminateResult(HLERequestContext& ctx); + void GetDisplayVersion(HLERequestContext& ctx); + void GetDesiredLanguage(HLERequestContext& ctx); + void IsGamePlayRecordingSupported(HLERequestContext& ctx); + void InitializeGamePlayRecording(HLERequestContext& ctx); + void SetGamePlayRecordingState(HLERequestContext& ctx); + void NotifyRunning(HLERequestContext& ctx); + void GetPseudoDeviceId(HLERequestContext& ctx); + void ExtendSaveData(HLERequestContext& ctx); + void GetSaveDataSize(HLERequestContext& ctx); + void BeginBlockingHomeButtonShortAndLongPressed(HLERequestContext& ctx); + void EndBlockingHomeButtonShortAndLongPressed(HLERequestContext& ctx); + void BeginBlockingHomeButton(HLERequestContext& ctx); + void EndBlockingHomeButton(HLERequestContext& ctx); + void EnableApplicationCrashReport(HLERequestContext& ctx); + void InitializeApplicationCopyrightFrameBuffer(HLERequestContext& ctx); + void SetApplicationCopyrightImage(HLERequestContext& ctx); + void SetApplicationCopyrightVisibility(HLERequestContext& ctx); + void QueryApplicationPlayStatistics(HLERequestContext& ctx); + void QueryApplicationPlayStatisticsByUid(HLERequestContext& ctx); + void ExecuteProgram(HLERequestContext& ctx); + void ClearUserChannel(HLERequestContext& ctx); + void UnpopToUserChannel(HLERequestContext& ctx); + void GetPreviousProgramIndex(HLERequestContext& ctx); + void GetGpuErrorDetectedSystemEvent(HLERequestContext& ctx); + void GetFriendInvitationStorageChannelEvent(HLERequestContext& ctx); + void TryPopFromFriendInvitationStorageChannel(HLERequestContext& ctx); + void GetNotificationStorageChannelEvent(HLERequestContext& ctx); + void GetHealthWarningDisappearedSystemEvent(HLERequestContext& ctx); + void PrepareForJit(HLERequestContext& ctx); KernelHelpers::ServiceContext service_context; @@ -370,8 +371,8 @@ public: ~IHomeMenuFunctions() override; private: - void RequestToGetForeground(Kernel::HLERequestContext& ctx); - void GetPopFromGeneralChannelEvent(Kernel::HLERequestContext& ctx); + void RequestToGetForeground(HLERequestContext& ctx); + void GetPopFromGeneralChannelEvent(HLERequestContext& ctx); KernelHelpers::ServiceContext service_context; @@ -396,6 +397,6 @@ public: ~IProcessWindingController() override; }; -void LoopProcess(NVFlinger::NVFlinger& nvflinger, Core::System& system); +void LoopProcess(Nvnflinger::Nvnflinger& nvnflinger, Core::System& system); } // namespace Service::AM diff --git a/src/core/hle/service/am/applet_ae.cpp b/src/core/hle/service/am/applet_ae.cpp index d7719da35..2764f7ceb 100644 --- a/src/core/hle/service/am/applet_ae.cpp +++ b/src/core/hle/service/am/applet_ae.cpp @@ -3,20 +3,20 @@ #include "common/logging/log.h" #include "core/core.h" -#include "core/hle/ipc_helpers.h" #include "core/hle/service/am/am.h" #include "core/hle/service/am/applet_ae.h" -#include "core/hle/service/nvflinger/nvflinger.h" +#include "core/hle/service/ipc_helpers.h" +#include "core/hle/service/nvnflinger/nvnflinger.h" namespace Service::AM { class ILibraryAppletProxy final : public ServiceFramework<ILibraryAppletProxy> { public: - explicit ILibraryAppletProxy(NVFlinger::NVFlinger& nvflinger_, + explicit ILibraryAppletProxy(Nvnflinger::Nvnflinger& nvnflinger_, std::shared_ptr<AppletMessageQueue> msg_queue_, Core::System& system_) - : ServiceFramework{system_, "ILibraryAppletProxy"}, nvflinger{nvflinger_}, - msg_queue{std::move(msg_queue_)} { + : ServiceFramework{system_, "ILibraryAppletProxy"}, + nvnflinger{nvnflinger_}, msg_queue{std::move(msg_queue_)} { // clang-format off static const FunctionInfo functions[] = { {0, &ILibraryAppletProxy::GetCommonStateGetter, "GetCommonStateGetter"}, @@ -36,7 +36,7 @@ public: } private: - void GetCommonStateGetter(Kernel::HLERequestContext& ctx) { + void GetCommonStateGetter(HLERequestContext& ctx) { LOG_DEBUG(Service_AM, "called"); IPC::ResponseBuilder rb{ctx, 2, 0, 1}; @@ -44,15 +44,15 @@ private: rb.PushIpcInterface<ICommonStateGetter>(system, msg_queue); } - void GetSelfController(Kernel::HLERequestContext& ctx) { + void GetSelfController(HLERequestContext& ctx) { LOG_DEBUG(Service_AM, "called"); IPC::ResponseBuilder rb{ctx, 2, 0, 1}; rb.Push(ResultSuccess); - rb.PushIpcInterface<ISelfController>(system, nvflinger); + rb.PushIpcInterface<ISelfController>(system, nvnflinger); } - void GetWindowController(Kernel::HLERequestContext& ctx) { + void GetWindowController(HLERequestContext& ctx) { LOG_DEBUG(Service_AM, "called"); IPC::ResponseBuilder rb{ctx, 2, 0, 1}; @@ -60,7 +60,7 @@ private: rb.PushIpcInterface<IWindowController>(system); } - void GetAudioController(Kernel::HLERequestContext& ctx) { + void GetAudioController(HLERequestContext& ctx) { LOG_DEBUG(Service_AM, "called"); IPC::ResponseBuilder rb{ctx, 2, 0, 1}; @@ -68,7 +68,7 @@ private: rb.PushIpcInterface<IAudioController>(system); } - void GetDisplayController(Kernel::HLERequestContext& ctx) { + void GetDisplayController(HLERequestContext& ctx) { LOG_DEBUG(Service_AM, "called"); IPC::ResponseBuilder rb{ctx, 2, 0, 1}; @@ -76,7 +76,7 @@ private: rb.PushIpcInterface<IDisplayController>(system); } - void GetProcessWindingController(Kernel::HLERequestContext& ctx) { + void GetProcessWindingController(HLERequestContext& ctx) { LOG_DEBUG(Service_AM, "called"); IPC::ResponseBuilder rb{ctx, 2, 0, 1}; @@ -84,7 +84,7 @@ private: rb.PushIpcInterface<IProcessWindingController>(system); } - void GetDebugFunctions(Kernel::HLERequestContext& ctx) { + void GetDebugFunctions(HLERequestContext& ctx) { LOG_DEBUG(Service_AM, "called"); IPC::ResponseBuilder rb{ctx, 2, 0, 1}; @@ -92,7 +92,7 @@ private: rb.PushIpcInterface<IDebugFunctions>(system); } - void GetLibraryAppletCreator(Kernel::HLERequestContext& ctx) { + void GetLibraryAppletCreator(HLERequestContext& ctx) { LOG_DEBUG(Service_AM, "called"); IPC::ResponseBuilder rb{ctx, 2, 0, 1}; @@ -100,7 +100,7 @@ private: rb.PushIpcInterface<ILibraryAppletCreator>(system); } - void GetApplicationFunctions(Kernel::HLERequestContext& ctx) { + void GetApplicationFunctions(HLERequestContext& ctx) { LOG_DEBUG(Service_AM, "called"); IPC::ResponseBuilder rb{ctx, 2, 0, 1}; @@ -108,17 +108,17 @@ private: rb.PushIpcInterface<IApplicationFunctions>(system); } - NVFlinger::NVFlinger& nvflinger; + Nvnflinger::Nvnflinger& nvnflinger; std::shared_ptr<AppletMessageQueue> msg_queue; }; class ISystemAppletProxy final : public ServiceFramework<ISystemAppletProxy> { public: - explicit ISystemAppletProxy(NVFlinger::NVFlinger& nvflinger_, + explicit ISystemAppletProxy(Nvnflinger::Nvnflinger& nvnflinger_, std::shared_ptr<AppletMessageQueue> msg_queue_, Core::System& system_) - : ServiceFramework{system_, "ISystemAppletProxy"}, nvflinger{nvflinger_}, - msg_queue{std::move(msg_queue_)} { + : ServiceFramework{system_, "ISystemAppletProxy"}, + nvnflinger{nvnflinger_}, msg_queue{std::move(msg_queue_)} { // clang-format off static const FunctionInfo functions[] = { {0, &ISystemAppletProxy::GetCommonStateGetter, "GetCommonStateGetter"}, @@ -140,7 +140,7 @@ public: } private: - void GetCommonStateGetter(Kernel::HLERequestContext& ctx) { + void GetCommonStateGetter(HLERequestContext& ctx) { LOG_DEBUG(Service_AM, "called"); IPC::ResponseBuilder rb{ctx, 2, 0, 1}; @@ -148,15 +148,15 @@ private: rb.PushIpcInterface<ICommonStateGetter>(system, msg_queue); } - void GetSelfController(Kernel::HLERequestContext& ctx) { + void GetSelfController(HLERequestContext& ctx) { LOG_DEBUG(Service_AM, "called"); IPC::ResponseBuilder rb{ctx, 2, 0, 1}; rb.Push(ResultSuccess); - rb.PushIpcInterface<ISelfController>(system, nvflinger); + rb.PushIpcInterface<ISelfController>(system, nvnflinger); } - void GetWindowController(Kernel::HLERequestContext& ctx) { + void GetWindowController(HLERequestContext& ctx) { LOG_DEBUG(Service_AM, "called"); IPC::ResponseBuilder rb{ctx, 2, 0, 1}; @@ -164,7 +164,7 @@ private: rb.PushIpcInterface<IWindowController>(system); } - void GetAudioController(Kernel::HLERequestContext& ctx) { + void GetAudioController(HLERequestContext& ctx) { LOG_DEBUG(Service_AM, "called"); IPC::ResponseBuilder rb{ctx, 2, 0, 1}; @@ -172,7 +172,7 @@ private: rb.PushIpcInterface<IAudioController>(system); } - void GetDisplayController(Kernel::HLERequestContext& ctx) { + void GetDisplayController(HLERequestContext& ctx) { LOG_DEBUG(Service_AM, "called"); IPC::ResponseBuilder rb{ctx, 2, 0, 1}; @@ -180,7 +180,7 @@ private: rb.PushIpcInterface<IDisplayController>(system); } - void GetDebugFunctions(Kernel::HLERequestContext& ctx) { + void GetDebugFunctions(HLERequestContext& ctx) { LOG_DEBUG(Service_AM, "called"); IPC::ResponseBuilder rb{ctx, 2, 0, 1}; @@ -188,7 +188,7 @@ private: rb.PushIpcInterface<IDebugFunctions>(system); } - void GetLibraryAppletCreator(Kernel::HLERequestContext& ctx) { + void GetLibraryAppletCreator(HLERequestContext& ctx) { LOG_DEBUG(Service_AM, "called"); IPC::ResponseBuilder rb{ctx, 2, 0, 1}; @@ -196,7 +196,7 @@ private: rb.PushIpcInterface<ILibraryAppletCreator>(system); } - void GetHomeMenuFunctions(Kernel::HLERequestContext& ctx) { + void GetHomeMenuFunctions(HLERequestContext& ctx) { LOG_DEBUG(Service_AM, "called"); IPC::ResponseBuilder rb{ctx, 2, 0, 1}; @@ -204,7 +204,7 @@ private: rb.PushIpcInterface<IHomeMenuFunctions>(system); } - void GetGlobalStateController(Kernel::HLERequestContext& ctx) { + void GetGlobalStateController(HLERequestContext& ctx) { LOG_DEBUG(Service_AM, "called"); IPC::ResponseBuilder rb{ctx, 2, 0, 1}; @@ -212,7 +212,7 @@ private: rb.PushIpcInterface<IGlobalStateController>(system); } - void GetApplicationCreator(Kernel::HLERequestContext& ctx) { + void GetApplicationCreator(HLERequestContext& ctx) { LOG_DEBUG(Service_AM, "called"); IPC::ResponseBuilder rb{ctx, 2, 0, 1}; @@ -220,38 +220,38 @@ private: rb.PushIpcInterface<IApplicationCreator>(system); } - NVFlinger::NVFlinger& nvflinger; + Nvnflinger::Nvnflinger& nvnflinger; std::shared_ptr<AppletMessageQueue> msg_queue; }; -void AppletAE::OpenSystemAppletProxy(Kernel::HLERequestContext& ctx) { +void AppletAE::OpenSystemAppletProxy(HLERequestContext& ctx) { LOG_DEBUG(Service_AM, "called"); IPC::ResponseBuilder rb{ctx, 2, 0, 1}; rb.Push(ResultSuccess); - rb.PushIpcInterface<ISystemAppletProxy>(nvflinger, msg_queue, system); + rb.PushIpcInterface<ISystemAppletProxy>(nvnflinger, msg_queue, system); } -void AppletAE::OpenLibraryAppletProxy(Kernel::HLERequestContext& ctx) { +void AppletAE::OpenLibraryAppletProxy(HLERequestContext& ctx) { LOG_DEBUG(Service_AM, "called"); IPC::ResponseBuilder rb{ctx, 2, 0, 1}; rb.Push(ResultSuccess); - rb.PushIpcInterface<ILibraryAppletProxy>(nvflinger, msg_queue, system); + rb.PushIpcInterface<ILibraryAppletProxy>(nvnflinger, msg_queue, system); } -void AppletAE::OpenLibraryAppletProxyOld(Kernel::HLERequestContext& ctx) { +void AppletAE::OpenLibraryAppletProxyOld(HLERequestContext& ctx) { LOG_DEBUG(Service_AM, "called"); IPC::ResponseBuilder rb{ctx, 2, 0, 1}; rb.Push(ResultSuccess); - rb.PushIpcInterface<ILibraryAppletProxy>(nvflinger, msg_queue, system); + rb.PushIpcInterface<ILibraryAppletProxy>(nvnflinger, msg_queue, system); } -AppletAE::AppletAE(NVFlinger::NVFlinger& nvflinger_, std::shared_ptr<AppletMessageQueue> msg_queue_, - Core::System& system_) - : ServiceFramework{system_, "appletAE"}, nvflinger{nvflinger_}, msg_queue{ - std::move(msg_queue_)} { +AppletAE::AppletAE(Nvnflinger::Nvnflinger& nvnflinger_, + std::shared_ptr<AppletMessageQueue> msg_queue_, Core::System& system_) + : ServiceFramework{system_, "appletAE"}, nvnflinger{nvnflinger_}, msg_queue{ + std::move(msg_queue_)} { // clang-format off static const FunctionInfo functions[] = { {100, &AppletAE::OpenSystemAppletProxy, "OpenSystemAppletProxy"}, diff --git a/src/core/hle/service/am/applet_ae.h b/src/core/hle/service/am/applet_ae.h index 2147976a6..538ce2903 100644 --- a/src/core/hle/service/am/applet_ae.h +++ b/src/core/hle/service/am/applet_ae.h @@ -12,8 +12,8 @@ namespace FileSystem { class FileSystemController; } -namespace NVFlinger { -class NVFlinger; +namespace Nvnflinger { +class Nvnflinger; } namespace AM { @@ -22,18 +22,18 @@ class AppletMessageQueue; class AppletAE final : public ServiceFramework<AppletAE> { public: - explicit AppletAE(NVFlinger::NVFlinger& nvflinger_, + explicit AppletAE(Nvnflinger::Nvnflinger& nvnflinger_, std::shared_ptr<AppletMessageQueue> msg_queue_, Core::System& system_); ~AppletAE() override; const std::shared_ptr<AppletMessageQueue>& GetMessageQueue() const; private: - void OpenSystemAppletProxy(Kernel::HLERequestContext& ctx); - void OpenLibraryAppletProxy(Kernel::HLERequestContext& ctx); - void OpenLibraryAppletProxyOld(Kernel::HLERequestContext& ctx); + void OpenSystemAppletProxy(HLERequestContext& ctx); + void OpenLibraryAppletProxy(HLERequestContext& ctx); + void OpenLibraryAppletProxyOld(HLERequestContext& ctx); - NVFlinger::NVFlinger& nvflinger; + Nvnflinger::Nvnflinger& nvnflinger; std::shared_ptr<AppletMessageQueue> msg_queue; }; diff --git a/src/core/hle/service/am/applet_oe.cpp b/src/core/hle/service/am/applet_oe.cpp index 00fc4202c..d6c565d85 100644 --- a/src/core/hle/service/am/applet_oe.cpp +++ b/src/core/hle/service/am/applet_oe.cpp @@ -2,20 +2,20 @@ // SPDX-License-Identifier: GPL-2.0-or-later #include "common/logging/log.h" -#include "core/hle/ipc_helpers.h" #include "core/hle/service/am/am.h" #include "core/hle/service/am/applet_oe.h" -#include "core/hle/service/nvflinger/nvflinger.h" +#include "core/hle/service/ipc_helpers.h" +#include "core/hle/service/nvnflinger/nvnflinger.h" namespace Service::AM { class IApplicationProxy final : public ServiceFramework<IApplicationProxy> { public: - explicit IApplicationProxy(NVFlinger::NVFlinger& nvflinger_, + explicit IApplicationProxy(Nvnflinger::Nvnflinger& nvnflinger_, std::shared_ptr<AppletMessageQueue> msg_queue_, Core::System& system_) - : ServiceFramework{system_, "IApplicationProxy"}, nvflinger{nvflinger_}, - msg_queue{std::move(msg_queue_)} { + : ServiceFramework{system_, "IApplicationProxy"}, + nvnflinger{nvnflinger_}, msg_queue{std::move(msg_queue_)} { // clang-format off static const FunctionInfo functions[] = { {0, &IApplicationProxy::GetCommonStateGetter, "GetCommonStateGetter"}, @@ -34,7 +34,7 @@ public: } private: - void GetAudioController(Kernel::HLERequestContext& ctx) { + void GetAudioController(HLERequestContext& ctx) { LOG_DEBUG(Service_AM, "called"); IPC::ResponseBuilder rb{ctx, 2, 0, 1}; @@ -42,7 +42,7 @@ private: rb.PushIpcInterface<IAudioController>(system); } - void GetDisplayController(Kernel::HLERequestContext& ctx) { + void GetDisplayController(HLERequestContext& ctx) { LOG_DEBUG(Service_AM, "called"); IPC::ResponseBuilder rb{ctx, 2, 0, 1}; @@ -50,7 +50,7 @@ private: rb.PushIpcInterface<IDisplayController>(system); } - void GetDebugFunctions(Kernel::HLERequestContext& ctx) { + void GetDebugFunctions(HLERequestContext& ctx) { LOG_DEBUG(Service_AM, "called"); IPC::ResponseBuilder rb{ctx, 2, 0, 1}; @@ -58,7 +58,7 @@ private: rb.PushIpcInterface<IDebugFunctions>(system); } - void GetWindowController(Kernel::HLERequestContext& ctx) { + void GetWindowController(HLERequestContext& ctx) { LOG_DEBUG(Service_AM, "called"); IPC::ResponseBuilder rb{ctx, 2, 0, 1}; @@ -66,15 +66,15 @@ private: rb.PushIpcInterface<IWindowController>(system); } - void GetSelfController(Kernel::HLERequestContext& ctx) { + void GetSelfController(HLERequestContext& ctx) { LOG_DEBUG(Service_AM, "called"); IPC::ResponseBuilder rb{ctx, 2, 0, 1}; rb.Push(ResultSuccess); - rb.PushIpcInterface<ISelfController>(system, nvflinger); + rb.PushIpcInterface<ISelfController>(system, nvnflinger); } - void GetCommonStateGetter(Kernel::HLERequestContext& ctx) { + void GetCommonStateGetter(HLERequestContext& ctx) { LOG_DEBUG(Service_AM, "called"); IPC::ResponseBuilder rb{ctx, 2, 0, 1}; @@ -82,7 +82,7 @@ private: rb.PushIpcInterface<ICommonStateGetter>(system, msg_queue); } - void GetLibraryAppletCreator(Kernel::HLERequestContext& ctx) { + void GetLibraryAppletCreator(HLERequestContext& ctx) { LOG_DEBUG(Service_AM, "called"); IPC::ResponseBuilder rb{ctx, 2, 0, 1}; @@ -90,7 +90,7 @@ private: rb.PushIpcInterface<ILibraryAppletCreator>(system); } - void GetApplicationFunctions(Kernel::HLERequestContext& ctx) { + void GetApplicationFunctions(HLERequestContext& ctx) { LOG_DEBUG(Service_AM, "called"); IPC::ResponseBuilder rb{ctx, 2, 0, 1}; @@ -98,22 +98,22 @@ private: rb.PushIpcInterface<IApplicationFunctions>(system); } - NVFlinger::NVFlinger& nvflinger; + Nvnflinger::Nvnflinger& nvnflinger; std::shared_ptr<AppletMessageQueue> msg_queue; }; -void AppletOE::OpenApplicationProxy(Kernel::HLERequestContext& ctx) { +void AppletOE::OpenApplicationProxy(HLERequestContext& ctx) { LOG_DEBUG(Service_AM, "called"); IPC::ResponseBuilder rb{ctx, 2, 0, 1}; rb.Push(ResultSuccess); - rb.PushIpcInterface<IApplicationProxy>(nvflinger, msg_queue, system); + rb.PushIpcInterface<IApplicationProxy>(nvnflinger, msg_queue, system); } -AppletOE::AppletOE(NVFlinger::NVFlinger& nvflinger_, std::shared_ptr<AppletMessageQueue> msg_queue_, - Core::System& system_) - : ServiceFramework{system_, "appletOE"}, nvflinger{nvflinger_}, msg_queue{ - std::move(msg_queue_)} { +AppletOE::AppletOE(Nvnflinger::Nvnflinger& nvnflinger_, + std::shared_ptr<AppletMessageQueue> msg_queue_, Core::System& system_) + : ServiceFramework{system_, "appletOE"}, nvnflinger{nvnflinger_}, msg_queue{ + std::move(msg_queue_)} { static const FunctionInfo functions[] = { {0, &AppletOE::OpenApplicationProxy, "OpenApplicationProxy"}, }; diff --git a/src/core/hle/service/am/applet_oe.h b/src/core/hle/service/am/applet_oe.h index 8fea249f1..39eccc4ab 100644 --- a/src/core/hle/service/am/applet_oe.h +++ b/src/core/hle/service/am/applet_oe.h @@ -12,8 +12,8 @@ namespace FileSystem { class FileSystemController; } -namespace NVFlinger { -class NVFlinger; +namespace Nvnflinger { +class Nvnflinger; } namespace AM { @@ -22,16 +22,16 @@ class AppletMessageQueue; class AppletOE final : public ServiceFramework<AppletOE> { public: - explicit AppletOE(NVFlinger::NVFlinger& nvflinger_, + explicit AppletOE(Nvnflinger::Nvnflinger& nvnflinger_, std::shared_ptr<AppletMessageQueue> msg_queue_, Core::System& system_); ~AppletOE() override; const std::shared_ptr<AppletMessageQueue>& GetMessageQueue() const; private: - void OpenApplicationProxy(Kernel::HLERequestContext& ctx); + void OpenApplicationProxy(HLERequestContext& ctx); - NVFlinger::NVFlinger& nvflinger; + Nvnflinger::Nvnflinger& nvnflinger; std::shared_ptr<AppletMessageQueue> msg_queue; }; diff --git a/src/core/hle/service/am/applets/applet_cabinet.cpp b/src/core/hle/service/am/applets/applet_cabinet.cpp index d0969b0f1..162687b29 100644 --- a/src/core/hle/service/am/applets/applet_cabinet.cpp +++ b/src/core/hle/service/am/applets/applet_cabinet.cpp @@ -119,7 +119,7 @@ void Cabinet::DisplayCompleted(bool apply_changes, std::string_view amiibo_name) case Service::NFP::CabinetMode::StartNicknameAndOwnerSettings: { Service::NFP::AmiiboName name{}; std::memcpy(name.data(), amiibo_name.data(), std::min(amiibo_name.size(), name.size() - 1)); - nfp_device->SetNicknameAndOwner(name); + nfp_device->SetRegisterInfoPrivate(name); break; } case Service::NFP::CabinetMode::StartGameDataEraser: @@ -129,7 +129,7 @@ void Cabinet::DisplayCompleted(bool apply_changes, std::string_view amiibo_name) nfp_device->RestoreAmiibo(); break; case Service::NFP::CabinetMode::StartFormatter: - nfp_device->DeleteAllData(); + nfp_device->Format(); break; default: UNIMPLEMENTED_MSG("Unknown CabinetMode={}", applet_input_common.applet_mode); diff --git a/src/core/hle/service/am/applets/applet_controller.cpp b/src/core/hle/service/am/applets/applet_controller.cpp index b418031de..58484519b 100644 --- a/src/core/hle/service/am/applets/applet_controller.cpp +++ b/src/core/hle/service/am/applets/applet_controller.cpp @@ -19,10 +19,9 @@ namespace Service::AM::Applets { -// This error code (0x183ACA) is thrown when the applet fails to initialize. -[[maybe_unused]] constexpr Result ERR_CONTROLLER_APPLET_3101{ErrorModule::HID, 3101}; -// This error code (0x183CCA) is thrown when the u32 result in ControllerSupportResultInfo is 2. -[[maybe_unused]] constexpr Result ERR_CONTROLLER_APPLET_3102{ErrorModule::HID, 3102}; +[[maybe_unused]] constexpr Result ResultControllerSupportCanceled{ErrorModule::HID, 3101}; +[[maybe_unused]] constexpr Result ResultControllerSupportNotSupportedNpadStyle{ErrorModule::HID, + 3102}; static Core::Frontend::ControllerParameters ConvertToFrontendParameters( ControllerSupportArgPrivate private_arg, ControllerSupportArgHeader header, bool enable_text, diff --git a/src/core/hle/service/am/applets/applet_profile_select.cpp b/src/core/hle/service/am/applets/applet_profile_select.cpp index c738db028..1d69f5447 100644 --- a/src/core/hle/service/am/applets/applet_profile_select.cpp +++ b/src/core/hle/service/am/applets/applet_profile_select.cpp @@ -7,13 +7,12 @@ #include "common/string_util.h" #include "core/core.h" #include "core/frontend/applets/profile_select.h" +#include "core/hle/service/acc/errors.h" #include "core/hle/service/am/am.h" #include "core/hle/service/am/applets/applet_profile_select.h" namespace Service::AM::Applets { -constexpr Result ERR_USER_CANCELLED_SELECTION{ErrorModule::Account, 1}; - ProfileSelect::ProfileSelect(Core::System& system_, LibraryAppletMode applet_mode_, const Core::Frontend::ProfileSelectApplet& frontend_) : Applet{system_, applet_mode_}, frontend{frontend_}, system{system_} {} @@ -63,8 +62,8 @@ void ProfileSelect::SelectionComplete(std::optional<Common::UUID> uuid) { output.result = 0; output.uuid_selected = *uuid; } else { - status = ERR_USER_CANCELLED_SELECTION; - output.result = ERR_USER_CANCELLED_SELECTION.raw; + status = Account::ResultCancelledByUser; + output.result = Account::ResultCancelledByUser.raw; output.uuid_selected = Common::InvalidUUID; } diff --git a/src/core/hle/service/aoc/aoc_u.cpp b/src/core/hle/service/aoc/aoc_u.cpp index fed51cfd6..38c2138e8 100644 --- a/src/core/hle/service/aoc/aoc_u.cpp +++ b/src/core/hle/service/aoc/aoc_u.cpp @@ -14,9 +14,9 @@ #include "core/file_sys/nca_metadata.h" #include "core/file_sys/patch_manager.h" #include "core/file_sys/registered_cache.h" -#include "core/hle/ipc_helpers.h" #include "core/hle/kernel/k_event.h" #include "core/hle/service/aoc/aoc_u.h" +#include "core/hle/service/ipc_helpers.h" #include "core/hle/service/server_manager.h" #include "core/loader/loader.h" @@ -69,7 +69,7 @@ public: } private: - void SetDefaultDeliveryTarget(Kernel::HLERequestContext& ctx) { + void SetDefaultDeliveryTarget(HLERequestContext& ctx) { IPC::RequestParser rp{ctx}; const auto unknown_1 = rp.Pop<u64>(); @@ -81,7 +81,7 @@ private: rb.Push(ResultSuccess); } - void SetDeliveryTarget(Kernel::HLERequestContext& ctx) { + void SetDeliveryTarget(HLERequestContext& ctx) { IPC::RequestParser rp{ctx}; const auto unknown_1 = rp.Pop<u64>(); @@ -93,7 +93,7 @@ private: rb.Push(ResultSuccess); } - void GetPurchasedEventReadableHandle(Kernel::HLERequestContext& ctx) { + void GetPurchasedEventReadableHandle(HLERequestContext& ctx) { LOG_WARNING(Service_AOC, "called"); IPC::ResponseBuilder rb{ctx, 2, 1}; @@ -145,7 +145,7 @@ AOC_U::~AOC_U() { service_context.CloseEvent(aoc_change_event); } -void AOC_U::CountAddOnContent(Kernel::HLERequestContext& ctx) { +void AOC_U::CountAddOnContent(HLERequestContext& ctx) { struct Parameters { u64 process_id; }; @@ -172,7 +172,7 @@ void AOC_U::CountAddOnContent(Kernel::HLERequestContext& ctx) { [current](u64 tid) { return CheckAOCTitleIDMatchesBase(tid, current); }))); } -void AOC_U::ListAddOnContent(Kernel::HLERequestContext& ctx) { +void AOC_U::ListAddOnContent(HLERequestContext& ctx) { struct Parameters { u32 offset; u32 count; @@ -218,7 +218,7 @@ void AOC_U::ListAddOnContent(Kernel::HLERequestContext& ctx) { rb.Push(out_count); } -void AOC_U::GetAddOnContentBaseId(Kernel::HLERequestContext& ctx) { +void AOC_U::GetAddOnContentBaseId(HLERequestContext& ctx) { struct Parameters { u64 process_id; }; @@ -245,7 +245,7 @@ void AOC_U::GetAddOnContentBaseId(Kernel::HLERequestContext& ctx) { rb.Push(res.first->GetDLCBaseTitleId()); } -void AOC_U::PrepareAddOnContent(Kernel::HLERequestContext& ctx) { +void AOC_U::PrepareAddOnContent(HLERequestContext& ctx) { struct Parameters { s32 addon_index; u64 process_id; @@ -262,7 +262,7 @@ void AOC_U::PrepareAddOnContent(Kernel::HLERequestContext& ctx) { rb.Push(ResultSuccess); } -void AOC_U::GetAddOnContentListChangedEvent(Kernel::HLERequestContext& ctx) { +void AOC_U::GetAddOnContentListChangedEvent(HLERequestContext& ctx) { LOG_WARNING(Service_AOC, "(STUBBED) called"); IPC::ResponseBuilder rb{ctx, 2, 1}; @@ -270,7 +270,7 @@ void AOC_U::GetAddOnContentListChangedEvent(Kernel::HLERequestContext& ctx) { rb.PushCopyObjects(aoc_change_event->GetReadableEvent()); } -void AOC_U::GetAddOnContentListChangedEventWithProcessId(Kernel::HLERequestContext& ctx) { +void AOC_U::GetAddOnContentListChangedEventWithProcessId(HLERequestContext& ctx) { LOG_WARNING(Service_AOC, "(STUBBED) called"); IPC::ResponseBuilder rb{ctx, 2, 1}; @@ -278,28 +278,28 @@ void AOC_U::GetAddOnContentListChangedEventWithProcessId(Kernel::HLERequestConte rb.PushCopyObjects(aoc_change_event->GetReadableEvent()); } -void AOC_U::NotifyMountAddOnContent(Kernel::HLERequestContext& ctx) { +void AOC_U::NotifyMountAddOnContent(HLERequestContext& ctx) { LOG_WARNING(Service_AOC, "(STUBBED) called"); IPC::ResponseBuilder rb{ctx, 2}; rb.Push(ResultSuccess); } -void AOC_U::NotifyUnmountAddOnContent(Kernel::HLERequestContext& ctx) { +void AOC_U::NotifyUnmountAddOnContent(HLERequestContext& ctx) { LOG_WARNING(Service_AOC, "(STUBBED) called"); IPC::ResponseBuilder rb{ctx, 2}; rb.Push(ResultSuccess); } -void AOC_U::CheckAddOnContentMountStatus(Kernel::HLERequestContext& ctx) { +void AOC_U::CheckAddOnContentMountStatus(HLERequestContext& ctx) { LOG_WARNING(Service_AOC, "(STUBBED) called"); IPC::ResponseBuilder rb{ctx, 2}; rb.Push(ResultSuccess); } -void AOC_U::CreateEcPurchasedEventManager(Kernel::HLERequestContext& ctx) { +void AOC_U::CreateEcPurchasedEventManager(HLERequestContext& ctx) { LOG_WARNING(Service_AOC, "(STUBBED) called"); IPC::ResponseBuilder rb{ctx, 2, 0, 1}; @@ -307,7 +307,7 @@ void AOC_U::CreateEcPurchasedEventManager(Kernel::HLERequestContext& ctx) { rb.PushIpcInterface<IPurchaseEventManager>(system); } -void AOC_U::CreatePermanentEcPurchasedEventManager(Kernel::HLERequestContext& ctx) { +void AOC_U::CreatePermanentEcPurchasedEventManager(HLERequestContext& ctx) { LOG_WARNING(Service_AOC, "(STUBBED) called"); IPC::ResponseBuilder rb{ctx, 2, 0, 1}; diff --git a/src/core/hle/service/aoc/aoc_u.h b/src/core/hle/service/aoc/aoc_u.h index 5e7087e50..12ccfeb6a 100644 --- a/src/core/hle/service/aoc/aoc_u.h +++ b/src/core/hle/service/aoc/aoc_u.h @@ -22,17 +22,17 @@ public: ~AOC_U() override; private: - void CountAddOnContent(Kernel::HLERequestContext& ctx); - void ListAddOnContent(Kernel::HLERequestContext& ctx); - void GetAddOnContentBaseId(Kernel::HLERequestContext& ctx); - void PrepareAddOnContent(Kernel::HLERequestContext& ctx); - void GetAddOnContentListChangedEvent(Kernel::HLERequestContext& ctx); - void GetAddOnContentListChangedEventWithProcessId(Kernel::HLERequestContext& ctx); - void NotifyMountAddOnContent(Kernel::HLERequestContext& ctx); - void NotifyUnmountAddOnContent(Kernel::HLERequestContext& ctx); - void CheckAddOnContentMountStatus(Kernel::HLERequestContext& ctx); - void CreateEcPurchasedEventManager(Kernel::HLERequestContext& ctx); - void CreatePermanentEcPurchasedEventManager(Kernel::HLERequestContext& ctx); + void CountAddOnContent(HLERequestContext& ctx); + void ListAddOnContent(HLERequestContext& ctx); + void GetAddOnContentBaseId(HLERequestContext& ctx); + void PrepareAddOnContent(HLERequestContext& ctx); + void GetAddOnContentListChangedEvent(HLERequestContext& ctx); + void GetAddOnContentListChangedEventWithProcessId(HLERequestContext& ctx); + void NotifyMountAddOnContent(HLERequestContext& ctx); + void NotifyUnmountAddOnContent(HLERequestContext& ctx); + void CheckAddOnContentMountStatus(HLERequestContext& ctx); + void CreateEcPurchasedEventManager(HLERequestContext& ctx); + void CreatePermanentEcPurchasedEventManager(HLERequestContext& ctx); std::vector<u64> add_on_content; KernelHelpers::ServiceContext service_context; diff --git a/src/core/hle/service/apm/apm_interface.cpp b/src/core/hle/service/apm/apm_interface.cpp index 041fc16bd..d29051ee7 100644 --- a/src/core/hle/service/apm/apm_interface.cpp +++ b/src/core/hle/service/apm/apm_interface.cpp @@ -2,10 +2,10 @@ // SPDX-License-Identifier: GPL-2.0-or-later #include "common/logging/log.h" -#include "core/hle/ipc_helpers.h" #include "core/hle/service/apm/apm.h" #include "core/hle/service/apm/apm_controller.h" #include "core/hle/service/apm/apm_interface.h" +#include "core/hle/service/ipc_helpers.h" namespace Service::APM { @@ -22,7 +22,7 @@ public: } private: - void SetPerformanceConfiguration(Kernel::HLERequestContext& ctx) { + void SetPerformanceConfiguration(HLERequestContext& ctx) { IPC::RequestParser rp{ctx}; const auto mode = rp.PopEnum<PerformanceMode>(); @@ -35,7 +35,7 @@ private: rb.Push(ResultSuccess); } - void GetPerformanceConfiguration(Kernel::HLERequestContext& ctx) { + void GetPerformanceConfiguration(HLERequestContext& ctx) { IPC::RequestParser rp{ctx}; const auto mode = rp.PopEnum<PerformanceMode>(); @@ -46,7 +46,7 @@ private: rb.PushEnum(controller.GetCurrentPerformanceConfiguration(mode)); } - void SetCpuOverclockEnabled(Kernel::HLERequestContext& ctx) { + void SetCpuOverclockEnabled(HLERequestContext& ctx) { IPC::RequestParser rp{ctx}; const auto cpu_overclock_enabled = rp.Pop<bool>(); @@ -74,7 +74,7 @@ APM::APM(Core::System& system_, std::shared_ptr<Module> apm_, Controller& contro APM::~APM() = default; -void APM::OpenSession(Kernel::HLERequestContext& ctx) { +void APM::OpenSession(HLERequestContext& ctx) { LOG_DEBUG(Service_APM, "called"); IPC::ResponseBuilder rb{ctx, 2, 0, 1}; @@ -82,14 +82,14 @@ void APM::OpenSession(Kernel::HLERequestContext& ctx) { rb.PushIpcInterface<ISession>(system, controller); } -void APM::GetPerformanceMode(Kernel::HLERequestContext& ctx) { +void APM::GetPerformanceMode(HLERequestContext& ctx) { LOG_DEBUG(Service_APM, "called"); IPC::ResponseBuilder rb{ctx, 2}; rb.PushEnum(controller.GetCurrentPerformanceMode()); } -void APM::IsCpuOverclockEnabled(Kernel::HLERequestContext& ctx) { +void APM::IsCpuOverclockEnabled(HLERequestContext& ctx) { LOG_WARNING(Service_APM, "(STUBBED) called"); IPC::ResponseBuilder rb{ctx, 3}; @@ -117,7 +117,7 @@ APM_Sys::APM_Sys(Core::System& system_, Controller& controller_) APM_Sys::~APM_Sys() = default; -void APM_Sys::GetPerformanceEvent(Kernel::HLERequestContext& ctx) { +void APM_Sys::GetPerformanceEvent(HLERequestContext& ctx) { LOG_DEBUG(Service_APM, "called"); IPC::ResponseBuilder rb{ctx, 2, 0, 1}; @@ -125,7 +125,7 @@ void APM_Sys::GetPerformanceEvent(Kernel::HLERequestContext& ctx) { rb.PushIpcInterface<ISession>(system, controller); } -void APM_Sys::SetCpuBoostMode(Kernel::HLERequestContext& ctx) { +void APM_Sys::SetCpuBoostMode(HLERequestContext& ctx) { IPC::RequestParser rp{ctx}; const auto mode = rp.PopEnum<CpuBoostMode>(); @@ -137,7 +137,7 @@ void APM_Sys::SetCpuBoostMode(Kernel::HLERequestContext& ctx) { rb.Push(ResultSuccess); } -void APM_Sys::GetCurrentPerformanceConfiguration(Kernel::HLERequestContext& ctx) { +void APM_Sys::GetCurrentPerformanceConfiguration(HLERequestContext& ctx) { LOG_DEBUG(Service_APM, "called"); IPC::ResponseBuilder rb{ctx, 3}; diff --git a/src/core/hle/service/apm/apm_interface.h b/src/core/hle/service/apm/apm_interface.h index 0740fd4ba..58718453b 100644 --- a/src/core/hle/service/apm/apm_interface.h +++ b/src/core/hle/service/apm/apm_interface.h @@ -17,9 +17,9 @@ public: ~APM() override; private: - void OpenSession(Kernel::HLERequestContext& ctx); - void GetPerformanceMode(Kernel::HLERequestContext& ctx); - void IsCpuOverclockEnabled(Kernel::HLERequestContext& ctx); + void OpenSession(HLERequestContext& ctx); + void GetPerformanceMode(HLERequestContext& ctx); + void IsCpuOverclockEnabled(HLERequestContext& ctx); std::shared_ptr<Module> apm; Controller& controller; @@ -30,11 +30,11 @@ public: explicit APM_Sys(Core::System& system_, Controller& controller); ~APM_Sys() override; - void SetCpuBoostMode(Kernel::HLERequestContext& ctx); + void SetCpuBoostMode(HLERequestContext& ctx); private: - void GetPerformanceEvent(Kernel::HLERequestContext& ctx); - void GetCurrentPerformanceConfiguration(Kernel::HLERequestContext& ctx); + void GetPerformanceEvent(HLERequestContext& ctx); + void GetCurrentPerformanceConfiguration(HLERequestContext& ctx); Controller& controller; }; diff --git a/src/core/hle/service/audio/audctl.cpp b/src/core/hle/service/audio/audctl.cpp index 5abf22ba4..7ad93be6b 100644 --- a/src/core/hle/service/audio/audctl.cpp +++ b/src/core/hle/service/audio/audctl.cpp @@ -2,8 +2,8 @@ // SPDX-License-Identifier: GPL-2.0-or-later #include "common/logging/log.h" -#include "core/hle/ipc_helpers.h" #include "core/hle/service/audio/audctl.h" +#include "core/hle/service/ipc_helpers.h" namespace Service::Audio { @@ -72,7 +72,7 @@ AudCtl::AudCtl(Core::System& system_) : ServiceFramework{system_, "audctl"} { AudCtl::~AudCtl() = default; -void AudCtl::GetTargetVolumeMin(Kernel::HLERequestContext& ctx) { +void AudCtl::GetTargetVolumeMin(HLERequestContext& ctx) { LOG_DEBUG(Audio, "called."); // This service function is currently hardcoded on the @@ -84,7 +84,7 @@ void AudCtl::GetTargetVolumeMin(Kernel::HLERequestContext& ctx) { rb.Push(target_min_volume); } -void AudCtl::GetTargetVolumeMax(Kernel::HLERequestContext& ctx) { +void AudCtl::GetTargetVolumeMax(HLERequestContext& ctx) { LOG_DEBUG(Audio, "called."); // This service function is currently hardcoded on the diff --git a/src/core/hle/service/audio/audctl.h b/src/core/hle/service/audio/audctl.h index a27ff6cfe..8e31ac237 100644 --- a/src/core/hle/service/audio/audctl.h +++ b/src/core/hle/service/audio/audctl.h @@ -17,8 +17,8 @@ public: ~AudCtl() override; private: - void GetTargetVolumeMin(Kernel::HLERequestContext& ctx); - void GetTargetVolumeMax(Kernel::HLERequestContext& ctx); + void GetTargetVolumeMin(HLERequestContext& ctx); + void GetTargetVolumeMax(HLERequestContext& ctx); }; } // namespace Service::Audio diff --git a/src/core/hle/service/audio/audin_u.cpp b/src/core/hle/service/audio/audin_u.cpp index 26dec7147..f0640c64f 100644 --- a/src/core/hle/service/audio/audin_u.cpp +++ b/src/core/hle/service/audio/audin_u.cpp @@ -7,9 +7,9 @@ #include "common/logging/log.h" #include "common/string_util.h" #include "core/core.h" -#include "core/hle/ipc_helpers.h" #include "core/hle/kernel/k_event.h" #include "core/hle/service/audio/audin_u.h" +#include "core/hle/service/ipc_helpers.h" namespace Service::Audio { using namespace AudioCore::AudioIn; @@ -61,7 +61,7 @@ public: } private: - void GetAudioInState(Kernel::HLERequestContext& ctx) { + void GetAudioInState(HLERequestContext& ctx) { const auto state = static_cast<u32>(impl->GetState()); LOG_DEBUG(Service_Audio, "called. State={}", state); @@ -71,7 +71,7 @@ private: rb.Push(state); } - void Start(Kernel::HLERequestContext& ctx) { + void Start(HLERequestContext& ctx) { LOG_DEBUG(Service_Audio, "called"); auto result = impl->StartSystem(); @@ -80,7 +80,7 @@ private: rb.Push(result); } - void Stop(Kernel::HLERequestContext& ctx) { + void Stop(HLERequestContext& ctx) { LOG_DEBUG(Service_Audio, "called"); auto result = impl->StopSystem(); @@ -89,7 +89,7 @@ private: rb.Push(result); } - void AppendAudioInBuffer(Kernel::HLERequestContext& ctx) { + void AppendAudioInBuffer(HLERequestContext& ctx) { IPC::RequestParser rp{ctx}; u64 tag = rp.PopRaw<u64>(); @@ -111,7 +111,7 @@ private: rb.Push(result); } - void RegisterBufferEvent(Kernel::HLERequestContext& ctx) { + void RegisterBufferEvent(HLERequestContext& ctx) { LOG_DEBUG(Service_Audio, "called"); auto& buffer_event = impl->GetBufferEvent(); @@ -121,7 +121,7 @@ private: rb.PushCopyObjects(buffer_event); } - void GetReleasedAudioInBuffer(Kernel::HLERequestContext& ctx) { + void GetReleasedAudioInBuffer(HLERequestContext& ctx) { const auto write_buffer_size = ctx.GetWriteBufferNumElements<u64>(); std::vector<u64> released_buffers(write_buffer_size); @@ -141,7 +141,7 @@ private: rb.Push(count); } - void ContainsAudioInBuffer(Kernel::HLERequestContext& ctx) { + void ContainsAudioInBuffer(HLERequestContext& ctx) { IPC::RequestParser rp{ctx}; const u64 tag{rp.Pop<u64>()}; @@ -154,7 +154,7 @@ private: rb.Push(buffer_queued); } - void GetAudioInBufferCount(Kernel::HLERequestContext& ctx) { + void GetAudioInBufferCount(HLERequestContext& ctx) { const auto buffer_count = impl->GetBufferCount(); LOG_DEBUG(Service_Audio, "called. Buffer count={}", buffer_count); @@ -165,7 +165,7 @@ private: rb.Push(buffer_count); } - void SetDeviceGain(Kernel::HLERequestContext& ctx) { + void SetDeviceGain(HLERequestContext& ctx) { IPC::RequestParser rp{ctx}; const auto volume{rp.Pop<f32>()}; @@ -177,7 +177,7 @@ private: rb.Push(ResultSuccess); } - void GetDeviceGain(Kernel::HLERequestContext& ctx) { + void GetDeviceGain(HLERequestContext& ctx) { auto volume{impl->GetVolume()}; LOG_DEBUG(Service_Audio, "called. Gain {}", volume); @@ -187,7 +187,7 @@ private: rb.Push(volume); } - void FlushAudioInBuffers(Kernel::HLERequestContext& ctx) { + void FlushAudioInBuffers(HLERequestContext& ctx) { bool flushed{impl->FlushAudioInBuffers()}; LOG_DEBUG(Service_Audio, "called. Were any buffers flushed? {}", flushed); @@ -221,7 +221,7 @@ AudInU::AudInU(Core::System& system_) AudInU::~AudInU() = default; -void AudInU::ListAudioIns(Kernel::HLERequestContext& ctx) { +void AudInU::ListAudioIns(HLERequestContext& ctx) { using namespace AudioCore::AudioRenderer; LOG_DEBUG(Service_Audio, "called"); @@ -241,7 +241,7 @@ void AudInU::ListAudioIns(Kernel::HLERequestContext& ctx) { rb.Push(out_count); } -void AudInU::ListAudioInsAutoFiltered(Kernel::HLERequestContext& ctx) { +void AudInU::ListAudioInsAutoFiltered(HLERequestContext& ctx) { using namespace AudioCore::AudioRenderer; LOG_DEBUG(Service_Audio, "called"); @@ -261,7 +261,7 @@ void AudInU::ListAudioInsAutoFiltered(Kernel::HLERequestContext& ctx) { rb.Push(out_count); } -void AudInU::OpenAudioIn(Kernel::HLERequestContext& ctx) { +void AudInU::OpenAudioIn(HLERequestContext& ctx) { IPC::RequestParser rp{ctx}; auto in_params{rp.PopRaw<AudioInParameter>()}; auto applet_resource_user_id{rp.PopRaw<u64>()}; @@ -311,7 +311,7 @@ void AudInU::OpenAudioIn(Kernel::HLERequestContext& ctx) { rb.PushIpcInterface<IAudioIn>(audio_in); } -void AudInU::OpenAudioInProtocolSpecified(Kernel::HLERequestContext& ctx) { +void AudInU::OpenAudioInProtocolSpecified(HLERequestContext& ctx) { IPC::RequestParser rp{ctx}; auto protocol_specified{rp.PopRaw<u64>()}; auto in_params{rp.PopRaw<AudioInParameter>()}; diff --git a/src/core/hle/service/audio/audin_u.h b/src/core/hle/service/audio/audin_u.h index b45fda78a..51e770ff9 100644 --- a/src/core/hle/service/audio/audin_u.h +++ b/src/core/hle/service/audio/audin_u.h @@ -12,10 +12,6 @@ namespace Core { class System; } -namespace Kernel { -class HLERequestContext; -} - namespace AudioCore::AudioOut { class Manager; class In; @@ -29,11 +25,11 @@ public: ~AudInU() override; private: - void ListAudioIns(Kernel::HLERequestContext& ctx); - void ListAudioInsAutoFiltered(Kernel::HLERequestContext& ctx); - void OpenInOutImpl(Kernel::HLERequestContext& ctx); - void OpenAudioIn(Kernel::HLERequestContext& ctx); - void OpenAudioInProtocolSpecified(Kernel::HLERequestContext& ctx); + void ListAudioIns(HLERequestContext& ctx); + void ListAudioInsAutoFiltered(HLERequestContext& ctx); + void OpenInOutImpl(HLERequestContext& ctx); + void OpenAudioIn(HLERequestContext& ctx); + void OpenAudioInProtocolSpecified(HLERequestContext& ctx); KernelHelpers::ServiceContext service_context; std::unique_ptr<AudioCore::AudioIn::Manager> impl; diff --git a/src/core/hle/service/audio/audout_u.cpp b/src/core/hle/service/audio/audout_u.cpp index 991e30ba1..23b8be993 100644 --- a/src/core/hle/service/audio/audout_u.cpp +++ b/src/core/hle/service/audio/audout_u.cpp @@ -12,10 +12,10 @@ #include "common/string_util.h" #include "common/swap.h" #include "core/core.h" -#include "core/hle/ipc_helpers.h" #include "core/hle/kernel/k_event.h" #include "core/hle/service/audio/audout_u.h" #include "core/hle/service/audio/errors.h" +#include "core/hle/service/ipc_helpers.h" #include "core/memory.h" namespace Service::Audio { @@ -67,7 +67,7 @@ public: } private: - void GetAudioOutState(Kernel::HLERequestContext& ctx) { + void GetAudioOutState(HLERequestContext& ctx) { const auto state = static_cast<u32>(impl->GetState()); LOG_DEBUG(Service_Audio, "called. State={}", state); @@ -77,7 +77,7 @@ private: rb.Push(state); } - void Start(Kernel::HLERequestContext& ctx) { + void Start(HLERequestContext& ctx) { LOG_DEBUG(Service_Audio, "called"); auto result = impl->StartSystem(); @@ -86,7 +86,7 @@ private: rb.Push(result); } - void Stop(Kernel::HLERequestContext& ctx) { + void Stop(HLERequestContext& ctx) { LOG_DEBUG(Service_Audio, "called"); auto result = impl->StopSystem(); @@ -95,7 +95,7 @@ private: rb.Push(result); } - void AppendAudioOutBuffer(Kernel::HLERequestContext& ctx) { + void AppendAudioOutBuffer(HLERequestContext& ctx) { IPC::RequestParser rp{ctx}; u64 tag = rp.PopRaw<u64>(); @@ -117,7 +117,7 @@ private: rb.Push(result); } - void RegisterBufferEvent(Kernel::HLERequestContext& ctx) { + void RegisterBufferEvent(HLERequestContext& ctx) { LOG_DEBUG(Service_Audio, "called"); auto& buffer_event = impl->GetBufferEvent(); @@ -127,7 +127,7 @@ private: rb.PushCopyObjects(buffer_event); } - void GetReleasedAudioOutBuffers(Kernel::HLERequestContext& ctx) { + void GetReleasedAudioOutBuffers(HLERequestContext& ctx) { const auto write_buffer_size = ctx.GetWriteBufferNumElements<u64>(); std::vector<u64> released_buffers(write_buffer_size); @@ -147,7 +147,7 @@ private: rb.Push(count); } - void ContainsAudioOutBuffer(Kernel::HLERequestContext& ctx) { + void ContainsAudioOutBuffer(HLERequestContext& ctx) { IPC::RequestParser rp{ctx}; const u64 tag{rp.Pop<u64>()}; @@ -160,7 +160,7 @@ private: rb.Push(buffer_queued); } - void GetAudioOutBufferCount(Kernel::HLERequestContext& ctx) { + void GetAudioOutBufferCount(HLERequestContext& ctx) { const auto buffer_count = impl->GetBufferCount(); LOG_DEBUG(Service_Audio, "called. Buffer count={}", buffer_count); @@ -171,7 +171,7 @@ private: rb.Push(buffer_count); } - void GetAudioOutPlayedSampleCount(Kernel::HLERequestContext& ctx) { + void GetAudioOutPlayedSampleCount(HLERequestContext& ctx) { const auto samples_played = impl->GetPlayedSampleCount(); LOG_DEBUG(Service_Audio, "called. Played samples={}", samples_played); @@ -182,7 +182,7 @@ private: rb.Push(samples_played); } - void FlushAudioOutBuffers(Kernel::HLERequestContext& ctx) { + void FlushAudioOutBuffers(HLERequestContext& ctx) { bool flushed{impl->FlushAudioOutBuffers()}; LOG_DEBUG(Service_Audio, "called. Were any buffers flushed? {}", flushed); @@ -192,7 +192,7 @@ private: rb.Push(flushed); } - void SetAudioOutVolume(Kernel::HLERequestContext& ctx) { + void SetAudioOutVolume(HLERequestContext& ctx) { IPC::RequestParser rp{ctx}; const auto volume = rp.Pop<f32>(); @@ -204,7 +204,7 @@ private: rb.Push(ResultSuccess); } - void GetAudioOutVolume(Kernel::HLERequestContext& ctx) { + void GetAudioOutVolume(HLERequestContext& ctx) { const auto volume = impl->GetVolume(); LOG_DEBUG(Service_Audio, "called. Volume={}", volume); @@ -236,7 +236,7 @@ AudOutU::AudOutU(Core::System& system_) AudOutU::~AudOutU() = default; -void AudOutU::ListAudioOuts(Kernel::HLERequestContext& ctx) { +void AudOutU::ListAudioOuts(HLERequestContext& ctx) { using namespace AudioCore::AudioRenderer; std::scoped_lock l{impl->mutex}; @@ -258,7 +258,7 @@ void AudOutU::ListAudioOuts(Kernel::HLERequestContext& ctx) { rb.Push<u32>(static_cast<u32>(device_names.size())); } -void AudOutU::OpenAudioOut(Kernel::HLERequestContext& ctx) { +void AudOutU::OpenAudioOut(HLERequestContext& ctx) { IPC::RequestParser rp{ctx}; auto in_params{rp.PopRaw<AudioOutParameter>()}; auto applet_resource_user_id{rp.PopRaw<u64>()}; diff --git a/src/core/hle/service/audio/audout_u.h b/src/core/hle/service/audio/audout_u.h index fdc0ee754..8f288c6e0 100644 --- a/src/core/hle/service/audio/audout_u.h +++ b/src/core/hle/service/audio/audout_u.h @@ -12,10 +12,6 @@ namespace Core { class System; } -namespace Kernel { -class HLERequestContext; -} - namespace AudioCore::AudioOut { class Manager; class Out; @@ -31,8 +27,8 @@ public: ~AudOutU() override; private: - void ListAudioOuts(Kernel::HLERequestContext& ctx); - void OpenAudioOut(Kernel::HLERequestContext& ctx); + void ListAudioOuts(HLERequestContext& ctx); + void OpenAudioOut(HLERequestContext& ctx); KernelHelpers::ServiceContext service_context; std::unique_ptr<AudioCore::AudioOut::Manager> impl; diff --git a/src/core/hle/service/audio/audren_u.cpp b/src/core/hle/service/audio/audren_u.cpp index 6c12f00a1..7086d4750 100644 --- a/src/core/hle/service/audio/audren_u.cpp +++ b/src/core/hle/service/audio/audren_u.cpp @@ -17,12 +17,12 @@ #include "common/polyfill_ranges.h" #include "common/string_util.h" #include "core/core.h" -#include "core/hle/ipc_helpers.h" #include "core/hle/kernel/k_event.h" #include "core/hle/kernel/k_process.h" #include "core/hle/kernel/k_transfer_memory.h" #include "core/hle/service/audio/audren_u.h" #include "core/hle/service/audio/errors.h" +#include "core/hle/service/ipc_helpers.h" #include "core/memory.h" using namespace AudioCore::AudioRenderer; @@ -68,7 +68,7 @@ public: } private: - void GetSampleRate(Kernel::HLERequestContext& ctx) { + void GetSampleRate(HLERequestContext& ctx) { const auto sample_rate{impl->GetSystem().GetSampleRate()}; LOG_DEBUG(Service_Audio, "called. Sample rate {}", sample_rate); @@ -78,7 +78,7 @@ private: rb.Push(sample_rate); } - void GetSampleCount(Kernel::HLERequestContext& ctx) { + void GetSampleCount(HLERequestContext& ctx) { const auto sample_count{impl->GetSystem().GetSampleCount()}; LOG_DEBUG(Service_Audio, "called. Sample count {}", sample_count); @@ -88,7 +88,7 @@ private: rb.Push(sample_count); } - void GetState(Kernel::HLERequestContext& ctx) { + void GetState(HLERequestContext& ctx) { const u32 state{!impl->GetSystem().IsActive()}; LOG_DEBUG(Service_Audio, "called, state {}", state); @@ -98,7 +98,7 @@ private: rb.Push(state); } - void GetMixBufferCount(Kernel::HLERequestContext& ctx) { + void GetMixBufferCount(HLERequestContext& ctx) { LOG_DEBUG(Service_Audio, "called"); const auto buffer_count{impl->GetSystem().GetMixBufferCount()}; @@ -108,7 +108,7 @@ private: rb.Push(buffer_count); } - void RequestUpdate(Kernel::HLERequestContext& ctx) { + void RequestUpdate(HLERequestContext& ctx) { LOG_TRACE(Service_Audio, "called"); const auto input{ctx.ReadBuffer(0)}; @@ -147,7 +147,7 @@ private: rb.Push(result); } - void Start(Kernel::HLERequestContext& ctx) { + void Start(HLERequestContext& ctx) { LOG_DEBUG(Service_Audio, "called"); impl->Start(); @@ -156,7 +156,7 @@ private: rb.Push(ResultSuccess); } - void Stop(Kernel::HLERequestContext& ctx) { + void Stop(HLERequestContext& ctx) { LOG_DEBUG(Service_Audio, "called"); impl->Stop(); @@ -165,12 +165,12 @@ private: rb.Push(ResultSuccess); } - void QuerySystemEvent(Kernel::HLERequestContext& ctx) { + void QuerySystemEvent(HLERequestContext& ctx) { LOG_DEBUG(Service_Audio, "called"); if (impl->GetSystem().GetExecutionMode() == AudioCore::ExecutionMode::Manual) { IPC::ResponseBuilder rb{ctx, 2}; - rb.Push(ERR_NOT_SUPPORTED); + rb.Push(Audio::ResultNotSupported); return; } @@ -179,7 +179,7 @@ private: rb.PushCopyObjects(rendered_event->GetReadableEvent()); } - void SetRenderingTimeLimit(Kernel::HLERequestContext& ctx) { + void SetRenderingTimeLimit(HLERequestContext& ctx) { LOG_DEBUG(Service_Audio, "called"); IPC::RequestParser rp{ctx}; @@ -192,7 +192,7 @@ private: rb.Push(ResultSuccess); } - void GetRenderingTimeLimit(Kernel::HLERequestContext& ctx) { + void GetRenderingTimeLimit(HLERequestContext& ctx) { LOG_DEBUG(Service_Audio, "called"); auto& system_ = impl->GetSystem(); @@ -203,11 +203,11 @@ private: rb.Push(time); } - void ExecuteAudioRendererRendering(Kernel::HLERequestContext& ctx) { + void ExecuteAudioRendererRendering(HLERequestContext& ctx) { LOG_DEBUG(Service_Audio, "called"); } - void SetVoiceDropParameter(Kernel::HLERequestContext& ctx) { + void SetVoiceDropParameter(HLERequestContext& ctx) { LOG_DEBUG(Service_Audio, "called"); IPC::RequestParser rp{ctx}; @@ -220,7 +220,7 @@ private: rb.Push(ResultSuccess); } - void GetVoiceDropParameter(Kernel::HLERequestContext& ctx) { + void GetVoiceDropParameter(HLERequestContext& ctx) { LOG_DEBUG(Service_Audio, "called"); auto& system_ = impl->GetSystem(); @@ -271,7 +271,7 @@ public: } private: - void ListAudioDeviceName(Kernel::HLERequestContext& ctx) { + void ListAudioDeviceName(HLERequestContext& ctx) { const size_t in_count = ctx.GetWriteBufferNumElements<AudioDevice::AudioDeviceName>(); std::vector<AudioDevice::AudioDeviceName> out_names{}; @@ -299,7 +299,7 @@ private: rb.Push(out_count); } - void SetAudioDeviceOutputVolume(Kernel::HLERequestContext& ctx) { + void SetAudioDeviceOutputVolume(HLERequestContext& ctx) { IPC::RequestParser rp{ctx}; const f32 volume = rp.Pop<f32>(); @@ -316,7 +316,7 @@ private: rb.Push(ResultSuccess); } - void GetAudioDeviceOutputVolume(Kernel::HLERequestContext& ctx) { + void GetAudioDeviceOutputVolume(HLERequestContext& ctx) { const auto device_name_buffer = ctx.ReadBuffer(); const std::string name = Common::StringFromBuffer(device_name_buffer); @@ -332,7 +332,7 @@ private: rb.Push(volume); } - void GetActiveAudioDeviceName(Kernel::HLERequestContext& ctx) { + void GetActiveAudioDeviceName(HLERequestContext& ctx) { const auto write_size = ctx.GetWriteBufferSize(); std::string out_name{"AudioTvOutput"}; @@ -346,7 +346,7 @@ private: rb.Push(ResultSuccess); } - void QueryAudioDeviceSystemEvent(Kernel::HLERequestContext& ctx) { + void QueryAudioDeviceSystemEvent(HLERequestContext& ctx) { LOG_DEBUG(Service_Audio, "(STUBBED) called"); event->Signal(); @@ -356,7 +356,7 @@ private: rb.PushCopyObjects(event->GetReadableEvent()); } - void GetActiveChannelCount(Kernel::HLERequestContext& ctx) { + void GetActiveChannelCount(HLERequestContext& ctx) { const auto& sink{system.AudioCore().GetOutputSink()}; u32 channel_count{sink.GetDeviceChannels()}; @@ -368,7 +368,7 @@ private: rb.Push<u32>(channel_count); } - void QueryAudioDeviceInputEvent(Kernel::HLERequestContext& ctx) { + void QueryAudioDeviceInputEvent(HLERequestContext& ctx) { LOG_DEBUG(Service_Audio, "(STUBBED) called"); IPC::ResponseBuilder rb{ctx, 2, 1}; @@ -376,7 +376,7 @@ private: rb.PushCopyObjects(event->GetReadableEvent()); } - void QueryAudioDeviceOutputEvent(Kernel::HLERequestContext& ctx) { + void QueryAudioDeviceOutputEvent(HLERequestContext& ctx) { LOG_DEBUG(Service_Audio, "called"); IPC::ResponseBuilder rb{ctx, 2, 1}; @@ -384,7 +384,7 @@ private: rb.PushCopyObjects(event->GetReadableEvent()); } - void ListAudioOutputDeviceName(Kernel::HLERequestContext& ctx) { + void ListAudioOutputDeviceName(HLERequestContext& ctx) { const size_t in_count = ctx.GetWriteBufferNumElements<AudioDevice::AudioDeviceName>(); std::vector<AudioDevice::AudioDeviceName> out_names{}; @@ -435,7 +435,7 @@ AudRenU::AudRenU(Core::System& system_) AudRenU::~AudRenU() = default; -void AudRenU::OpenAudioRenderer(Kernel::HLERequestContext& ctx) { +void AudRenU::OpenAudioRenderer(HLERequestContext& ctx) { IPC::RequestParser rp{ctx}; AudioCore::AudioRendererParameterInternal params; @@ -448,7 +448,7 @@ void AudRenU::OpenAudioRenderer(Kernel::HLERequestContext& ctx) { if (impl->GetSessionCount() + 1 > AudioCore::MaxRendererSessions) { LOG_ERROR(Service_Audio, "Too many AudioRenderer sessions open!"); IPC::ResponseBuilder rb{ctx, 2}; - rb.Push(ERR_MAXIMUM_SESSIONS_REACHED); + rb.Push(Audio::ResultOutOfSessions); return; } @@ -461,7 +461,7 @@ void AudRenU::OpenAudioRenderer(Kernel::HLERequestContext& ctx) { if (session_id == -1) { LOG_ERROR(Service_Audio, "Tried to open a session that's already in use!"); IPC::ResponseBuilder rb{ctx, 2}; - rb.Push(ERR_MAXIMUM_SESSIONS_REACHED); + rb.Push(Audio::ResultOutOfSessions); return; } @@ -475,7 +475,7 @@ void AudRenU::OpenAudioRenderer(Kernel::HLERequestContext& ctx) { applet_resource_user_id, session_id); } -void AudRenU::GetWorkBufferSize(Kernel::HLERequestContext& ctx) { +void AudRenU::GetWorkBufferSize(HLERequestContext& ctx) { AudioCore::AudioRendererParameterInternal params; IPC::RequestParser rp{ctx}; @@ -506,7 +506,7 @@ void AudRenU::GetWorkBufferSize(Kernel::HLERequestContext& ctx) { rb.Push<u64>(size); } -void AudRenU::GetAudioDeviceService(Kernel::HLERequestContext& ctx) { +void AudRenU::GetAudioDeviceService(HLERequestContext& ctx) { IPC::RequestParser rp{ctx}; const auto applet_resource_user_id = rp.Pop<u64>(); @@ -520,11 +520,11 @@ void AudRenU::GetAudioDeviceService(Kernel::HLERequestContext& ctx) { ::Common::MakeMagic('R', 'E', 'V', '1'), num_audio_devices++); } -void AudRenU::OpenAudioRendererForManualExecution(Kernel::HLERequestContext& ctx) { +void AudRenU::OpenAudioRendererForManualExecution(HLERequestContext& ctx) { LOG_DEBUG(Service_Audio, "called"); } -void AudRenU::GetAudioDeviceServiceWithRevisionInfo(Kernel::HLERequestContext& ctx) { +void AudRenU::GetAudioDeviceServiceWithRevisionInfo(HLERequestContext& ctx) { struct Parameters { u32 revision; u64 applet_resource_user_id; diff --git a/src/core/hle/service/audio/audren_u.h b/src/core/hle/service/audio/audren_u.h index 4384a9b3c..24ce37e87 100644 --- a/src/core/hle/service/audio/audren_u.h +++ b/src/core/hle/service/audio/audren_u.h @@ -11,10 +11,6 @@ namespace Core { class System; } -namespace Kernel { -class HLERequestContext; -} - namespace Service::Audio { class IAudioRenderer; @@ -24,11 +20,11 @@ public: ~AudRenU() override; private: - void OpenAudioRenderer(Kernel::HLERequestContext& ctx); - void GetWorkBufferSize(Kernel::HLERequestContext& ctx); - void GetAudioDeviceService(Kernel::HLERequestContext& ctx); - void OpenAudioRendererForManualExecution(Kernel::HLERequestContext& ctx); - void GetAudioDeviceServiceWithRevisionInfo(Kernel::HLERequestContext& ctx); + void OpenAudioRenderer(HLERequestContext& ctx); + void GetWorkBufferSize(HLERequestContext& ctx); + void GetAudioDeviceService(HLERequestContext& ctx); + void OpenAudioRendererForManualExecution(HLERequestContext& ctx); + void GetAudioDeviceServiceWithRevisionInfo(HLERequestContext& ctx); KernelHelpers::ServiceContext service_context; std::unique_ptr<AudioCore::AudioRenderer::Manager> impl; diff --git a/src/core/hle/service/audio/errors.h b/src/core/hle/service/audio/errors.h index d706978cb..3d3d3d97a 100644 --- a/src/core/hle/service/audio/errors.h +++ b/src/core/hle/service/audio/errors.h @@ -7,17 +7,17 @@ namespace Service::Audio { -constexpr Result ERR_INVALID_DEVICE_NAME{ErrorModule::Audio, 1}; -constexpr Result ERR_OPERATION_FAILED{ErrorModule::Audio, 2}; -constexpr Result ERR_INVALID_SAMPLE_RATE{ErrorModule::Audio, 3}; -constexpr Result ERR_INSUFFICIENT_BUFFER_SIZE{ErrorModule::Audio, 4}; -constexpr Result ERR_MAXIMUM_SESSIONS_REACHED{ErrorModule::Audio, 5}; -constexpr Result ERR_BUFFER_COUNT_EXCEEDED{ErrorModule::Audio, 8}; -constexpr Result ERR_INVALID_CHANNEL_COUNT{ErrorModule::Audio, 10}; -constexpr Result ERR_INVALID_UPDATE_DATA{ErrorModule::Audio, 41}; -constexpr Result ERR_POOL_MAPPING_FAILED{ErrorModule::Audio, 42}; -constexpr Result ERR_NOT_SUPPORTED{ErrorModule::Audio, 513}; -constexpr Result ERR_INVALID_PROCESS_HANDLE{ErrorModule::Audio, 1536}; -constexpr Result ERR_INVALID_REVISION{ErrorModule::Audio, 1537}; +constexpr Result ResultNotFound{ErrorModule::Audio, 1}; +constexpr Result ResultOperationFailed{ErrorModule::Audio, 2}; +constexpr Result ResultInvalidSampleRate{ErrorModule::Audio, 3}; +constexpr Result ResultInsufficientBuffer{ErrorModule::Audio, 4}; +constexpr Result ResultOutOfSessions{ErrorModule::Audio, 5}; +constexpr Result ResultBufferCountReached{ErrorModule::Audio, 8}; +constexpr Result ResultInvalidChannelCount{ErrorModule::Audio, 10}; +constexpr Result ResultInvalidUpdateInfo{ErrorModule::Audio, 41}; +constexpr Result ResultInvalidAddressInfo{ErrorModule::Audio, 42}; +constexpr Result ResultNotSupported{ErrorModule::Audio, 513}; +constexpr Result ResultInvalidHandle{ErrorModule::Audio, 1536}; +constexpr Result ResultInvalidRevision{ErrorModule::Audio, 1537}; } // namespace Service::Audio diff --git a/src/core/hle/service/audio/hwopus.cpp b/src/core/hle/service/audio/hwopus.cpp index 3db3fe188..451ac224a 100644 --- a/src/core/hle/service/audio/hwopus.cpp +++ b/src/core/hle/service/audio/hwopus.cpp @@ -11,8 +11,8 @@ #include "common/assert.h" #include "common/logging/log.h" -#include "core/hle/ipc_helpers.h" #include "core/hle/service/audio/hwopus.h" +#include "core/hle/service/ipc_helpers.h" namespace Service::Audio { namespace { @@ -53,7 +53,7 @@ public: // Decodes interleaved Opus packets. Optionally allows reporting time taken to // perform the decoding, as well as any relevant extra behavior. - void DecodeInterleaved(Kernel::HLERequestContext& ctx, PerfTime perf_time, + void DecodeInterleaved(HLERequestContext& ctx, PerfTime perf_time, ExtraBehavior extra_behavior) { if (perf_time == PerfTime::Disabled) { DecodeInterleavedHelper(ctx, nullptr, extra_behavior); @@ -64,7 +64,7 @@ public: } private: - void DecodeInterleavedHelper(Kernel::HLERequestContext& ctx, u64* performance, + void DecodeInterleavedHelper(HLERequestContext& ctx, u64* performance, ExtraBehavior extra_behavior) { u32 consumed = 0; u32 sample_count = 0; @@ -180,21 +180,21 @@ public: } private: - void DecodeInterleavedOld(Kernel::HLERequestContext& ctx) { + void DecodeInterleavedOld(HLERequestContext& ctx) { LOG_DEBUG(Audio, "called"); decoder_state.DecodeInterleaved(ctx, OpusDecoderState::PerfTime::Disabled, OpusDecoderState::ExtraBehavior::None); } - void DecodeInterleavedWithPerfOld(Kernel::HLERequestContext& ctx) { + void DecodeInterleavedWithPerfOld(HLERequestContext& ctx) { LOG_DEBUG(Audio, "called"); decoder_state.DecodeInterleaved(ctx, OpusDecoderState::PerfTime::Enabled, OpusDecoderState::ExtraBehavior::None); } - void DecodeInterleaved(Kernel::HLERequestContext& ctx) { + void DecodeInterleaved(HLERequestContext& ctx) { LOG_DEBUG(Audio, "called"); IPC::RequestParser rp{ctx}; @@ -231,7 +231,7 @@ std::array<u8, 2> CreateMappingTable(u32 channel_count) { } } // Anonymous namespace -void HwOpus::GetWorkBufferSize(Kernel::HLERequestContext& ctx) { +void HwOpus::GetWorkBufferSize(HLERequestContext& ctx) { IPC::RequestParser rp{ctx}; const auto sample_rate = rp.Pop<u32>(); const auto channel_count = rp.Pop<u32>(); @@ -251,11 +251,11 @@ void HwOpus::GetWorkBufferSize(Kernel::HLERequestContext& ctx) { rb.Push<u32>(worker_buffer_sz); } -void HwOpus::GetWorkBufferSizeEx(Kernel::HLERequestContext& ctx) { +void HwOpus::GetWorkBufferSizeEx(HLERequestContext& ctx) { GetWorkBufferSize(ctx); } -void HwOpus::GetWorkBufferSizeForMultiStreamEx(Kernel::HLERequestContext& ctx) { +void HwOpus::GetWorkBufferSizeForMultiStreamEx(HLERequestContext& ctx) { OpusMultiStreamParametersEx param; std::memcpy(¶m, ctx.ReadBuffer().data(), ctx.GetReadBufferSize()); @@ -281,7 +281,7 @@ void HwOpus::GetWorkBufferSizeForMultiStreamEx(Kernel::HLERequestContext& ctx) { rb.Push<u32>(worker_buffer_sz); } -void HwOpus::OpenHardwareOpusDecoder(Kernel::HLERequestContext& ctx) { +void HwOpus::OpenHardwareOpusDecoder(HLERequestContext& ctx) { IPC::RequestParser rp{ctx}; const auto sample_rate = rp.Pop<u32>(); const auto channel_count = rp.Pop<u32>(); @@ -319,7 +319,7 @@ void HwOpus::OpenHardwareOpusDecoder(Kernel::HLERequestContext& ctx) { system, OpusDecoderState{std::move(decoder), sample_rate, channel_count}); } -void HwOpus::OpenHardwareOpusDecoderEx(Kernel::HLERequestContext& ctx) { +void HwOpus::OpenHardwareOpusDecoderEx(HLERequestContext& ctx) { IPC::RequestParser rp{ctx}; const auto sample_rate = rp.Pop<u32>(); const auto channel_count = rp.Pop<u32>(); diff --git a/src/core/hle/service/audio/hwopus.h b/src/core/hle/service/audio/hwopus.h index e6092e290..ece65c02c 100644 --- a/src/core/hle/service/audio/hwopus.h +++ b/src/core/hle/service/audio/hwopus.h @@ -27,11 +27,11 @@ public: ~HwOpus() override; private: - void OpenHardwareOpusDecoder(Kernel::HLERequestContext& ctx); - void OpenHardwareOpusDecoderEx(Kernel::HLERequestContext& ctx); - void GetWorkBufferSize(Kernel::HLERequestContext& ctx); - void GetWorkBufferSizeEx(Kernel::HLERequestContext& ctx); - void GetWorkBufferSizeForMultiStreamEx(Kernel::HLERequestContext& ctx); + void OpenHardwareOpusDecoder(HLERequestContext& ctx); + void OpenHardwareOpusDecoderEx(HLERequestContext& ctx); + void GetWorkBufferSize(HLERequestContext& ctx); + void GetWorkBufferSizeEx(HLERequestContext& ctx); + void GetWorkBufferSizeForMultiStreamEx(HLERequestContext& ctx); }; } // namespace Service::Audio diff --git a/src/core/hle/service/bcat/bcat_module.cpp b/src/core/hle/service/bcat/bcat_module.cpp index 1db3f026b..a6281913a 100644 --- a/src/core/hle/service/bcat/bcat_module.cpp +++ b/src/core/hle/service/bcat/bcat_module.cpp @@ -9,12 +9,12 @@ #include "common/string_util.h" #include "core/core.h" #include "core/file_sys/vfs.h" -#include "core/hle/ipc_helpers.h" #include "core/hle/kernel/k_readable_event.h" #include "core/hle/service/bcat/backend/backend.h" #include "core/hle/service/bcat/bcat.h" #include "core/hle/service/bcat/bcat_module.h" #include "core/hle/service/filesystem/filesystem.h" +#include "core/hle/service/ipc_helpers.h" #include "core/hle/service/server_manager.h" namespace Service::BCAT { @@ -51,8 +51,7 @@ BCATDigest DigestFile(const FileSys::VirtualFile& file) { // For a name to be valid it must be non-empty, must have a null terminating character as the final // char, can only contain numbers, letters, underscores and a hyphen if directory and a period if // file. -bool VerifyNameValidInternal(Kernel::HLERequestContext& ctx, std::array<char, 0x20> name, - char match_char) { +bool VerifyNameValidInternal(HLERequestContext& ctx, std::array<char, 0x20> name, char match_char) { const auto null_chars = std::count(name.begin(), name.end(), 0); const auto bad_chars = std::count_if(name.begin(), name.end(), [match_char](char c) { return !std::isalnum(static_cast<u8>(c)) && c != '_' && c != match_char && c != '\0'; @@ -67,11 +66,11 @@ bool VerifyNameValidInternal(Kernel::HLERequestContext& ctx, std::array<char, 0x return true; } -bool VerifyNameValidDir(Kernel::HLERequestContext& ctx, DirectoryName name) { +bool VerifyNameValidDir(HLERequestContext& ctx, DirectoryName name) { return VerifyNameValidInternal(ctx, name, '-'); } -bool VerifyNameValidFile(Kernel::HLERequestContext& ctx, FileName name) { +bool VerifyNameValidFile(HLERequestContext& ctx, FileName name) { return VerifyNameValidInternal(ctx, name, '.'); } @@ -99,7 +98,7 @@ public: } private: - void GetEvent(Kernel::HLERequestContext& ctx) { + void GetEvent(HLERequestContext& ctx) { LOG_DEBUG(Service_BCAT, "called"); IPC::ResponseBuilder rb{ctx, 2, 1}; @@ -107,7 +106,7 @@ private: rb.PushCopyObjects(event); } - void GetImpl(Kernel::HLERequestContext& ctx) { + void GetImpl(HLERequestContext& ctx) { LOG_DEBUG(Service_BCAT, "called"); ctx.WriteBuffer(impl); @@ -174,7 +173,7 @@ private: progress_backend.GetImpl()); } - void RequestSyncDeliveryCache(Kernel::HLERequestContext& ctx) { + void RequestSyncDeliveryCache(HLERequestContext& ctx) { LOG_DEBUG(Service_BCAT, "called"); backend.Synchronize({system.GetApplicationProcessProgramID(), @@ -186,7 +185,7 @@ private: rb.PushIpcInterface(CreateProgressService(SyncType::Normal)); } - void RequestSyncDeliveryCacheWithDirectoryName(Kernel::HLERequestContext& ctx) { + void RequestSyncDeliveryCacheWithDirectoryName(HLERequestContext& ctx) { IPC::RequestParser rp{ctx}; const auto name_raw = rp.PopRaw<DirectoryName>(); const auto name = @@ -203,7 +202,7 @@ private: rb.PushIpcInterface(CreateProgressService(SyncType::Directory)); } - void SetPassphrase(Kernel::HLERequestContext& ctx) { + void SetPassphrase(HLERequestContext& ctx) { IPC::RequestParser rp{ctx}; const auto title_id = rp.PopRaw<u64>(); @@ -235,7 +234,7 @@ private: rb.Push(ResultSuccess); } - void ClearDeliveryCacheStorage(Kernel::HLERequestContext& ctx) { + void ClearDeliveryCacheStorage(HLERequestContext& ctx) { IPC::RequestParser rp{ctx}; const auto title_id = rp.PopRaw<u64>(); @@ -271,7 +270,7 @@ private: std::array<ProgressServiceBackend, static_cast<size_t>(SyncType::Count)> progress; }; -void Module::Interface::CreateBcatService(Kernel::HLERequestContext& ctx) { +void Module::Interface::CreateBcatService(HLERequestContext& ctx) { LOG_DEBUG(Service_BCAT, "called"); IPC::ResponseBuilder rb{ctx, 2, 0, 1}; @@ -296,7 +295,7 @@ public: } private: - void Open(Kernel::HLERequestContext& ctx) { + void Open(HLERequestContext& ctx) { IPC::RequestParser rp{ctx}; const auto dir_name_raw = rp.PopRaw<DirectoryName>(); const auto file_name_raw = rp.PopRaw<FileName>(); @@ -340,7 +339,7 @@ private: rb.Push(ResultSuccess); } - void Read(Kernel::HLERequestContext& ctx) { + void Read(HLERequestContext& ctx) { IPC::RequestParser rp{ctx}; const auto offset{rp.PopRaw<u64>()}; @@ -363,7 +362,7 @@ private: rb.Push<u64>(buffer.size()); } - void GetSize(Kernel::HLERequestContext& ctx) { + void GetSize(HLERequestContext& ctx) { LOG_DEBUG(Service_BCAT, "called"); if (current_file == nullptr) { @@ -377,7 +376,7 @@ private: rb.Push<u64>(current_file->GetSize()); } - void GetDigest(Kernel::HLERequestContext& ctx) { + void GetDigest(HLERequestContext& ctx) { LOG_DEBUG(Service_BCAT, "called"); if (current_file == nullptr) { @@ -412,7 +411,7 @@ public: } private: - void Open(Kernel::HLERequestContext& ctx) { + void Open(HLERequestContext& ctx) { IPC::RequestParser rp{ctx}; const auto name_raw = rp.PopRaw<DirectoryName>(); const auto name = @@ -443,7 +442,7 @@ private: rb.Push(ResultSuccess); } - void Read(Kernel::HLERequestContext& ctx) { + void Read(HLERequestContext& ctx) { auto write_size = ctx.GetWriteBufferNumElements<DeliveryCacheDirectoryEntry>(); LOG_DEBUG(Service_BCAT, "called, write_size={:016X}", write_size); @@ -473,7 +472,7 @@ private: rb.Push(static_cast<u32>(write_size * sizeof(DeliveryCacheDirectoryEntry))); } - void GetCount(Kernel::HLERequestContext& ctx) { + void GetCount(HLERequestContext& ctx) { LOG_DEBUG(Service_BCAT, "called"); if (current_dir == nullptr) { @@ -517,7 +516,7 @@ public: } private: - void CreateFileService(Kernel::HLERequestContext& ctx) { + void CreateFileService(HLERequestContext& ctx) { LOG_DEBUG(Service_BCAT, "called"); IPC::ResponseBuilder rb{ctx, 2, 0, 1}; @@ -525,7 +524,7 @@ private: rb.PushIpcInterface<IDeliveryCacheFileService>(system, root); } - void CreateDirectoryService(Kernel::HLERequestContext& ctx) { + void CreateDirectoryService(HLERequestContext& ctx) { LOG_DEBUG(Service_BCAT, "called"); IPC::ResponseBuilder rb{ctx, 2, 0, 1}; @@ -533,7 +532,7 @@ private: rb.PushIpcInterface<IDeliveryCacheDirectoryService>(system, root); } - void EnumerateDeliveryCacheDirectory(Kernel::HLERequestContext& ctx) { + void EnumerateDeliveryCacheDirectory(HLERequestContext& ctx) { auto size = ctx.GetWriteBufferNumElements<DirectoryName>(); LOG_DEBUG(Service_BCAT, "called, size={:016X}", size); @@ -552,7 +551,7 @@ private: u64 next_read_index = 0; }; -void Module::Interface::CreateDeliveryCacheStorageService(Kernel::HLERequestContext& ctx) { +void Module::Interface::CreateDeliveryCacheStorageService(HLERequestContext& ctx) { LOG_DEBUG(Service_BCAT, "called"); const auto title_id = system.GetApplicationProcessProgramID(); @@ -561,8 +560,7 @@ void Module::Interface::CreateDeliveryCacheStorageService(Kernel::HLERequestCont rb.PushIpcInterface<IDeliveryCacheStorageService>(system, fsc.GetBCATDirectory(title_id)); } -void Module::Interface::CreateDeliveryCacheStorageServiceWithApplicationId( - Kernel::HLERequestContext& ctx) { +void Module::Interface::CreateDeliveryCacheStorageServiceWithApplicationId(HLERequestContext& ctx) { IPC::RequestParser rp{ctx}; const auto title_id = rp.PopRaw<u64>(); diff --git a/src/core/hle/service/bcat/bcat_module.h b/src/core/hle/service/bcat/bcat_module.h index 0c134d1ff..87576288b 100644 --- a/src/core/hle/service/bcat/bcat_module.h +++ b/src/core/hle/service/bcat/bcat_module.h @@ -27,9 +27,9 @@ public: FileSystem::FileSystemController& fsc_, const char* name); ~Interface() override; - void CreateBcatService(Kernel::HLERequestContext& ctx); - void CreateDeliveryCacheStorageService(Kernel::HLERequestContext& ctx); - void CreateDeliveryCacheStorageServiceWithApplicationId(Kernel::HLERequestContext& ctx); + void CreateBcatService(HLERequestContext& ctx); + void CreateDeliveryCacheStorageService(HLERequestContext& ctx); + void CreateDeliveryCacheStorageServiceWithApplicationId(HLERequestContext& ctx); protected: FileSystem::FileSystemController& fsc; diff --git a/src/core/hle/service/btdrv/btdrv.cpp b/src/core/hle/service/btdrv/btdrv.cpp index ed020d03f..38cdd57ad 100644 --- a/src/core/hle/service/btdrv/btdrv.cpp +++ b/src/core/hle/service/btdrv/btdrv.cpp @@ -3,9 +3,9 @@ #include "common/logging/log.h" #include "core/core.h" -#include "core/hle/ipc_helpers.h" #include "core/hle/kernel/k_event.h" #include "core/hle/service/btdrv/btdrv.h" +#include "core/hle/service/ipc_helpers.h" #include "core/hle/service/kernel_helpers.h" #include "core/hle/service/server_manager.h" #include "core/hle/service/service.h" @@ -41,7 +41,7 @@ public: } private: - void RegisterBleEvent(Kernel::HLERequestContext& ctx) { + void RegisterBleEvent(HLERequestContext& ctx) { LOG_WARNING(Service_BTM, "(STUBBED) called"); IPC::ResponseBuilder rb{ctx, 2, 1}; diff --git a/src/core/hle/service/btm/btm.cpp b/src/core/hle/service/btm/btm.cpp index dbd9d6a88..8069f75b7 100644 --- a/src/core/hle/service/btm/btm.cpp +++ b/src/core/hle/service/btm/btm.cpp @@ -5,9 +5,9 @@ #include "common/logging/log.h" #include "core/core.h" -#include "core/hle/ipc_helpers.h" #include "core/hle/kernel/k_event.h" #include "core/hle/service/btm/btm.h" +#include "core/hle/service/ipc_helpers.h" #include "core/hle/service/kernel_helpers.h" #include "core/hle/service/server_manager.h" #include "core/hle/service/service.h" @@ -70,7 +70,7 @@ public: } private: - void AcquireBleScanEvent(Kernel::HLERequestContext& ctx) { + void AcquireBleScanEvent(HLERequestContext& ctx) { LOG_WARNING(Service_BTM, "(STUBBED) called"); IPC::ResponseBuilder rb{ctx, 3, 1}; @@ -79,7 +79,7 @@ private: rb.PushCopyObjects(scan_event->GetReadableEvent()); } - void AcquireBleConnectionEvent(Kernel::HLERequestContext& ctx) { + void AcquireBleConnectionEvent(HLERequestContext& ctx) { LOG_WARNING(Service_BTM, "(STUBBED) called"); IPC::ResponseBuilder rb{ctx, 3, 1}; @@ -88,7 +88,7 @@ private: rb.PushCopyObjects(connection_event->GetReadableEvent()); } - void AcquireBleServiceDiscoveryEvent(Kernel::HLERequestContext& ctx) { + void AcquireBleServiceDiscoveryEvent(HLERequestContext& ctx) { LOG_WARNING(Service_BTM, "(STUBBED) called"); IPC::ResponseBuilder rb{ctx, 3, 1}; @@ -97,7 +97,7 @@ private: rb.PushCopyObjects(service_discovery_event->GetReadableEvent()); } - void AcquireBleMtuConfigEvent(Kernel::HLERequestContext& ctx) { + void AcquireBleMtuConfigEvent(HLERequestContext& ctx) { LOG_WARNING(Service_BTM, "(STUBBED) called"); IPC::ResponseBuilder rb{ctx, 3, 1}; @@ -126,7 +126,7 @@ public: } private: - void GetCore(Kernel::HLERequestContext& ctx) { + void GetCore(HLERequestContext& ctx) { LOG_DEBUG(Service_BTM, "called"); IPC::ResponseBuilder rb{ctx, 2, 0, 1}; @@ -307,7 +307,7 @@ public: } private: - void GetCore(Kernel::HLERequestContext& ctx) { + void GetCore(HLERequestContext& ctx) { LOG_DEBUG(Service_BTM, "called"); IPC::ResponseBuilder rb{ctx, 2, 0, 1}; diff --git a/src/core/hle/service/caps/caps_a.h b/src/core/hle/service/caps/caps_a.h index 319c173d8..98a21a5ad 100644 --- a/src/core/hle/service/caps/caps_a.h +++ b/src/core/hle/service/caps/caps_a.h @@ -9,10 +9,6 @@ namespace Core { class System; } -namespace Kernel { -class HLERequestContext; -} - namespace Service::Capture { class CAPS_A final : public ServiceFramework<CAPS_A> { diff --git a/src/core/hle/service/caps/caps_c.cpp b/src/core/hle/service/caps/caps_c.cpp index 725a2e3a7..fc77e35cd 100644 --- a/src/core/hle/service/caps/caps_c.cpp +++ b/src/core/hle/service/caps/caps_c.cpp @@ -2,8 +2,8 @@ // SPDX-License-Identifier: GPL-2.0-or-later #include "common/logging/log.h" -#include "core/hle/ipc_helpers.h" #include "core/hle/service/caps/caps_c.h" +#include "core/hle/service/ipc_helpers.h" namespace Service::Capture { @@ -74,7 +74,7 @@ CAPS_C::CAPS_C(Core::System& system_) : ServiceFramework{system_, "caps:c"} { CAPS_C::~CAPS_C() = default; -void CAPS_C::SetShimLibraryVersion(Kernel::HLERequestContext& ctx) { +void CAPS_C::SetShimLibraryVersion(HLERequestContext& ctx) { IPC::RequestParser rp{ctx}; const auto library_version{rp.Pop<u64>()}; const auto applet_resource_user_id{rp.Pop<u64>()}; diff --git a/src/core/hle/service/caps/caps_c.h b/src/core/hle/service/caps/caps_c.h index 983a4212d..537b3a2e3 100644 --- a/src/core/hle/service/caps/caps_c.h +++ b/src/core/hle/service/caps/caps_c.h @@ -9,10 +9,6 @@ namespace Core { class System; } -namespace Kernel { -class HLERequestContext; -} - namespace Service::Capture { class CAPS_C final : public ServiceFramework<CAPS_C> { @@ -21,7 +17,7 @@ public: ~CAPS_C() override; private: - void SetShimLibraryVersion(Kernel::HLERequestContext& ctx); + void SetShimLibraryVersion(HLERequestContext& ctx); }; } // namespace Service::Capture diff --git a/src/core/hle/service/caps/caps_su.cpp b/src/core/hle/service/caps/caps_su.cpp index fcb496756..3b11cc95c 100644 --- a/src/core/hle/service/caps/caps_su.cpp +++ b/src/core/hle/service/caps/caps_su.cpp @@ -2,8 +2,8 @@ // SPDX-License-Identifier: GPL-2.0-or-later #include "common/logging/log.h" -#include "core/hle/ipc_helpers.h" #include "core/hle/service/caps/caps_su.h" +#include "core/hle/service/ipc_helpers.h" namespace Service::Capture { @@ -23,7 +23,7 @@ CAPS_SU::CAPS_SU(Core::System& system_) : ServiceFramework{system_, "caps:su"} { CAPS_SU::~CAPS_SU() = default; -void CAPS_SU::SetShimLibraryVersion(Kernel::HLERequestContext& ctx) { +void CAPS_SU::SetShimLibraryVersion(HLERequestContext& ctx) { IPC::RequestParser rp{ctx}; const auto library_version{rp.Pop<u64>()}; const auto applet_resource_user_id{rp.Pop<u64>()}; diff --git a/src/core/hle/service/caps/caps_su.h b/src/core/hle/service/caps/caps_su.h index c9a1d507b..c6398858d 100644 --- a/src/core/hle/service/caps/caps_su.h +++ b/src/core/hle/service/caps/caps_su.h @@ -9,10 +9,6 @@ namespace Core { class System; } -namespace Kernel { -class HLERequestContext; -} - namespace Service::Capture { class CAPS_SU final : public ServiceFramework<CAPS_SU> { @@ -21,7 +17,7 @@ public: ~CAPS_SU() override; private: - void SetShimLibraryVersion(Kernel::HLERequestContext& ctx); + void SetShimLibraryVersion(HLERequestContext& ctx); }; } // namespace Service::Capture diff --git a/src/core/hle/service/caps/caps_u.cpp b/src/core/hle/service/caps/caps_u.cpp index 5fbba8673..bffe0f8d0 100644 --- a/src/core/hle/service/caps/caps_u.cpp +++ b/src/core/hle/service/caps/caps_u.cpp @@ -2,9 +2,9 @@ // SPDX-License-Identifier: GPL-2.0-or-later #include "common/logging/log.h" -#include "core/hle/ipc_helpers.h" #include "core/hle/service/caps/caps.h" #include "core/hle/service/caps/caps_u.h" +#include "core/hle/service/ipc_helpers.h" namespace Service::Capture { @@ -52,7 +52,7 @@ CAPS_U::CAPS_U(Core::System& system_) : ServiceFramework{system_, "caps:u"} { CAPS_U::~CAPS_U() = default; -void CAPS_U::SetShimLibraryVersion(Kernel::HLERequestContext& ctx) { +void CAPS_U::SetShimLibraryVersion(HLERequestContext& ctx) { IPC::RequestParser rp{ctx}; const auto library_version{rp.Pop<u64>()}; const auto applet_resource_user_id{rp.Pop<u64>()}; @@ -64,7 +64,7 @@ void CAPS_U::SetShimLibraryVersion(Kernel::HLERequestContext& ctx) { rb.Push(ResultSuccess); } -void CAPS_U::GetAlbumContentsFileListForApplication(Kernel::HLERequestContext& ctx) { +void CAPS_U::GetAlbumContentsFileListForApplication(HLERequestContext& ctx) { // Takes a type-0x6 output buffer containing an array of ApplicationAlbumFileEntry, a PID, an // u8 ContentType, two s64s, and an u64 AppletResourceUserId. Returns an output u64 for total // output entries (which is copied to a s32 by official SW). @@ -93,7 +93,7 @@ void CAPS_U::GetAlbumContentsFileListForApplication(Kernel::HLERequestContext& c rb.Push(total_entries_2); } -void CAPS_U::GetAlbumFileList3AaeAruid(Kernel::HLERequestContext& ctx) { +void CAPS_U::GetAlbumFileList3AaeAruid(HLERequestContext& ctx) { GetAlbumContentsFileListForApplication(ctx); } diff --git a/src/core/hle/service/caps/caps_u.h b/src/core/hle/service/caps/caps_u.h index c3d4b9cea..e8dd037d7 100644 --- a/src/core/hle/service/caps/caps_u.h +++ b/src/core/hle/service/caps/caps_u.h @@ -9,10 +9,6 @@ namespace Core { class System; } -namespace Kernel { -class HLERequestContext; -} - namespace Service::Capture { class CAPS_U final : public ServiceFramework<CAPS_U> { @@ -21,9 +17,9 @@ public: ~CAPS_U() override; private: - void SetShimLibraryVersion(Kernel::HLERequestContext& ctx); - void GetAlbumContentsFileListForApplication(Kernel::HLERequestContext& ctx); - void GetAlbumFileList3AaeAruid(Kernel::HLERequestContext& ctx); + void SetShimLibraryVersion(HLERequestContext& ctx); + void GetAlbumContentsFileListForApplication(HLERequestContext& ctx); + void GetAlbumFileList3AaeAruid(HLERequestContext& ctx); }; } // namespace Service::Capture diff --git a/src/core/hle/service/es/es.cpp b/src/core/hle/service/es/es.cpp index d9736af4e..446f46b3c 100644 --- a/src/core/hle/service/es/es.cpp +++ b/src/core/hle/service/es/es.cpp @@ -2,8 +2,8 @@ // SPDX-License-Identifier: GPL-2.0-or-later #include "core/crypto/key_manager.h" -#include "core/hle/ipc_helpers.h" #include "core/hle/service/es/es.h" +#include "core/hle/service/ipc_helpers.h" #include "core/hle/service/server_manager.h" #include "core/hle/service/service.h" @@ -110,7 +110,7 @@ public: } private: - bool CheckRightsId(Kernel::HLERequestContext& ctx, const u128& rights_id) { + bool CheckRightsId(HLERequestContext& ctx, const u128& rights_id) { if (rights_id == u128{}) { LOG_ERROR(Service_ETicket, "The rights ID was invalid!"); IPC::ResponseBuilder rb{ctx, 2}; @@ -121,7 +121,7 @@ private: return true; } - void ImportTicket(Kernel::HLERequestContext& ctx) { + void ImportTicket(HLERequestContext& ctx) { const auto ticket = ctx.ReadBuffer(); [[maybe_unused]] const auto cert = ctx.ReadBuffer(1); @@ -146,7 +146,7 @@ private: rb.Push(ResultSuccess); } - void GetTitleKey(Kernel::HLERequestContext& ctx) { + void GetTitleKey(HLERequestContext& ctx) { IPC::RequestParser rp{ctx}; const auto rights_id = rp.PopRaw<u128>(); @@ -172,7 +172,7 @@ private: rb.Push(ResultSuccess); } - void CountCommonTicket(Kernel::HLERequestContext& ctx) { + void CountCommonTicket(HLERequestContext& ctx) { LOG_DEBUG(Service_ETicket, "called"); const u32 count = static_cast<u32>(keys.GetCommonTickets().size()); @@ -182,7 +182,7 @@ private: rb.Push<u32>(count); } - void CountPersonalizedTicket(Kernel::HLERequestContext& ctx) { + void CountPersonalizedTicket(HLERequestContext& ctx) { LOG_DEBUG(Service_ETicket, "called"); const u32 count = static_cast<u32>(keys.GetPersonalizedTickets().size()); @@ -192,7 +192,7 @@ private: rb.Push<u32>(count); } - void ListCommonTicketRightsIds(Kernel::HLERequestContext& ctx) { + void ListCommonTicketRightsIds(HLERequestContext& ctx) { size_t out_entries = 0; if (!keys.GetCommonTickets().empty()) { out_entries = ctx.GetWriteBufferNumElements<u128>(); @@ -213,7 +213,7 @@ private: rb.Push<u32>(static_cast<u32>(out_entries)); } - void ListPersonalizedTicketRightsIds(Kernel::HLERequestContext& ctx) { + void ListPersonalizedTicketRightsIds(HLERequestContext& ctx) { size_t out_entries = 0; if (!keys.GetPersonalizedTickets().empty()) { out_entries = ctx.GetWriteBufferNumElements<u128>(); @@ -235,7 +235,7 @@ private: rb.Push<u32>(static_cast<u32>(out_entries)); } - void GetCommonTicketSize(Kernel::HLERequestContext& ctx) { + void GetCommonTicketSize(HLERequestContext& ctx) { IPC::RequestParser rp{ctx}; const auto rights_id = rp.PopRaw<u128>(); @@ -251,7 +251,7 @@ private: rb.Push<u64>(ticket.GetSize()); } - void GetPersonalizedTicketSize(Kernel::HLERequestContext& ctx) { + void GetPersonalizedTicketSize(HLERequestContext& ctx) { IPC::RequestParser rp{ctx}; const auto rights_id = rp.PopRaw<u128>(); @@ -267,7 +267,7 @@ private: rb.Push<u64>(ticket.GetSize()); } - void GetCommonTicketData(Kernel::HLERequestContext& ctx) { + void GetCommonTicketData(HLERequestContext& ctx) { IPC::RequestParser rp{ctx}; const auto rights_id = rp.PopRaw<u128>(); @@ -286,7 +286,7 @@ private: rb.Push<u64>(write_size); } - void GetPersonalizedTicketData(Kernel::HLERequestContext& ctx) { + void GetPersonalizedTicketData(HLERequestContext& ctx) { IPC::RequestParser rp{ctx}; const auto rights_id = rp.PopRaw<u128>(); diff --git a/src/core/hle/service/fatal/fatal.cpp b/src/core/hle/service/fatal/fatal.cpp index 3b7b636f3..fe2ed8df8 100644 --- a/src/core/hle/service/fatal/fatal.cpp +++ b/src/core/hle/service/fatal/fatal.cpp @@ -9,10 +9,10 @@ #include "common/scm_rev.h" #include "common/swap.h" #include "core/core.h" -#include "core/hle/ipc_helpers.h" #include "core/hle/service/fatal/fatal.h" #include "core/hle/service/fatal/fatal_p.h" #include "core/hle/service/fatal/fatal_u.h" +#include "core/hle/service/ipc_helpers.h" #include "core/hle/service/server_manager.h" #include "core/reporter.h" @@ -126,7 +126,7 @@ static void ThrowFatalError(Core::System& system, Result error_code, FatalType f } } -void Module::Interface::ThrowFatal(Kernel::HLERequestContext& ctx) { +void Module::Interface::ThrowFatal(HLERequestContext& ctx) { LOG_ERROR(Service_Fatal, "called"); IPC::RequestParser rp{ctx}; const auto error_code = rp.Pop<Result>(); @@ -136,7 +136,7 @@ void Module::Interface::ThrowFatal(Kernel::HLERequestContext& ctx) { rb.Push(ResultSuccess); } -void Module::Interface::ThrowFatalWithPolicy(Kernel::HLERequestContext& ctx) { +void Module::Interface::ThrowFatalWithPolicy(HLERequestContext& ctx) { LOG_ERROR(Service_Fatal, "called"); IPC::RequestParser rp(ctx); const auto error_code = rp.Pop<Result>(); @@ -148,7 +148,7 @@ void Module::Interface::ThrowFatalWithPolicy(Kernel::HLERequestContext& ctx) { rb.Push(ResultSuccess); } -void Module::Interface::ThrowFatalWithCpuContext(Kernel::HLERequestContext& ctx) { +void Module::Interface::ThrowFatalWithCpuContext(HLERequestContext& ctx) { LOG_ERROR(Service_Fatal, "called"); IPC::RequestParser rp(ctx); const auto error_code = rp.Pop<Result>(); diff --git a/src/core/hle/service/fatal/fatal.h b/src/core/hle/service/fatal/fatal.h index 2e4e4c2f6..f1c110406 100644 --- a/src/core/hle/service/fatal/fatal.h +++ b/src/core/hle/service/fatal/fatal.h @@ -19,9 +19,9 @@ public: const char* name); ~Interface() override; - void ThrowFatal(Kernel::HLERequestContext& ctx); - void ThrowFatalWithPolicy(Kernel::HLERequestContext& ctx); - void ThrowFatalWithCpuContext(Kernel::HLERequestContext& ctx); + void ThrowFatal(HLERequestContext& ctx); + void ThrowFatalWithPolicy(HLERequestContext& ctx); + void ThrowFatalWithCpuContext(HLERequestContext& ctx); protected: std::shared_ptr<Module> module; diff --git a/src/core/hle/service/fgm/fgm.cpp b/src/core/hle/service/fgm/fgm.cpp index 612491270..6b3f77be2 100644 --- a/src/core/hle/service/fgm/fgm.cpp +++ b/src/core/hle/service/fgm/fgm.cpp @@ -3,8 +3,8 @@ #include <memory> -#include "core/hle/ipc_helpers.h" #include "core/hle/service/fgm/fgm.h" +#include "core/hle/service/ipc_helpers.h" #include "core/hle/service/server_manager.h" #include "core/hle/service/service.h" #include "core/hle/service/sm/sm.h" @@ -40,7 +40,7 @@ public: } private: - void Initialize(Kernel::HLERequestContext& ctx) { + void Initialize(HLERequestContext& ctx) { LOG_DEBUG(Service_FGM, "called"); IPC::ResponseBuilder rb{ctx, 2, 0, 1}; diff --git a/src/core/hle/service/filesystem/fsp_srv.cpp b/src/core/hle/service/filesystem/fsp_srv.cpp index 89eddb510..9e559d97e 100644 --- a/src/core/hle/service/filesystem/fsp_srv.cpp +++ b/src/core/hle/service/filesystem/fsp_srv.cpp @@ -24,9 +24,9 @@ #include "core/file_sys/savedata_factory.h" #include "core/file_sys/system_archive/system_archive.h" #include "core/file_sys/vfs.h" -#include "core/hle/ipc_helpers.h" #include "core/hle/service/filesystem/filesystem.h" #include "core/hle/service/filesystem/fsp_srv.h" +#include "core/hle/service/ipc_helpers.h" #include "core/reporter.h" namespace Service::FileSystem { @@ -72,7 +72,7 @@ public: private: FileSys::VirtualFile backend; - void Read(Kernel::HLERequestContext& ctx) { + void Read(HLERequestContext& ctx) { IPC::RequestParser rp{ctx}; const s64 offset = rp.Pop<s64>(); const s64 length = rp.Pop<s64>(); @@ -102,7 +102,7 @@ private: rb.Push(ResultSuccess); } - void GetSize(Kernel::HLERequestContext& ctx) { + void GetSize(HLERequestContext& ctx) { const u64 size = backend->GetSize(); LOG_DEBUG(Service_FS, "called, size={}", size); @@ -131,7 +131,7 @@ public: private: FileSys::VirtualFile backend; - void Read(Kernel::HLERequestContext& ctx) { + void Read(HLERequestContext& ctx) { IPC::RequestParser rp{ctx}; const u64 option = rp.Pop<u64>(); const s64 offset = rp.Pop<s64>(); @@ -165,7 +165,7 @@ private: rb.Push(static_cast<u64>(output.size())); } - void Write(Kernel::HLERequestContext& ctx) { + void Write(HLERequestContext& ctx) { IPC::RequestParser rp{ctx}; const u64 option = rp.Pop<u64>(); const s64 offset = rp.Pop<s64>(); @@ -208,7 +208,7 @@ private: rb.Push(ResultSuccess); } - void Flush(Kernel::HLERequestContext& ctx) { + void Flush(HLERequestContext& ctx) { LOG_DEBUG(Service_FS, "called"); // Exists for SDK compatibiltity -- No need to flush file. @@ -217,7 +217,7 @@ private: rb.Push(ResultSuccess); } - void SetSize(Kernel::HLERequestContext& ctx) { + void SetSize(HLERequestContext& ctx) { IPC::RequestParser rp{ctx}; const u64 size = rp.Pop<u64>(); LOG_DEBUG(Service_FS, "called, size={}", size); @@ -228,7 +228,7 @@ private: rb.Push(ResultSuccess); } - void GetSize(Kernel::HLERequestContext& ctx) { + void GetSize(HLERequestContext& ctx) { const u64 size = backend->GetSize(); LOG_DEBUG(Service_FS, "called, size={}", size); @@ -270,7 +270,7 @@ private: std::vector<FileSys::Entry> entries; u64 next_entry_index = 0; - void Read(Kernel::HLERequestContext& ctx) { + void Read(HLERequestContext& ctx) { LOG_DEBUG(Service_FS, "called."); // Calculate how many entries we can fit in the output buffer @@ -294,7 +294,7 @@ private: rb.Push(actual_entries); } - void GetEntryCount(Kernel::HLERequestContext& ctx) { + void GetEntryCount(HLERequestContext& ctx) { LOG_DEBUG(Service_FS, "called"); u64 count = entries.size() - next_entry_index; @@ -331,7 +331,7 @@ public: RegisterHandlers(functions); } - void CreateFile(Kernel::HLERequestContext& ctx) { + void CreateFile(HLERequestContext& ctx) { IPC::RequestParser rp{ctx}; const auto file_buffer = ctx.ReadBuffer(); @@ -347,7 +347,7 @@ public: rb.Push(backend.CreateFile(name, file_size)); } - void DeleteFile(Kernel::HLERequestContext& ctx) { + void DeleteFile(HLERequestContext& ctx) { const auto file_buffer = ctx.ReadBuffer(); const std::string name = Common::StringFromBuffer(file_buffer); @@ -357,7 +357,7 @@ public: rb.Push(backend.DeleteFile(name)); } - void CreateDirectory(Kernel::HLERequestContext& ctx) { + void CreateDirectory(HLERequestContext& ctx) { const auto file_buffer = ctx.ReadBuffer(); const std::string name = Common::StringFromBuffer(file_buffer); @@ -367,7 +367,7 @@ public: rb.Push(backend.CreateDirectory(name)); } - void DeleteDirectory(Kernel::HLERequestContext& ctx) { + void DeleteDirectory(HLERequestContext& ctx) { const auto file_buffer = ctx.ReadBuffer(); const std::string name = Common::StringFromBuffer(file_buffer); @@ -377,7 +377,7 @@ public: rb.Push(backend.DeleteDirectory(name)); } - void DeleteDirectoryRecursively(Kernel::HLERequestContext& ctx) { + void DeleteDirectoryRecursively(HLERequestContext& ctx) { const auto file_buffer = ctx.ReadBuffer(); const std::string name = Common::StringFromBuffer(file_buffer); @@ -387,7 +387,7 @@ public: rb.Push(backend.DeleteDirectoryRecursively(name)); } - void CleanDirectoryRecursively(Kernel::HLERequestContext& ctx) { + void CleanDirectoryRecursively(HLERequestContext& ctx) { const auto file_buffer = ctx.ReadBuffer(); const std::string name = Common::StringFromBuffer(file_buffer); @@ -397,7 +397,7 @@ public: rb.Push(backend.CleanDirectoryRecursively(name)); } - void RenameFile(Kernel::HLERequestContext& ctx) { + void RenameFile(HLERequestContext& ctx) { const std::string src_name = Common::StringFromBuffer(ctx.ReadBuffer(0)); const std::string dst_name = Common::StringFromBuffer(ctx.ReadBuffer(1)); @@ -407,7 +407,7 @@ public: rb.Push(backend.RenameFile(src_name, dst_name)); } - void OpenFile(Kernel::HLERequestContext& ctx) { + void OpenFile(HLERequestContext& ctx) { IPC::RequestParser rp{ctx}; const auto file_buffer = ctx.ReadBuffer(); @@ -431,7 +431,7 @@ public: rb.PushIpcInterface<IFile>(std::move(file)); } - void OpenDirectory(Kernel::HLERequestContext& ctx) { + void OpenDirectory(HLERequestContext& ctx) { IPC::RequestParser rp{ctx}; const auto file_buffer = ctx.ReadBuffer(); @@ -456,7 +456,7 @@ public: rb.PushIpcInterface<IDirectory>(std::move(directory)); } - void GetEntryType(Kernel::HLERequestContext& ctx) { + void GetEntryType(HLERequestContext& ctx) { const auto file_buffer = ctx.ReadBuffer(); const std::string name = Common::StringFromBuffer(file_buffer); @@ -474,14 +474,14 @@ public: rb.Push<u32>(static_cast<u32>(*result)); } - void Commit(Kernel::HLERequestContext& ctx) { + void Commit(HLERequestContext& ctx) { LOG_WARNING(Service_FS, "(STUBBED) called"); IPC::ResponseBuilder rb{ctx, 2}; rb.Push(ResultSuccess); } - void GetFreeSpaceSize(Kernel::HLERequestContext& ctx) { + void GetFreeSpaceSize(HLERequestContext& ctx) { LOG_DEBUG(Service_FS, "called"); IPC::ResponseBuilder rb{ctx, 4}; @@ -489,7 +489,7 @@ public: rb.Push(size.get_free_size()); } - void GetTotalSpaceSize(Kernel::HLERequestContext& ctx) { + void GetTotalSpaceSize(HLERequestContext& ctx) { LOG_DEBUG(Service_FS, "called"); IPC::ResponseBuilder rb{ctx, 4}; @@ -497,7 +497,7 @@ public: rb.Push(size.get_total_size()); } - void GetFileTimeStampRaw(Kernel::HLERequestContext& ctx) { + void GetFileTimeStampRaw(HLERequestContext& ctx) { const auto file_buffer = ctx.ReadBuffer(); const std::string name = Common::StringFromBuffer(file_buffer); @@ -533,7 +533,7 @@ public: FindAllSaves(space); } - void ReadSaveDataInfo(Kernel::HLERequestContext& ctx) { + void ReadSaveDataInfo(HLERequestContext& ctx) { LOG_DEBUG(Service_FS, "called"); // Calculate how many entries we can fit in the output buffer @@ -811,7 +811,7 @@ FSP_SRV::FSP_SRV(Core::System& system_) FSP_SRV::~FSP_SRV() = default; -void FSP_SRV::SetCurrentProcess(Kernel::HLERequestContext& ctx) { +void FSP_SRV::SetCurrentProcess(HLERequestContext& ctx) { IPC::RequestParser rp{ctx}; current_process_id = rp.Pop<u64>(); @@ -821,7 +821,7 @@ void FSP_SRV::SetCurrentProcess(Kernel::HLERequestContext& ctx) { rb.Push(ResultSuccess); } -void FSP_SRV::OpenFileSystemWithPatch(Kernel::HLERequestContext& ctx) { +void FSP_SRV::OpenFileSystemWithPatch(HLERequestContext& ctx) { IPC::RequestParser rp{ctx}; const auto type = rp.PopRaw<FileSystemType>(); @@ -832,7 +832,7 @@ void FSP_SRV::OpenFileSystemWithPatch(Kernel::HLERequestContext& ctx) { rb.Push(ResultUnknown); } -void FSP_SRV::OpenSdCardFileSystem(Kernel::HLERequestContext& ctx) { +void FSP_SRV::OpenSdCardFileSystem(HLERequestContext& ctx) { LOG_DEBUG(Service_FS, "called"); auto filesystem = @@ -844,7 +844,7 @@ void FSP_SRV::OpenSdCardFileSystem(Kernel::HLERequestContext& ctx) { rb.PushIpcInterface<IFileSystem>(std::move(filesystem)); } -void FSP_SRV::CreateSaveDataFileSystem(Kernel::HLERequestContext& ctx) { +void FSP_SRV::CreateSaveDataFileSystem(HLERequestContext& ctx) { IPC::RequestParser rp{ctx}; auto save_struct = rp.PopRaw<FileSys::SaveDataAttribute>(); @@ -860,7 +860,7 @@ void FSP_SRV::CreateSaveDataFileSystem(Kernel::HLERequestContext& ctx) { rb.Push(ResultSuccess); } -void FSP_SRV::OpenSaveDataFileSystem(Kernel::HLERequestContext& ctx) { +void FSP_SRV::OpenSaveDataFileSystem(HLERequestContext& ctx) { IPC::RequestParser rp{ctx}; struct Parameters { @@ -905,12 +905,12 @@ void FSP_SRV::OpenSaveDataFileSystem(Kernel::HLERequestContext& ctx) { rb.PushIpcInterface<IFileSystem>(std::move(filesystem)); } -void FSP_SRV::OpenReadOnlySaveDataFileSystem(Kernel::HLERequestContext& ctx) { +void FSP_SRV::OpenReadOnlySaveDataFileSystem(HLERequestContext& ctx) { LOG_WARNING(Service_FS, "(STUBBED) called, delegating to 51 OpenSaveDataFilesystem"); OpenSaveDataFileSystem(ctx); } -void FSP_SRV::OpenSaveDataInfoReaderBySaveDataSpaceId(Kernel::HLERequestContext& ctx) { +void FSP_SRV::OpenSaveDataInfoReaderBySaveDataSpaceId(HLERequestContext& ctx) { IPC::RequestParser rp{ctx}; const auto space = rp.PopRaw<FileSys::SaveDataSpaceId>(); LOG_INFO(Service_FS, "called, space={}", space); @@ -921,15 +921,14 @@ void FSP_SRV::OpenSaveDataInfoReaderBySaveDataSpaceId(Kernel::HLERequestContext& std::make_shared<ISaveDataInfoReader>(system, space, fsc)); } -void FSP_SRV::WriteSaveDataFileSystemExtraDataBySaveDataAttribute(Kernel::HLERequestContext& ctx) { +void FSP_SRV::WriteSaveDataFileSystemExtraDataBySaveDataAttribute(HLERequestContext& ctx) { LOG_WARNING(Service_FS, "(STUBBED) called."); IPC::ResponseBuilder rb{ctx, 2}; rb.Push(ResultSuccess); } -void FSP_SRV::ReadSaveDataFileSystemExtraDataWithMaskBySaveDataAttribute( - Kernel::HLERequestContext& ctx) { +void FSP_SRV::ReadSaveDataFileSystemExtraDataWithMaskBySaveDataAttribute(HLERequestContext& ctx) { IPC::RequestParser rp{ctx}; struct Parameters { @@ -955,7 +954,7 @@ void FSP_SRV::ReadSaveDataFileSystemExtraDataWithMaskBySaveDataAttribute( rb.Push(flags); } -void FSP_SRV::OpenDataStorageByCurrentProcess(Kernel::HLERequestContext& ctx) { +void FSP_SRV::OpenDataStorageByCurrentProcess(HLERequestContext& ctx) { LOG_DEBUG(Service_FS, "called"); auto current_romfs = fsc.OpenRomFSCurrentProcess(); @@ -974,7 +973,7 @@ void FSP_SRV::OpenDataStorageByCurrentProcess(Kernel::HLERequestContext& ctx) { rb.PushIpcInterface<IStorage>(std::move(storage)); } -void FSP_SRV::OpenDataStorageByDataId(Kernel::HLERequestContext& ctx) { +void FSP_SRV::OpenDataStorageByDataId(HLERequestContext& ctx) { IPC::RequestParser rp{ctx}; const auto storage_id = rp.PopRaw<FileSys::StorageId>(); const auto unknown = rp.PopRaw<u32>(); @@ -1014,7 +1013,7 @@ void FSP_SRV::OpenDataStorageByDataId(Kernel::HLERequestContext& ctx) { rb.PushIpcInterface<IStorage>(std::move(storage)); } -void FSP_SRV::OpenPatchDataStorageByCurrentProcess(Kernel::HLERequestContext& ctx) { +void FSP_SRV::OpenPatchDataStorageByCurrentProcess(HLERequestContext& ctx) { IPC::RequestParser rp{ctx}; const auto storage_id = rp.PopRaw<FileSys::StorageId>(); @@ -1026,7 +1025,7 @@ void FSP_SRV::OpenPatchDataStorageByCurrentProcess(Kernel::HLERequestContext& ct rb.Push(FileSys::ERROR_ENTITY_NOT_FOUND); } -void FSP_SRV::OpenDataStorageWithProgramIndex(Kernel::HLERequestContext& ctx) { +void FSP_SRV::OpenDataStorageWithProgramIndex(HLERequestContext& ctx) { IPC::RequestParser rp{ctx}; const auto program_index = rp.PopRaw<u8>(); @@ -1053,7 +1052,7 @@ void FSP_SRV::OpenDataStorageWithProgramIndex(Kernel::HLERequestContext& ctx) { rb.PushIpcInterface<IStorage>(std::move(storage)); } -void FSP_SRV::DisableAutoSaveDataCreation(Kernel::HLERequestContext& ctx) { +void FSP_SRV::DisableAutoSaveDataCreation(HLERequestContext& ctx) { LOG_DEBUG(Service_FS, "called"); fsc.SetAutoSaveDataCreation(false); @@ -1062,7 +1061,7 @@ void FSP_SRV::DisableAutoSaveDataCreation(Kernel::HLERequestContext& ctx) { rb.Push(ResultSuccess); } -void FSP_SRV::SetGlobalAccessLogMode(Kernel::HLERequestContext& ctx) { +void FSP_SRV::SetGlobalAccessLogMode(HLERequestContext& ctx) { IPC::RequestParser rp{ctx}; access_log_mode = rp.PopEnum<AccessLogMode>(); @@ -1072,7 +1071,7 @@ void FSP_SRV::SetGlobalAccessLogMode(Kernel::HLERequestContext& ctx) { rb.Push(ResultSuccess); } -void FSP_SRV::GetGlobalAccessLogMode(Kernel::HLERequestContext& ctx) { +void FSP_SRV::GetGlobalAccessLogMode(HLERequestContext& ctx) { LOG_DEBUG(Service_FS, "called"); IPC::ResponseBuilder rb{ctx, 3}; @@ -1080,7 +1079,7 @@ void FSP_SRV::GetGlobalAccessLogMode(Kernel::HLERequestContext& ctx) { rb.PushEnum(access_log_mode); } -void FSP_SRV::OutputAccessLogToSdCard(Kernel::HLERequestContext& ctx) { +void FSP_SRV::OutputAccessLogToSdCard(HLERequestContext& ctx) { const auto raw = ctx.ReadBufferCopy(); auto log = Common::StringFromFixedZeroTerminatedBuffer( reinterpret_cast<const char*>(raw.data()), raw.size()); @@ -1093,7 +1092,7 @@ void FSP_SRV::OutputAccessLogToSdCard(Kernel::HLERequestContext& ctx) { rb.Push(ResultSuccess); } -void FSP_SRV::GetProgramIndexForAccessLog(Kernel::HLERequestContext& ctx) { +void FSP_SRV::GetProgramIndexForAccessLog(HLERequestContext& ctx) { LOG_DEBUG(Service_FS, "called"); IPC::ResponseBuilder rb{ctx, 4}; @@ -1102,7 +1101,7 @@ void FSP_SRV::GetProgramIndexForAccessLog(Kernel::HLERequestContext& ctx) { rb.Push(access_log_program_index); } -void FSP_SRV::GetCacheStorageSize(Kernel::HLERequestContext& ctx) { +void FSP_SRV::GetCacheStorageSize(HLERequestContext& ctx) { IPC::RequestParser rp{ctx}; const auto index{rp.Pop<s32>()}; @@ -1128,14 +1127,14 @@ public: private: FileSys::VirtualFile backend; - void Add(Kernel::HLERequestContext& ctx) { + void Add(HLERequestContext& ctx) { LOG_WARNING(Service_FS, "(STUBBED) called"); IPC::ResponseBuilder rb{ctx, 2}; rb.Push(ResultSuccess); } - void Commit(Kernel::HLERequestContext& ctx) { + void Commit(HLERequestContext& ctx) { LOG_WARNING(Service_FS, "(STUBBED) called"); IPC::ResponseBuilder rb{ctx, 2}; @@ -1143,7 +1142,7 @@ private: } }; -void FSP_SRV::OpenMultiCommitManager(Kernel::HLERequestContext& ctx) { +void FSP_SRV::OpenMultiCommitManager(HLERequestContext& ctx) { LOG_DEBUG(Service_FS, "called"); IPC::ResponseBuilder rb{ctx, 2, 0, 1}; diff --git a/src/core/hle/service/filesystem/fsp_srv.h b/src/core/hle/service/filesystem/fsp_srv.h index 3d88b97f9..49f17c7c3 100644 --- a/src/core/hle/service/filesystem/fsp_srv.h +++ b/src/core/hle/service/filesystem/fsp_srv.h @@ -35,26 +35,26 @@ public: ~FSP_SRV() override; private: - void SetCurrentProcess(Kernel::HLERequestContext& ctx); - void OpenFileSystemWithPatch(Kernel::HLERequestContext& ctx); - void OpenSdCardFileSystem(Kernel::HLERequestContext& ctx); - void CreateSaveDataFileSystem(Kernel::HLERequestContext& ctx); - void OpenSaveDataFileSystem(Kernel::HLERequestContext& ctx); - void OpenReadOnlySaveDataFileSystem(Kernel::HLERequestContext& ctx); - void OpenSaveDataInfoReaderBySaveDataSpaceId(Kernel::HLERequestContext& ctx); - void WriteSaveDataFileSystemExtraDataBySaveDataAttribute(Kernel::HLERequestContext& ctx); - void ReadSaveDataFileSystemExtraDataWithMaskBySaveDataAttribute(Kernel::HLERequestContext& ctx); - void OpenDataStorageByCurrentProcess(Kernel::HLERequestContext& ctx); - void OpenDataStorageByDataId(Kernel::HLERequestContext& ctx); - void OpenPatchDataStorageByCurrentProcess(Kernel::HLERequestContext& ctx); - void OpenDataStorageWithProgramIndex(Kernel::HLERequestContext& ctx); - void DisableAutoSaveDataCreation(Kernel::HLERequestContext& ctx); - void SetGlobalAccessLogMode(Kernel::HLERequestContext& ctx); - void GetGlobalAccessLogMode(Kernel::HLERequestContext& ctx); - void OutputAccessLogToSdCard(Kernel::HLERequestContext& ctx); - void GetProgramIndexForAccessLog(Kernel::HLERequestContext& ctx); - void OpenMultiCommitManager(Kernel::HLERequestContext& ctx); - void GetCacheStorageSize(Kernel::HLERequestContext& ctx); + void SetCurrentProcess(HLERequestContext& ctx); + void OpenFileSystemWithPatch(HLERequestContext& ctx); + void OpenSdCardFileSystem(HLERequestContext& ctx); + void CreateSaveDataFileSystem(HLERequestContext& ctx); + void OpenSaveDataFileSystem(HLERequestContext& ctx); + void OpenReadOnlySaveDataFileSystem(HLERequestContext& ctx); + void OpenSaveDataInfoReaderBySaveDataSpaceId(HLERequestContext& ctx); + void WriteSaveDataFileSystemExtraDataBySaveDataAttribute(HLERequestContext& ctx); + void ReadSaveDataFileSystemExtraDataWithMaskBySaveDataAttribute(HLERequestContext& ctx); + void OpenDataStorageByCurrentProcess(HLERequestContext& ctx); + void OpenDataStorageByDataId(HLERequestContext& ctx); + void OpenPatchDataStorageByCurrentProcess(HLERequestContext& ctx); + void OpenDataStorageWithProgramIndex(HLERequestContext& ctx); + void DisableAutoSaveDataCreation(HLERequestContext& ctx); + void SetGlobalAccessLogMode(HLERequestContext& ctx); + void GetGlobalAccessLogMode(HLERequestContext& ctx); + void OutputAccessLogToSdCard(HLERequestContext& ctx); + void GetProgramIndexForAccessLog(HLERequestContext& ctx); + void OpenMultiCommitManager(HLERequestContext& ctx); + void GetCacheStorageSize(HLERequestContext& ctx); FileSystemController& fsc; const FileSys::ContentProvider& content_provider; diff --git a/src/core/hle/service/friend/errors.h b/src/core/hle/service/friend/errors.h deleted file mode 100644 index ff525d865..000000000 --- a/src/core/hle/service/friend/errors.h +++ /dev/null @@ -1,11 +0,0 @@ -// SPDX-FileCopyrightText: Copyright 2019 yuzu Emulator Project -// SPDX-License-Identifier: GPL-2.0-or-later - -#pragma once - -#include "core/hle/result.h" - -namespace Service::Friend { - -constexpr Result ERR_NO_NOTIFICATIONS{ErrorModule::Account, 15}; -} diff --git a/src/core/hle/service/friend/friend.cpp b/src/core/hle/service/friend/friend.cpp index fcf10bfeb..9d05f9801 100644 --- a/src/core/hle/service/friend/friend.cpp +++ b/src/core/hle/service/friend/friend.cpp @@ -5,11 +5,11 @@ #include "common/logging/log.h" #include "common/uuid.h" #include "core/core.h" -#include "core/hle/ipc_helpers.h" #include "core/hle/kernel/k_event.h" -#include "core/hle/service/friend/errors.h" +#include "core/hle/service/acc/errors.h" #include "core/hle/service/friend/friend.h" #include "core/hle/service/friend/friend_interface.h" +#include "core/hle/service/ipc_helpers.h" #include "core/hle/service/kernel_helpers.h" #include "core/hle/service/server_manager.h" @@ -136,7 +136,7 @@ private: }; static_assert(sizeof(SizedFriendFilter) == 0x10, "SizedFriendFilter is an invalid size"); - void GetCompletionEvent(Kernel::HLERequestContext& ctx) { + void GetCompletionEvent(HLERequestContext& ctx) { LOG_DEBUG(Service_Friend, "called"); IPC::ResponseBuilder rb{ctx, 2, 1}; @@ -144,7 +144,7 @@ private: rb.PushCopyObjects(completion_event->GetReadableEvent()); } - void GetBlockedUserListIds(Kernel::HLERequestContext& ctx) { + void GetBlockedUserListIds(HLERequestContext& ctx) { // This is safe to stub, as there should be no adverse consequences from reporting no // blocked users. LOG_WARNING(Service_Friend, "(STUBBED) called"); @@ -153,21 +153,21 @@ private: rb.Push<u32>(0); // Indicates there are no blocked users } - void DeclareCloseOnlinePlaySession(Kernel::HLERequestContext& ctx) { + void DeclareCloseOnlinePlaySession(HLERequestContext& ctx) { // Stub used by Splatoon 2 LOG_WARNING(Service_Friend, "(STUBBED) called"); IPC::ResponseBuilder rb{ctx, 2}; rb.Push(ResultSuccess); } - void UpdateUserPresence(Kernel::HLERequestContext& ctx) { + void UpdateUserPresence(HLERequestContext& ctx) { // Stub used by Retro City Rampage LOG_WARNING(Service_Friend, "(STUBBED) called"); IPC::ResponseBuilder rb{ctx, 2}; rb.Push(ResultSuccess); } - void GetPlayHistoryRegistrationKey(Kernel::HLERequestContext& ctx) { + void GetPlayHistoryRegistrationKey(HLERequestContext& ctx) { IPC::RequestParser rp{ctx}; const auto local_play = rp.Pop<bool>(); const auto uuid = rp.PopRaw<Common::UUID>(); @@ -179,7 +179,7 @@ private: rb.Push(ResultSuccess); } - void GetFriendList(Kernel::HLERequestContext& ctx) { + void GetFriendList(HLERequestContext& ctx) { IPC::RequestParser rp{ctx}; const auto friend_offset = rp.Pop<u32>(); const auto uuid = rp.PopRaw<Common::UUID>(); @@ -195,7 +195,7 @@ private: // TODO(ogniK): Return a buffer of u64s which are the "NetworkServiceAccountId" } - void CheckFriendListAvailability(Kernel::HLERequestContext& ctx) { + void CheckFriendListAvailability(HLERequestContext& ctx) { IPC::RequestParser rp{ctx}; const auto uuid{rp.PopRaw<Common::UUID>()}; @@ -234,7 +234,7 @@ public: } private: - void GetEvent(Kernel::HLERequestContext& ctx) { + void GetEvent(HLERequestContext& ctx) { LOG_DEBUG(Service_Friend, "called"); IPC::ResponseBuilder rb{ctx, 2, 1}; @@ -242,7 +242,7 @@ private: rb.PushCopyObjects(notification_event->GetReadableEvent()); } - void Clear(Kernel::HLERequestContext& ctx) { + void Clear(HLERequestContext& ctx) { LOG_DEBUG(Service_Friend, "called"); while (!notifications.empty()) { notifications.pop(); @@ -253,13 +253,13 @@ private: rb.Push(ResultSuccess); } - void Pop(Kernel::HLERequestContext& ctx) { + void Pop(HLERequestContext& ctx) { LOG_DEBUG(Service_Friend, "called"); if (notifications.empty()) { LOG_ERROR(Service_Friend, "No notifications in queue!"); IPC::ResponseBuilder rb{ctx, 2}; - rb.Push(ERR_NO_NOTIFICATIONS); + rb.Push(Account::ResultNoNotifications); return; } @@ -312,14 +312,14 @@ private: States states{}; }; -void Module::Interface::CreateFriendService(Kernel::HLERequestContext& ctx) { +void Module::Interface::CreateFriendService(HLERequestContext& ctx) { IPC::ResponseBuilder rb{ctx, 2, 0, 1}; rb.Push(ResultSuccess); rb.PushIpcInterface<IFriendService>(system); LOG_DEBUG(Service_Friend, "called"); } -void Module::Interface::CreateNotificationService(Kernel::HLERequestContext& ctx) { +void Module::Interface::CreateNotificationService(HLERequestContext& ctx) { IPC::RequestParser rp{ctx}; auto uuid = rp.PopRaw<Common::UUID>(); diff --git a/src/core/hle/service/friend/friend.h b/src/core/hle/service/friend/friend.h index 41be06a4f..2824dc786 100644 --- a/src/core/hle/service/friend/friend.h +++ b/src/core/hle/service/friend/friend.h @@ -19,8 +19,8 @@ public: const char* name); ~Interface() override; - void CreateFriendService(Kernel::HLERequestContext& ctx); - void CreateNotificationService(Kernel::HLERequestContext& ctx); + void CreateFriendService(HLERequestContext& ctx); + void CreateNotificationService(HLERequestContext& ctx); protected: std::shared_ptr<Module> module; diff --git a/src/core/hle/service/glue/arp.cpp b/src/core/hle/service/glue/arp.cpp index ce21b69e3..ed6fcb5f6 100644 --- a/src/core/hle/service/glue/arp.cpp +++ b/src/core/hle/service/glue/arp.cpp @@ -5,12 +5,12 @@ #include "common/logging/log.h" #include "core/core.h" -#include "core/hle/ipc_helpers.h" #include "core/hle/kernel/k_process.h" #include "core/hle/kernel/kernel.h" #include "core/hle/service/glue/arp.h" #include "core/hle/service/glue/errors.h" #include "core/hle/service/glue/glue_manager.h" +#include "core/hle/service/ipc_helpers.h" namespace Service::Glue { @@ -18,14 +18,14 @@ namespace { std::optional<u64> GetTitleIDForProcessID(const Core::System& system, u64 process_id) { const auto& list = system.Kernel().GetProcessList(); const auto iter = std::find_if(list.begin(), list.end(), [&process_id](const auto& process) { - return process->GetProcessID() == process_id; + return process->GetProcessId() == process_id; }); if (iter == list.end()) { return std::nullopt; } - return (*iter)->GetProgramID(); + return (*iter)->GetProgramId(); } } // Anonymous namespace @@ -51,7 +51,7 @@ ARP_R::ARP_R(Core::System& system_, const ARPManager& manager_) ARP_R::~ARP_R() = default; -void ARP_R::GetApplicationLaunchProperty(Kernel::HLERequestContext& ctx) { +void ARP_R::GetApplicationLaunchProperty(HLERequestContext& ctx) { IPC::RequestParser rp{ctx}; const auto process_id = rp.PopRaw<u64>(); @@ -61,7 +61,7 @@ void ARP_R::GetApplicationLaunchProperty(Kernel::HLERequestContext& ctx) { if (!title_id.has_value()) { LOG_ERROR(Service_ARP, "Failed to get title ID for process ID!"); IPC::ResponseBuilder rb{ctx, 2}; - rb.Push(ERR_NOT_REGISTERED); + rb.Push(Glue::ResultProcessIdNotRegistered); return; } @@ -79,7 +79,7 @@ void ARP_R::GetApplicationLaunchProperty(Kernel::HLERequestContext& ctx) { rb.PushRaw(*res); } -void ARP_R::GetApplicationLaunchPropertyWithApplicationId(Kernel::HLERequestContext& ctx) { +void ARP_R::GetApplicationLaunchPropertyWithApplicationId(HLERequestContext& ctx) { IPC::RequestParser rp{ctx}; const auto title_id = rp.PopRaw<u64>(); @@ -99,7 +99,7 @@ void ARP_R::GetApplicationLaunchPropertyWithApplicationId(Kernel::HLERequestCont rb.PushRaw(*res); } -void ARP_R::GetApplicationControlProperty(Kernel::HLERequestContext& ctx) { +void ARP_R::GetApplicationControlProperty(HLERequestContext& ctx) { IPC::RequestParser rp{ctx}; const auto process_id = rp.PopRaw<u64>(); @@ -109,7 +109,7 @@ void ARP_R::GetApplicationControlProperty(Kernel::HLERequestContext& ctx) { if (!title_id.has_value()) { LOG_ERROR(Service_ARP, "Failed to get title ID for process ID!"); IPC::ResponseBuilder rb{ctx, 2}; - rb.Push(ERR_NOT_REGISTERED); + rb.Push(Glue::ResultProcessIdNotRegistered); return; } @@ -128,7 +128,7 @@ void ARP_R::GetApplicationControlProperty(Kernel::HLERequestContext& ctx) { rb.Push(ResultSuccess); } -void ARP_R::GetApplicationControlPropertyWithApplicationId(Kernel::HLERequestContext& ctx) { +void ARP_R::GetApplicationControlPropertyWithApplicationId(HLERequestContext& ctx) { IPC::RequestParser rp{ctx}; const auto title_id = rp.PopRaw<u64>(); @@ -169,7 +169,7 @@ public: } private: - void Issue(Kernel::HLERequestContext& ctx) { + void Issue(HLERequestContext& ctx) { IPC::RequestParser rp{ctx}; const auto process_id = rp.PopRaw<u64>(); @@ -178,7 +178,7 @@ private: if (process_id == 0) { LOG_ERROR(Service_ARP, "Must have non-zero process ID!"); IPC::ResponseBuilder rb{ctx, 2}; - rb.Push(ERR_INVALID_PROCESS_ID); + rb.Push(Glue::ResultInvalidProcessId); return; } @@ -186,7 +186,7 @@ private: LOG_ERROR(Service_ARP, "Attempted to issue registrar, but registrar is already issued!"); IPC::ResponseBuilder rb{ctx, 2}; - rb.Push(ERR_INVALID_ACCESS); + rb.Push(Glue::ResultAlreadyBound); return; } @@ -197,7 +197,7 @@ private: rb.Push(ResultSuccess); } - void SetApplicationLaunchProperty(Kernel::HLERequestContext& ctx) { + void SetApplicationLaunchProperty(HLERequestContext& ctx) { LOG_DEBUG(Service_ARP, "called"); if (issued) { @@ -205,7 +205,7 @@ private: Service_ARP, "Attempted to set application launch property, but registrar is already issued!"); IPC::ResponseBuilder rb{ctx, 2}; - rb.Push(ERR_INVALID_ACCESS); + rb.Push(Glue::ResultAlreadyBound); return; } @@ -216,7 +216,7 @@ private: rb.Push(ResultSuccess); } - void SetApplicationControlProperty(Kernel::HLERequestContext& ctx) { + void SetApplicationControlProperty(HLERequestContext& ctx) { LOG_DEBUG(Service_ARP, "called"); if (issued) { @@ -224,7 +224,7 @@ private: Service_ARP, "Attempted to set application control property, but registrar is already issued!"); IPC::ResponseBuilder rb{ctx, 2}; - rb.Push(ERR_INVALID_ACCESS); + rb.Push(Glue::ResultAlreadyBound); return; } @@ -256,14 +256,14 @@ ARP_W::ARP_W(Core::System& system_, ARPManager& manager_) ARP_W::~ARP_W() = default; -void ARP_W::AcquireRegistrar(Kernel::HLERequestContext& ctx) { +void ARP_W::AcquireRegistrar(HLERequestContext& ctx) { LOG_DEBUG(Service_ARP, "called"); registrar = std::make_shared<IRegistrar>( system, [this](u64 process_id, ApplicationLaunchProperty launch, std::vector<u8> control) { const auto res = GetTitleIDForProcessID(system, process_id); if (!res.has_value()) { - return ERR_NOT_REGISTERED; + return Glue::ResultProcessIdNotRegistered; } return manager.Register(*res, launch, std::move(control)); @@ -274,7 +274,7 @@ void ARP_W::AcquireRegistrar(Kernel::HLERequestContext& ctx) { rb.PushIpcInterface(registrar); } -void ARP_W::UnregisterApplicationInstance(Kernel::HLERequestContext& ctx) { +void ARP_W::UnregisterApplicationInstance(HLERequestContext& ctx) { IPC::RequestParser rp{ctx}; const auto process_id = rp.PopRaw<u64>(); @@ -283,7 +283,7 @@ void ARP_W::UnregisterApplicationInstance(Kernel::HLERequestContext& ctx) { if (process_id == 0) { LOG_ERROR(Service_ARP, "Must have non-zero process ID!"); IPC::ResponseBuilder rb{ctx, 2}; - rb.Push(ERR_INVALID_PROCESS_ID); + rb.Push(Glue::ResultInvalidProcessId); return; } @@ -292,7 +292,7 @@ void ARP_W::UnregisterApplicationInstance(Kernel::HLERequestContext& ctx) { if (!title_id.has_value()) { LOG_ERROR(Service_ARP, "No title ID for process ID!"); IPC::ResponseBuilder rb{ctx, 2}; - rb.Push(ERR_NOT_REGISTERED); + rb.Push(Glue::ResultProcessIdNotRegistered); return; } diff --git a/src/core/hle/service/glue/arp.h b/src/core/hle/service/glue/arp.h index 06c992e88..5bce80175 100644 --- a/src/core/hle/service/glue/arp.h +++ b/src/core/hle/service/glue/arp.h @@ -16,10 +16,10 @@ public: ~ARP_R() override; private: - void GetApplicationLaunchProperty(Kernel::HLERequestContext& ctx); - void GetApplicationLaunchPropertyWithApplicationId(Kernel::HLERequestContext& ctx); - void GetApplicationControlProperty(Kernel::HLERequestContext& ctx); - void GetApplicationControlPropertyWithApplicationId(Kernel::HLERequestContext& ctx); + void GetApplicationLaunchProperty(HLERequestContext& ctx); + void GetApplicationLaunchPropertyWithApplicationId(HLERequestContext& ctx); + void GetApplicationControlProperty(HLERequestContext& ctx); + void GetApplicationControlPropertyWithApplicationId(HLERequestContext& ctx); const ARPManager& manager; }; @@ -30,8 +30,8 @@ public: ~ARP_W() override; private: - void AcquireRegistrar(Kernel::HLERequestContext& ctx); - void UnregisterApplicationInstance(Kernel::HLERequestContext& ctx); + void AcquireRegistrar(HLERequestContext& ctx); + void UnregisterApplicationInstance(HLERequestContext& ctx); ARPManager& manager; std::shared_ptr<IRegistrar> registrar; diff --git a/src/core/hle/service/glue/bgtc.cpp b/src/core/hle/service/glue/bgtc.cpp index 3248091c3..ae22ac4f7 100644 --- a/src/core/hle/service/glue/bgtc.cpp +++ b/src/core/hle/service/glue/bgtc.cpp @@ -3,8 +3,8 @@ #include "common/logging/log.h" #include "core/core.h" -#include "core/hle/ipc_helpers.h" #include "core/hle/service/glue/bgtc.h" +#include "core/hle/service/ipc_helpers.h" namespace Service::Glue { @@ -20,7 +20,7 @@ BGTC_T::BGTC_T(Core::System& system_) : ServiceFramework{system_, "bgtc:t"} { BGTC_T::~BGTC_T() = default; -void BGTC_T::OpenTaskService(Kernel::HLERequestContext& ctx) { +void BGTC_T::OpenTaskService(HLERequestContext& ctx) { LOG_DEBUG(Service_BGTC, "called"); IPC::ResponseBuilder rb{ctx, 2, 0, 1}; diff --git a/src/core/hle/service/glue/bgtc.h b/src/core/hle/service/glue/bgtc.h index d6e2baec1..5a5d9c9a7 100644 --- a/src/core/hle/service/glue/bgtc.h +++ b/src/core/hle/service/glue/bgtc.h @@ -16,7 +16,7 @@ public: explicit BGTC_T(Core::System& system_); ~BGTC_T() override; - void OpenTaskService(Kernel::HLERequestContext& ctx); + void OpenTaskService(HLERequestContext& ctx); }; class ITaskService final : public ServiceFramework<ITaskService> { diff --git a/src/core/hle/service/glue/errors.h b/src/core/hle/service/glue/errors.h index d4ce7f44e..30feaa5c0 100644 --- a/src/core/hle/service/glue/errors.h +++ b/src/core/hle/service/glue/errors.h @@ -7,9 +7,8 @@ namespace Service::Glue { -constexpr Result ERR_INVALID_RESOURCE{ErrorModule::ARP, 30}; -constexpr Result ERR_INVALID_PROCESS_ID{ErrorModule::ARP, 31}; -constexpr Result ERR_INVALID_ACCESS{ErrorModule::ARP, 42}; -constexpr Result ERR_NOT_REGISTERED{ErrorModule::ARP, 102}; +constexpr Result ResultInvalidProcessId{ErrorModule::ARP, 31}; +constexpr Result ResultAlreadyBound{ErrorModule::ARP, 42}; +constexpr Result ResultProcessIdNotRegistered{ErrorModule::ARP, 102}; } // namespace Service::Glue diff --git a/src/core/hle/service/glue/glue_manager.cpp b/src/core/hle/service/glue/glue_manager.cpp index 8a654cdca..4bf67921b 100644 --- a/src/core/hle/service/glue/glue_manager.cpp +++ b/src/core/hle/service/glue/glue_manager.cpp @@ -17,12 +17,12 @@ ARPManager::~ARPManager() = default; ResultVal<ApplicationLaunchProperty> ARPManager::GetLaunchProperty(u64 title_id) const { if (title_id == 0) { - return ERR_INVALID_PROCESS_ID; + return Glue::ResultInvalidProcessId; } const auto iter = entries.find(title_id); if (iter == entries.end()) { - return ERR_NOT_REGISTERED; + return Glue::ResultProcessIdNotRegistered; } return iter->second.launch; @@ -30,12 +30,12 @@ ResultVal<ApplicationLaunchProperty> ARPManager::GetLaunchProperty(u64 title_id) ResultVal<std::vector<u8>> ARPManager::GetControlProperty(u64 title_id) const { if (title_id == 0) { - return ERR_INVALID_PROCESS_ID; + return Glue::ResultInvalidProcessId; } const auto iter = entries.find(title_id); if (iter == entries.end()) { - return ERR_NOT_REGISTERED; + return Glue::ResultProcessIdNotRegistered; } return iter->second.control; @@ -44,12 +44,12 @@ ResultVal<std::vector<u8>> ARPManager::GetControlProperty(u64 title_id) const { Result ARPManager::Register(u64 title_id, ApplicationLaunchProperty launch, std::vector<u8> control) { if (title_id == 0) { - return ERR_INVALID_PROCESS_ID; + return Glue::ResultInvalidProcessId; } const auto iter = entries.find(title_id); if (iter != entries.end()) { - return ERR_INVALID_ACCESS; + return Glue::ResultAlreadyBound; } entries.insert_or_assign(title_id, MapEntry{launch, std::move(control)}); @@ -58,12 +58,12 @@ Result ARPManager::Register(u64 title_id, ApplicationLaunchProperty launch, Result ARPManager::Unregister(u64 title_id) { if (title_id == 0) { - return ERR_INVALID_PROCESS_ID; + return Glue::ResultInvalidProcessId; } const auto iter = entries.find(title_id); if (iter == entries.end()) { - return ERR_NOT_REGISTERED; + return Glue::ResultProcessIdNotRegistered; } entries.erase(iter); diff --git a/src/core/hle/service/glue/glue_manager.h b/src/core/hle/service/glue/glue_manager.h index cd0b092ac..1cf53d9d9 100644 --- a/src/core/hle/service/glue/glue_manager.h +++ b/src/core/hle/service/glue/glue_manager.h @@ -30,23 +30,23 @@ public: ~ARPManager(); // Returns the ApplicationLaunchProperty corresponding to the provided title ID if it was - // previously registered, otherwise ERR_NOT_REGISTERED if it was never registered or - // ERR_INVALID_PROCESS_ID if the title ID is 0. + // previously registered, otherwise ResultProcessIdNotRegistered if it was never registered or + // ResultInvalidProcessId if the title ID is 0. ResultVal<ApplicationLaunchProperty> GetLaunchProperty(u64 title_id) const; // Returns a vector of the raw bytes of NACP data (necessarily 0x4000 in size) corresponding to - // the provided title ID if it was previously registered, otherwise ERR_NOT_REGISTERED if it was - // never registered or ERR_INVALID_PROCESS_ID if the title ID is 0. + // the provided title ID if it was previously registered, otherwise ResultProcessIdNotRegistered + // if it was never registered or ResultInvalidProcessId if the title ID is 0. ResultVal<std::vector<u8>> GetControlProperty(u64 title_id) const; // Adds a new entry to the internal database with the provided parameters, returning - // ERR_INVALID_ACCESS if attempting to re-register a title ID without an intermediate Unregister - // step, and ERR_INVALID_PROCESS_ID if the title ID is 0. + // ResultProcessIdNotRegistered if attempting to re-register a title ID without an intermediate + // Unregister step, and ResultInvalidProcessId if the title ID is 0. Result Register(u64 title_id, ApplicationLaunchProperty launch, std::vector<u8> control); // Removes the registration for the provided title ID from the database, returning - // ERR_NOT_REGISTERED if it doesn't exist in the database and ERR_INVALID_PROCESS_ID if the - // title ID is 0. + // ResultProcessIdNotRegistered if it doesn't exist in the database and ResultInvalidProcessId + // if the title ID is 0. Result Unregister(u64 title_id); // Removes all entries from the database, always succeeds. Should only be used when resetting diff --git a/src/core/hle/service/glue/notif.cpp b/src/core/hle/service/glue/notif.cpp index 3ace2dabd..fec4ad86c 100644 --- a/src/core/hle/service/glue/notif.cpp +++ b/src/core/hle/service/glue/notif.cpp @@ -6,8 +6,8 @@ #include "common/assert.h" #include "common/logging/log.h" -#include "core/hle/ipc_helpers.h" #include "core/hle/service/glue/notif.h" +#include "core/hle/service/ipc_helpers.h" namespace Service::Glue { @@ -28,7 +28,7 @@ NOTIF_A::NOTIF_A(Core::System& system_) : ServiceFramework{system_, "notif:a"} { NOTIF_A::~NOTIF_A() = default; -void NOTIF_A::RegisterAlarmSetting(Kernel::HLERequestContext& ctx) { +void NOTIF_A::RegisterAlarmSetting(HLERequestContext& ctx) { const auto alarm_setting_buffer_size = ctx.GetReadBufferSize(0); const auto application_parameter_size = ctx.GetReadBufferSize(1); @@ -63,7 +63,7 @@ void NOTIF_A::RegisterAlarmSetting(Kernel::HLERequestContext& ctx) { rb.Push(new_alarm.alarm_setting_id); } -void NOTIF_A::UpdateAlarmSetting(Kernel::HLERequestContext& ctx) { +void NOTIF_A::UpdateAlarmSetting(HLERequestContext& ctx) { const auto alarm_setting_buffer_size = ctx.GetReadBufferSize(0); const auto application_parameter_size = ctx.GetReadBufferSize(1); @@ -91,7 +91,7 @@ void NOTIF_A::UpdateAlarmSetting(Kernel::HLERequestContext& ctx) { rb.Push(ResultSuccess); } -void NOTIF_A::ListAlarmSettings(Kernel::HLERequestContext& ctx) { +void NOTIF_A::ListAlarmSettings(HLERequestContext& ctx) { LOG_INFO(Service_NOTIF, "called, alarm_count={}", alarms.size()); // TODO: Only return alarms of this game id @@ -102,7 +102,7 @@ void NOTIF_A::ListAlarmSettings(Kernel::HLERequestContext& ctx) { rb.Push(static_cast<u32>(alarms.size())); } -void NOTIF_A::LoadApplicationParameter(Kernel::HLERequestContext& ctx) { +void NOTIF_A::LoadApplicationParameter(HLERequestContext& ctx) { IPC::RequestParser rp{ctx}; const auto alarm_setting_id{rp.Pop<AlarmSettingId>()}; @@ -126,7 +126,7 @@ void NOTIF_A::LoadApplicationParameter(Kernel::HLERequestContext& ctx) { rb.Push(static_cast<u32>(application_parameter.size())); } -void NOTIF_A::DeleteAlarmSetting(Kernel::HLERequestContext& ctx) { +void NOTIF_A::DeleteAlarmSetting(HLERequestContext& ctx) { IPC::RequestParser rp{ctx}; const auto alarm_setting_id{rp.Pop<AlarmSettingId>()}; @@ -140,7 +140,7 @@ void NOTIF_A::DeleteAlarmSetting(Kernel::HLERequestContext& ctx) { rb.Push(ResultSuccess); } -void NOTIF_A::Initialize(Kernel::HLERequestContext& ctx) { +void NOTIF_A::Initialize(HLERequestContext& ctx) { // TODO: Load previous alarms from config LOG_WARNING(Service_NOTIF, "(STUBBED) called"); diff --git a/src/core/hle/service/glue/notif.h b/src/core/hle/service/glue/notif.h index 4467e1f35..b1187f3a3 100644 --- a/src/core/hle/service/glue/notif.h +++ b/src/core/hle/service/glue/notif.h @@ -56,12 +56,12 @@ private: }; static_assert(sizeof(AlarmSetting) == 0x40, "AlarmSetting is an invalid size"); - void RegisterAlarmSetting(Kernel::HLERequestContext& ctx); - void UpdateAlarmSetting(Kernel::HLERequestContext& ctx); - void ListAlarmSettings(Kernel::HLERequestContext& ctx); - void LoadApplicationParameter(Kernel::HLERequestContext& ctx); - void DeleteAlarmSetting(Kernel::HLERequestContext& ctx); - void Initialize(Kernel::HLERequestContext& ctx); + void RegisterAlarmSetting(HLERequestContext& ctx); + void UpdateAlarmSetting(HLERequestContext& ctx); + void ListAlarmSettings(HLERequestContext& ctx); + void LoadApplicationParameter(HLERequestContext& ctx); + void DeleteAlarmSetting(HLERequestContext& ctx); + void Initialize(HLERequestContext& ctx); std::vector<AlarmSetting>::iterator GetAlarmFromId(AlarmSettingId alarm_setting_id); diff --git a/src/core/hle/service/hid/controllers/gesture.cpp b/src/core/hle/service/hid/controllers/gesture.cpp index de0090cc5..03432f7cb 100644 --- a/src/core/hle/service/hid/controllers/gesture.cpp +++ b/src/core/hle/service/hid/controllers/gesture.cpp @@ -55,7 +55,7 @@ void Controller_Gesture::OnUpdate(const Core::Timing::CoreTiming& core_timing) { static_cast<f32>(shared_memory->gesture_lifo.timestamp - last_update_timestamp) / (1000 * 1000 * 1000); - // Only update if necesary + // Only update if necessary if (!ShouldUpdateGesture(gesture, time_difference)) { return; } diff --git a/src/core/hle/service/hid/controllers/stubbed.cpp b/src/core/hle/service/hid/controllers/stubbed.cpp index df9ee0c3f..9e2f3ab21 100644 --- a/src/core/hle/service/hid/controllers/stubbed.cpp +++ b/src/core/hle/service/hid/controllers/stubbed.cpp @@ -26,7 +26,7 @@ void Controller_Stubbed::OnUpdate(const Core::Timing::CoreTiming& core_timing) { } CommonHeader header{}; - header.timestamp = core_timing.GetCPUTicks(); + header.timestamp = core_timing.GetGlobalTimeNs().count(); header.total_entry_count = 17; header.entry_count = 0; header.last_entry_index = 0; diff --git a/src/core/hle/service/hid/controllers/touchscreen.cpp b/src/core/hle/service/hid/controllers/touchscreen.cpp index d90a4e732..3ef91df4b 100644 --- a/src/core/hle/service/hid/controllers/touchscreen.cpp +++ b/src/core/hle/service/hid/controllers/touchscreen.cpp @@ -32,7 +32,7 @@ void Controller_Touchscreen::OnInit() {} void Controller_Touchscreen::OnRelease() {} void Controller_Touchscreen::OnUpdate(const Core::Timing::CoreTiming& core_timing) { - shared_memory->touch_screen_lifo.timestamp = core_timing.GetCPUTicks(); + shared_memory->touch_screen_lifo.timestamp = core_timing.GetGlobalTimeNs().count(); if (!IsControllerActivated()) { shared_memory->touch_screen_lifo.buffer_count = 0; @@ -85,7 +85,7 @@ void Controller_Touchscreen::OnUpdate(const Core::Timing::CoreTiming& core_timin const auto active_fingers_count = static_cast<std::size_t>(std::distance(active_fingers.begin(), end_iter)); - const u64 tick = core_timing.GetCPUTicks(); + const u64 timestamp = static_cast<u64>(core_timing.GetGlobalTimeNs().count()); const auto& last_entry = shared_memory->touch_screen_lifo.ReadCurrentEntry().state; next_state.sampling_number = last_entry.sampling_number + 1; @@ -102,8 +102,8 @@ void Controller_Touchscreen::OnUpdate(const Core::Timing::CoreTiming& core_timin touch_entry.diameter_x = Settings::values.touchscreen.diameter_x; touch_entry.diameter_y = Settings::values.touchscreen.diameter_y; touch_entry.rotation_angle = Settings::values.touchscreen.rotation_angle; - touch_entry.delta_time = tick - active_fingers[id].last_touch; - fingers[active_fingers[id].id].last_touch = tick; + touch_entry.delta_time = timestamp - active_fingers[id].last_touch; + fingers[active_fingers[id].id].last_touch = timestamp; touch_entry.finger = active_fingers[id].id; touch_entry.attribute.raw = active_fingers[id].attribute.raw; } else { diff --git a/src/core/hle/service/hid/hid.cpp b/src/core/hle/service/hid/hid.cpp index 4b5130469..4529ad643 100644 --- a/src/core/hle/service/hid/hid.cpp +++ b/src/core/hle/service/hid/hid.cpp @@ -8,7 +8,6 @@ #include "core/core.h" #include "core/core_timing.h" #include "core/hid/hid_core.h" -#include "core/hle/ipc_helpers.h" #include "core/hle/kernel/k_readable_event.h" #include "core/hle/kernel/k_shared_memory.h" #include "core/hle/kernel/k_transfer_memory.h" @@ -18,6 +17,7 @@ #include "core/hle/service/hid/hidbus.h" #include "core/hle/service/hid/irs.h" #include "core/hle/service/hid/xcd.h" +#include "core/hle/service/ipc_helpers.h" #include "core/hle/service/server_manager.h" #include "core/memory.h" @@ -138,7 +138,7 @@ IAppletResource::~IAppletResource() { system.CoreTiming().UnscheduleEvent(motion_update_event, 0); } -void IAppletResource::GetSharedMemoryHandle(Kernel::HLERequestContext& ctx) { +void IAppletResource::GetSharedMemoryHandle(HLERequestContext& ctx) { LOG_DEBUG(Service_HID, "called"); IPC::ResponseBuilder rb{ctx, 2, 1}; @@ -203,7 +203,7 @@ public: } private: - void InitializeVibrationDevice(Kernel::HLERequestContext& ctx) { + void InitializeVibrationDevice(HLERequestContext& ctx) { IPC::RequestParser rp{ctx}; const auto vibration_device_handle{rp.PopRaw<Core::HID::VibrationDeviceHandle>()}; @@ -382,7 +382,7 @@ Hid::Hid(Core::System& system_) Hid::~Hid() = default; -void Hid::CreateAppletResource(Kernel::HLERequestContext& ctx) { +void Hid::CreateAppletResource(HLERequestContext& ctx) { IPC::RequestParser rp{ctx}; const auto applet_resource_user_id{rp.Pop<u64>()}; @@ -397,7 +397,7 @@ void Hid::CreateAppletResource(Kernel::HLERequestContext& ctx) { rb.PushIpcInterface<IAppletResource>(applet_resource); } -void Hid::ActivateDebugPad(Kernel::HLERequestContext& ctx) { +void Hid::ActivateDebugPad(HLERequestContext& ctx) { IPC::RequestParser rp{ctx}; const auto applet_resource_user_id{rp.Pop<u64>()}; @@ -409,7 +409,7 @@ void Hid::ActivateDebugPad(Kernel::HLERequestContext& ctx) { rb.Push(ResultSuccess); } -void Hid::ActivateTouchScreen(Kernel::HLERequestContext& ctx) { +void Hid::ActivateTouchScreen(HLERequestContext& ctx) { IPC::RequestParser rp{ctx}; const auto applet_resource_user_id{rp.Pop<u64>()}; @@ -421,7 +421,7 @@ void Hid::ActivateTouchScreen(Kernel::HLERequestContext& ctx) { rb.Push(ResultSuccess); } -void Hid::ActivateMouse(Kernel::HLERequestContext& ctx) { +void Hid::ActivateMouse(HLERequestContext& ctx) { IPC::RequestParser rp{ctx}; const auto applet_resource_user_id{rp.Pop<u64>()}; @@ -433,7 +433,7 @@ void Hid::ActivateMouse(Kernel::HLERequestContext& ctx) { rb.Push(ResultSuccess); } -void Hid::ActivateKeyboard(Kernel::HLERequestContext& ctx) { +void Hid::ActivateKeyboard(HLERequestContext& ctx) { IPC::RequestParser rp{ctx}; const auto applet_resource_user_id{rp.Pop<u64>()}; @@ -445,7 +445,7 @@ void Hid::ActivateKeyboard(Kernel::HLERequestContext& ctx) { rb.Push(ResultSuccess); } -void Hid::SendKeyboardLockKeyEvent(Kernel::HLERequestContext& ctx) { +void Hid::SendKeyboardLockKeyEvent(HLERequestContext& ctx) { IPC::RequestParser rp{ctx}; const auto flags{rp.Pop<u32>()}; @@ -455,7 +455,7 @@ void Hid::SendKeyboardLockKeyEvent(Kernel::HLERequestContext& ctx) { rb.Push(ResultSuccess); } -void Hid::ActivateXpad(Kernel::HLERequestContext& ctx) { +void Hid::ActivateXpad(HLERequestContext& ctx) { IPC::RequestParser rp{ctx}; struct Parameters { u32 basic_xpad_id; @@ -475,7 +475,7 @@ void Hid::ActivateXpad(Kernel::HLERequestContext& ctx) { rb.Push(ResultSuccess); } -void Hid::GetXpadIDs(Kernel::HLERequestContext& ctx) { +void Hid::GetXpadIDs(HLERequestContext& ctx) { IPC::RequestParser rp{ctx}; const auto applet_resource_user_id{rp.Pop<u64>()}; @@ -486,7 +486,7 @@ void Hid::GetXpadIDs(Kernel::HLERequestContext& ctx) { rb.Push(0); } -void Hid::ActivateSixAxisSensor(Kernel::HLERequestContext& ctx) { +void Hid::ActivateSixAxisSensor(HLERequestContext& ctx) { IPC::RequestParser rp{ctx}; struct Parameters { u32 basic_xpad_id; @@ -506,7 +506,7 @@ void Hid::ActivateSixAxisSensor(Kernel::HLERequestContext& ctx) { rb.Push(ResultSuccess); } -void Hid::DeactivateSixAxisSensor(Kernel::HLERequestContext& ctx) { +void Hid::DeactivateSixAxisSensor(HLERequestContext& ctx) { IPC::RequestParser rp{ctx}; struct Parameters { u32 basic_xpad_id; @@ -526,7 +526,7 @@ void Hid::DeactivateSixAxisSensor(Kernel::HLERequestContext& ctx) { rb.Push(ResultSuccess); } -void Hid::StartSixAxisSensor(Kernel::HLERequestContext& ctx) { +void Hid::StartSixAxisSensor(HLERequestContext& ctx) { IPC::RequestParser rp{ctx}; struct Parameters { Core::HID::SixAxisSensorHandle sixaxis_handle; @@ -549,7 +549,7 @@ void Hid::StartSixAxisSensor(Kernel::HLERequestContext& ctx) { rb.Push(result); } -void Hid::StopSixAxisSensor(Kernel::HLERequestContext& ctx) { +void Hid::StopSixAxisSensor(HLERequestContext& ctx) { IPC::RequestParser rp{ctx}; struct Parameters { Core::HID::SixAxisSensorHandle sixaxis_handle; @@ -572,7 +572,7 @@ void Hid::StopSixAxisSensor(Kernel::HLERequestContext& ctx) { rb.Push(result); } -void Hid::IsSixAxisSensorFusionEnabled(Kernel::HLERequestContext& ctx) { +void Hid::IsSixAxisSensorFusionEnabled(HLERequestContext& ctx) { IPC::RequestParser rp{ctx}; struct Parameters { Core::HID::SixAxisSensorHandle sixaxis_handle; @@ -598,7 +598,7 @@ void Hid::IsSixAxisSensorFusionEnabled(Kernel::HLERequestContext& ctx) { rb.Push(is_enabled); } -void Hid::EnableSixAxisSensorFusion(Kernel::HLERequestContext& ctx) { +void Hid::EnableSixAxisSensorFusion(HLERequestContext& ctx) { IPC::RequestParser rp{ctx}; struct Parameters { bool enable_sixaxis_sensor_fusion; @@ -625,7 +625,7 @@ void Hid::EnableSixAxisSensorFusion(Kernel::HLERequestContext& ctx) { rb.Push(result); } -void Hid::SetSixAxisSensorFusionParameters(Kernel::HLERequestContext& ctx) { +void Hid::SetSixAxisSensorFusionParameters(HLERequestContext& ctx) { IPC::RequestParser rp{ctx}; struct Parameters { Core::HID::SixAxisSensorHandle sixaxis_handle; @@ -652,7 +652,7 @@ void Hid::SetSixAxisSensorFusionParameters(Kernel::HLERequestContext& ctx) { rb.Push(result); } -void Hid::GetSixAxisSensorFusionParameters(Kernel::HLERequestContext& ctx) { +void Hid::GetSixAxisSensorFusionParameters(HLERequestContext& ctx) { IPC::RequestParser rp{ctx}; struct Parameters { Core::HID::SixAxisSensorHandle sixaxis_handle; @@ -679,7 +679,7 @@ void Hid::GetSixAxisSensorFusionParameters(Kernel::HLERequestContext& ctx) { rb.PushRaw(fusion_parameters); } -void Hid::ResetSixAxisSensorFusionParameters(Kernel::HLERequestContext& ctx) { +void Hid::ResetSixAxisSensorFusionParameters(HLERequestContext& ctx) { IPC::RequestParser rp{ctx}; struct Parameters { Core::HID::SixAxisSensorHandle sixaxis_handle; @@ -690,7 +690,7 @@ void Hid::ResetSixAxisSensorFusionParameters(Kernel::HLERequestContext& ctx) { const auto parameters{rp.PopRaw<Parameters>()}; - // Since these parameters are unknow just use what HW outputs + // Since these parameters are unknown just use what HW outputs const Core::HID::SixAxisSensorFusionParameters fusion_parameters{ .parameter1 = 0.03f, .parameter2 = 0.4f, @@ -713,7 +713,7 @@ void Hid::ResetSixAxisSensorFusionParameters(Kernel::HLERequestContext& ctx) { rb.Push(result2); } -void Hid::SetGyroscopeZeroDriftMode(Kernel::HLERequestContext& ctx) { +void Hid::SetGyroscopeZeroDriftMode(HLERequestContext& ctx) { IPC::RequestParser rp{ctx}; const auto sixaxis_handle{rp.PopRaw<Core::HID::SixAxisSensorHandle>()}; const auto drift_mode{rp.PopEnum<Core::HID::GyroscopeZeroDriftMode>()}; @@ -732,7 +732,7 @@ void Hid::SetGyroscopeZeroDriftMode(Kernel::HLERequestContext& ctx) { rb.Push(result); } -void Hid::GetGyroscopeZeroDriftMode(Kernel::HLERequestContext& ctx) { +void Hid::GetGyroscopeZeroDriftMode(HLERequestContext& ctx) { IPC::RequestParser rp{ctx}; struct Parameters { Core::HID::SixAxisSensorHandle sixaxis_handle; @@ -757,7 +757,7 @@ void Hid::GetGyroscopeZeroDriftMode(Kernel::HLERequestContext& ctx) { rb.PushEnum(drift_mode); } -void Hid::ResetGyroscopeZeroDriftMode(Kernel::HLERequestContext& ctx) { +void Hid::ResetGyroscopeZeroDriftMode(HLERequestContext& ctx) { IPC::RequestParser rp{ctx}; struct Parameters { Core::HID::SixAxisSensorHandle sixaxis_handle; @@ -781,7 +781,7 @@ void Hid::ResetGyroscopeZeroDriftMode(Kernel::HLERequestContext& ctx) { rb.Push(result); } -void Hid::IsSixAxisSensorAtRest(Kernel::HLERequestContext& ctx) { +void Hid::IsSixAxisSensorAtRest(HLERequestContext& ctx) { IPC::RequestParser rp{ctx}; struct Parameters { Core::HID::SixAxisSensorHandle sixaxis_handle; @@ -806,7 +806,7 @@ void Hid::IsSixAxisSensorAtRest(Kernel::HLERequestContext& ctx) { rb.Push(is_at_rest); } -void Hid::IsFirmwareUpdateAvailableForSixAxisSensor(Kernel::HLERequestContext& ctx) { +void Hid::IsFirmwareUpdateAvailableForSixAxisSensor(HLERequestContext& ctx) { IPC::RequestParser rp{ctx}; struct Parameters { Core::HID::SixAxisSensorHandle sixaxis_handle; @@ -833,7 +833,7 @@ void Hid::IsFirmwareUpdateAvailableForSixAxisSensor(Kernel::HLERequestContext& c rb.Push(is_firmware_available); } -void Hid::EnableSixAxisSensorUnalteredPassthrough(Kernel::HLERequestContext& ctx) { +void Hid::EnableSixAxisSensorUnalteredPassthrough(HLERequestContext& ctx) { IPC::RequestParser rp{ctx}; struct Parameters { bool enabled; @@ -859,7 +859,7 @@ void Hid::EnableSixAxisSensorUnalteredPassthrough(Kernel::HLERequestContext& ctx rb.Push(result); } -void Hid::IsSixAxisSensorUnalteredPassthroughEnabled(Kernel::HLERequestContext& ctx) { +void Hid::IsSixAxisSensorUnalteredPassthroughEnabled(HLERequestContext& ctx) { IPC::RequestParser rp{ctx}; struct Parameters { Core::HID::SixAxisSensorHandle sixaxis_handle; @@ -886,7 +886,7 @@ void Hid::IsSixAxisSensorUnalteredPassthroughEnabled(Kernel::HLERequestContext& rb.Push(is_unaltered_sisxaxis_enabled); } -void Hid::LoadSixAxisSensorCalibrationParameter(Kernel::HLERequestContext& ctx) { +void Hid::LoadSixAxisSensorCalibrationParameter(HLERequestContext& ctx) { IPC::RequestParser rp{ctx}; struct Parameters { Core::HID::SixAxisSensorHandle sixaxis_handle; @@ -916,7 +916,7 @@ void Hid::LoadSixAxisSensorCalibrationParameter(Kernel::HLERequestContext& ctx) rb.Push(result); } -void Hid::GetSixAxisSensorIcInformation(Kernel::HLERequestContext& ctx) { +void Hid::GetSixAxisSensorIcInformation(HLERequestContext& ctx) { IPC::RequestParser rp{ctx}; struct Parameters { Core::HID::SixAxisSensorHandle sixaxis_handle; @@ -946,7 +946,7 @@ void Hid::GetSixAxisSensorIcInformation(Kernel::HLERequestContext& ctx) { rb.Push(result); } -void Hid::ResetIsSixAxisSensorDeviceNewlyAssigned(Kernel::HLERequestContext& ctx) { +void Hid::ResetIsSixAxisSensorDeviceNewlyAssigned(HLERequestContext& ctx) { IPC::RequestParser rp{ctx}; struct Parameters { Core::HID::SixAxisSensorHandle sixaxis_handle; @@ -971,7 +971,7 @@ void Hid::ResetIsSixAxisSensorDeviceNewlyAssigned(Kernel::HLERequestContext& ctx rb.Push(result); } -void Hid::ActivateGesture(Kernel::HLERequestContext& ctx) { +void Hid::ActivateGesture(HLERequestContext& ctx) { IPC::RequestParser rp{ctx}; struct Parameters { u32 unknown; @@ -991,7 +991,7 @@ void Hid::ActivateGesture(Kernel::HLERequestContext& ctx) { rb.Push(ResultSuccess); } -void Hid::SetSupportedNpadStyleSet(Kernel::HLERequestContext& ctx) { +void Hid::SetSupportedNpadStyleSet(HLERequestContext& ctx) { IPC::RequestParser rp{ctx}; struct Parameters { Core::HID::NpadStyleSet supported_styleset; @@ -1012,7 +1012,7 @@ void Hid::SetSupportedNpadStyleSet(Kernel::HLERequestContext& ctx) { rb.Push(ResultSuccess); } -void Hid::GetSupportedNpadStyleSet(Kernel::HLERequestContext& ctx) { +void Hid::GetSupportedNpadStyleSet(HLERequestContext& ctx) { IPC::RequestParser rp{ctx}; const auto applet_resource_user_id{rp.Pop<u64>()}; @@ -1025,7 +1025,7 @@ void Hid::GetSupportedNpadStyleSet(Kernel::HLERequestContext& ctx) { .raw); } -void Hid::SetSupportedNpadIdType(Kernel::HLERequestContext& ctx) { +void Hid::SetSupportedNpadIdType(HLERequestContext& ctx) { IPC::RequestParser rp{ctx}; const auto applet_resource_user_id{rp.Pop<u64>()}; @@ -1038,7 +1038,7 @@ void Hid::SetSupportedNpadIdType(Kernel::HLERequestContext& ctx) { rb.Push(result); } -void Hid::ActivateNpad(Kernel::HLERequestContext& ctx) { +void Hid::ActivateNpad(HLERequestContext& ctx) { IPC::RequestParser rp{ctx}; const auto applet_resource_user_id{rp.Pop<u64>()}; @@ -1050,7 +1050,7 @@ void Hid::ActivateNpad(Kernel::HLERequestContext& ctx) { rb.Push(ResultSuccess); } -void Hid::DeactivateNpad(Kernel::HLERequestContext& ctx) { +void Hid::DeactivateNpad(HLERequestContext& ctx) { IPC::RequestParser rp{ctx}; const auto applet_resource_user_id{rp.Pop<u64>()}; @@ -1062,7 +1062,7 @@ void Hid::DeactivateNpad(Kernel::HLERequestContext& ctx) { rb.Push(ResultSuccess); } -void Hid::AcquireNpadStyleSetUpdateEventHandle(Kernel::HLERequestContext& ctx) { +void Hid::AcquireNpadStyleSetUpdateEventHandle(HLERequestContext& ctx) { IPC::RequestParser rp{ctx}; struct Parameters { Core::HID::NpadIdType npad_id; @@ -1087,7 +1087,7 @@ void Hid::AcquireNpadStyleSetUpdateEventHandle(Kernel::HLERequestContext& ctx) { .GetStyleSetChangedEvent(parameters.npad_id)); } -void Hid::DisconnectNpad(Kernel::HLERequestContext& ctx) { +void Hid::DisconnectNpad(HLERequestContext& ctx) { IPC::RequestParser rp{ctx}; struct Parameters { Core::HID::NpadIdType npad_id; @@ -1108,7 +1108,7 @@ void Hid::DisconnectNpad(Kernel::HLERequestContext& ctx) { rb.Push(ResultSuccess); } -void Hid::GetPlayerLedPattern(Kernel::HLERequestContext& ctx) { +void Hid::GetPlayerLedPattern(HLERequestContext& ctx) { IPC::RequestParser rp{ctx}; const auto npad_id{rp.PopEnum<Core::HID::NpadIdType>()}; @@ -1123,7 +1123,7 @@ void Hid::GetPlayerLedPattern(Kernel::HLERequestContext& ctx) { rb.Push(pattern.raw); } -void Hid::ActivateNpadWithRevision(Kernel::HLERequestContext& ctx) { +void Hid::ActivateNpadWithRevision(HLERequestContext& ctx) { // Should have no effect with how our npad sets up the data IPC::RequestParser rp{ctx}; struct Parameters { @@ -1144,7 +1144,7 @@ void Hid::ActivateNpadWithRevision(Kernel::HLERequestContext& ctx) { rb.Push(ResultSuccess); } -void Hid::SetNpadJoyHoldType(Kernel::HLERequestContext& ctx) { +void Hid::SetNpadJoyHoldType(HLERequestContext& ctx) { IPC::RequestParser rp{ctx}; const auto applet_resource_user_id{rp.Pop<u64>()}; const auto hold_type{rp.PopEnum<Controller_NPad::NpadJoyHoldType>()}; @@ -1158,7 +1158,7 @@ void Hid::SetNpadJoyHoldType(Kernel::HLERequestContext& ctx) { rb.Push(ResultSuccess); } -void Hid::GetNpadJoyHoldType(Kernel::HLERequestContext& ctx) { +void Hid::GetNpadJoyHoldType(HLERequestContext& ctx) { IPC::RequestParser rp{ctx}; const auto applet_resource_user_id{rp.Pop<u64>()}; @@ -1169,7 +1169,7 @@ void Hid::GetNpadJoyHoldType(Kernel::HLERequestContext& ctx) { rb.PushEnum(applet_resource->GetController<Controller_NPad>(HidController::NPad).GetHoldType()); } -void Hid::SetNpadJoyAssignmentModeSingleByDefault(Kernel::HLERequestContext& ctx) { +void Hid::SetNpadJoyAssignmentModeSingleByDefault(HLERequestContext& ctx) { IPC::RequestParser rp{ctx}; struct Parameters { Core::HID::NpadIdType npad_id; @@ -1191,7 +1191,7 @@ void Hid::SetNpadJoyAssignmentModeSingleByDefault(Kernel::HLERequestContext& ctx rb.Push(ResultSuccess); } -void Hid::SetNpadJoyAssignmentModeSingle(Kernel::HLERequestContext& ctx) { +void Hid::SetNpadJoyAssignmentModeSingle(HLERequestContext& ctx) { IPC::RequestParser rp{ctx}; struct Parameters { Core::HID::NpadIdType npad_id; @@ -1215,7 +1215,7 @@ void Hid::SetNpadJoyAssignmentModeSingle(Kernel::HLERequestContext& ctx) { rb.Push(ResultSuccess); } -void Hid::SetNpadJoyAssignmentModeDual(Kernel::HLERequestContext& ctx) { +void Hid::SetNpadJoyAssignmentModeDual(HLERequestContext& ctx) { IPC::RequestParser rp{ctx}; struct Parameters { Core::HID::NpadIdType npad_id; @@ -1236,7 +1236,7 @@ void Hid::SetNpadJoyAssignmentModeDual(Kernel::HLERequestContext& ctx) { rb.Push(ResultSuccess); } -void Hid::MergeSingleJoyAsDualJoy(Kernel::HLERequestContext& ctx) { +void Hid::MergeSingleJoyAsDualJoy(HLERequestContext& ctx) { IPC::RequestParser rp{ctx}; const auto npad_id_1{rp.PopEnum<Core::HID::NpadIdType>()}; const auto npad_id_2{rp.PopEnum<Core::HID::NpadIdType>()}; @@ -1252,7 +1252,7 @@ void Hid::MergeSingleJoyAsDualJoy(Kernel::HLERequestContext& ctx) { rb.Push(result); } -void Hid::StartLrAssignmentMode(Kernel::HLERequestContext& ctx) { +void Hid::StartLrAssignmentMode(HLERequestContext& ctx) { IPC::RequestParser rp{ctx}; const auto applet_resource_user_id{rp.Pop<u64>()}; @@ -1264,7 +1264,7 @@ void Hid::StartLrAssignmentMode(Kernel::HLERequestContext& ctx) { rb.Push(ResultSuccess); } -void Hid::StopLrAssignmentMode(Kernel::HLERequestContext& ctx) { +void Hid::StopLrAssignmentMode(HLERequestContext& ctx) { IPC::RequestParser rp{ctx}; const auto applet_resource_user_id{rp.Pop<u64>()}; @@ -1276,7 +1276,7 @@ void Hid::StopLrAssignmentMode(Kernel::HLERequestContext& ctx) { rb.Push(ResultSuccess); } -void Hid::SetNpadHandheldActivationMode(Kernel::HLERequestContext& ctx) { +void Hid::SetNpadHandheldActivationMode(HLERequestContext& ctx) { IPC::RequestParser rp{ctx}; const auto applet_resource_user_id{rp.Pop<u64>()}; const auto activation_mode{rp.PopEnum<Controller_NPad::NpadHandheldActivationMode>()}; @@ -1291,7 +1291,7 @@ void Hid::SetNpadHandheldActivationMode(Kernel::HLERequestContext& ctx) { rb.Push(ResultSuccess); } -void Hid::GetNpadHandheldActivationMode(Kernel::HLERequestContext& ctx) { +void Hid::GetNpadHandheldActivationMode(HLERequestContext& ctx) { IPC::RequestParser rp{ctx}; const auto applet_resource_user_id{rp.Pop<u64>()}; @@ -1303,7 +1303,7 @@ void Hid::GetNpadHandheldActivationMode(Kernel::HLERequestContext& ctx) { .GetNpadHandheldActivationMode()); } -void Hid::SwapNpadAssignment(Kernel::HLERequestContext& ctx) { +void Hid::SwapNpadAssignment(HLERequestContext& ctx) { IPC::RequestParser rp{ctx}; const auto npad_id_1{rp.PopEnum<Core::HID::NpadIdType>()}; const auto npad_id_2{rp.PopEnum<Core::HID::NpadIdType>()}; @@ -1319,7 +1319,7 @@ void Hid::SwapNpadAssignment(Kernel::HLERequestContext& ctx) { rb.Push(result); } -void Hid::IsUnintendedHomeButtonInputProtectionEnabled(Kernel::HLERequestContext& ctx) { +void Hid::IsUnintendedHomeButtonInputProtectionEnabled(HLERequestContext& ctx) { IPC::RequestParser rp{ctx}; struct Parameters { Core::HID::NpadIdType npad_id; @@ -1343,7 +1343,7 @@ void Hid::IsUnintendedHomeButtonInputProtectionEnabled(Kernel::HLERequestContext rb.Push(is_enabled); } -void Hid::EnableUnintendedHomeButtonInputProtection(Kernel::HLERequestContext& ctx) { +void Hid::EnableUnintendedHomeButtonInputProtection(HLERequestContext& ctx) { IPC::RequestParser rp{ctx}; struct Parameters { bool unintended_home_button_input_protection; @@ -1369,7 +1369,7 @@ void Hid::EnableUnintendedHomeButtonInputProtection(Kernel::HLERequestContext& c rb.Push(result); } -void Hid::SetNpadAnalogStickUseCenterClamp(Kernel::HLERequestContext& ctx) { +void Hid::SetNpadAnalogStickUseCenterClamp(HLERequestContext& ctx) { IPC::RequestParser rp{ctx}; struct Parameters { bool analog_stick_use_center_clamp; @@ -1392,7 +1392,7 @@ void Hid::SetNpadAnalogStickUseCenterClamp(Kernel::HLERequestContext& ctx) { rb.Push(ResultSuccess); } -void Hid::SetNpadCaptureButtonAssignment(Kernel::HLERequestContext& ctx) { +void Hid::SetNpadCaptureButtonAssignment(HLERequestContext& ctx) { IPC::RequestParser rp{ctx}; struct Parameters { Core::HID::NpadStyleSet npad_styleset; @@ -1412,7 +1412,7 @@ void Hid::SetNpadCaptureButtonAssignment(Kernel::HLERequestContext& ctx) { rb.Push(ResultSuccess); } -void Hid::ClearNpadCaptureButtonAssignment(Kernel::HLERequestContext& ctx) { +void Hid::ClearNpadCaptureButtonAssignment(HLERequestContext& ctx) { IPC::RequestParser rp{ctx}; const auto applet_resource_user_id{rp.Pop<u64>()}; @@ -1423,7 +1423,7 @@ void Hid::ClearNpadCaptureButtonAssignment(Kernel::HLERequestContext& ctx) { rb.Push(ResultSuccess); } -void Hid::GetVibrationDeviceInfo(Kernel::HLERequestContext& ctx) { +void Hid::GetVibrationDeviceInfo(HLERequestContext& ctx) { IPC::RequestParser rp{ctx}; const auto vibration_device_handle{rp.PopRaw<Core::HID::VibrationDeviceHandle>()}; const auto& controller = @@ -1483,7 +1483,7 @@ void Hid::GetVibrationDeviceInfo(Kernel::HLERequestContext& ctx) { rb.PushRaw(vibration_device_info); } -void Hid::SendVibrationValue(Kernel::HLERequestContext& ctx) { +void Hid::SendVibrationValue(HLERequestContext& ctx) { IPC::RequestParser rp{ctx}; struct Parameters { Core::HID::VibrationDeviceHandle vibration_device_handle; @@ -1508,7 +1508,7 @@ void Hid::SendVibrationValue(Kernel::HLERequestContext& ctx) { rb.Push(ResultSuccess); } -void Hid::GetActualVibrationValue(Kernel::HLERequestContext& ctx) { +void Hid::GetActualVibrationValue(HLERequestContext& ctx) { IPC::RequestParser rp{ctx}; struct Parameters { Core::HID::VibrationDeviceHandle vibration_device_handle; @@ -1531,7 +1531,7 @@ void Hid::GetActualVibrationValue(Kernel::HLERequestContext& ctx) { .GetLastVibration(parameters.vibration_device_handle)); } -void Hid::CreateActiveVibrationDeviceList(Kernel::HLERequestContext& ctx) { +void Hid::CreateActiveVibrationDeviceList(HLERequestContext& ctx) { LOG_DEBUG(Service_HID, "called"); IPC::ResponseBuilder rb{ctx, 2, 0, 1}; @@ -1539,7 +1539,7 @@ void Hid::CreateActiveVibrationDeviceList(Kernel::HLERequestContext& ctx) { rb.PushIpcInterface<IActiveVibrationDeviceList>(system, applet_resource); } -void Hid::PermitVibration(Kernel::HLERequestContext& ctx) { +void Hid::PermitVibration(HLERequestContext& ctx) { IPC::RequestParser rp{ctx}; const auto can_vibrate{rp.Pop<bool>()}; @@ -1553,7 +1553,7 @@ void Hid::PermitVibration(Kernel::HLERequestContext& ctx) { rb.Push(ResultSuccess); } -void Hid::IsVibrationPermitted(Kernel::HLERequestContext& ctx) { +void Hid::IsVibrationPermitted(HLERequestContext& ctx) { LOG_DEBUG(Service_HID, "called"); // nnSDK checks if a float is greater than zero. We return the bool we stored earlier @@ -1564,7 +1564,7 @@ void Hid::IsVibrationPermitted(Kernel::HLERequestContext& ctx) { rb.Push(is_enabled); } -void Hid::SendVibrationValues(Kernel::HLERequestContext& ctx) { +void Hid::SendVibrationValues(HLERequestContext& ctx) { IPC::RequestParser rp{ctx}; const auto applet_resource_user_id{rp.Pop<u64>()}; @@ -1588,7 +1588,7 @@ void Hid::SendVibrationValues(Kernel::HLERequestContext& ctx) { rb.Push(ResultSuccess); } -void Hid::SendVibrationGcErmCommand(Kernel::HLERequestContext& ctx) { +void Hid::SendVibrationGcErmCommand(HLERequestContext& ctx) { IPC::RequestParser rp{ctx}; struct Parameters { Core::HID::VibrationDeviceHandle vibration_device_handle; @@ -1649,7 +1649,7 @@ void Hid::SendVibrationGcErmCommand(Kernel::HLERequestContext& ctx) { rb.Push(ResultSuccess); } -void Hid::GetActualVibrationGcErmCommand(Kernel::HLERequestContext& ctx) { +void Hid::GetActualVibrationGcErmCommand(HLERequestContext& ctx) { IPC::RequestParser rp{ctx}; struct Parameters { Core::HID::VibrationDeviceHandle vibration_device_handle; @@ -1691,7 +1691,7 @@ void Hid::GetActualVibrationGcErmCommand(Kernel::HLERequestContext& ctx) { rb.PushEnum(gc_erm_command); } -void Hid::BeginPermitVibrationSession(Kernel::HLERequestContext& ctx) { +void Hid::BeginPermitVibrationSession(HLERequestContext& ctx) { IPC::RequestParser rp{ctx}; const auto applet_resource_user_id{rp.Pop<u64>()}; @@ -1704,7 +1704,7 @@ void Hid::BeginPermitVibrationSession(Kernel::HLERequestContext& ctx) { rb.Push(ResultSuccess); } -void Hid::EndPermitVibrationSession(Kernel::HLERequestContext& ctx) { +void Hid::EndPermitVibrationSession(HLERequestContext& ctx) { applet_resource->GetController<Controller_NPad>(HidController::NPad) .SetPermitVibrationSession(false); @@ -1714,7 +1714,7 @@ void Hid::EndPermitVibrationSession(Kernel::HLERequestContext& ctx) { rb.Push(ResultSuccess); } -void Hid::IsVibrationDeviceMounted(Kernel::HLERequestContext& ctx) { +void Hid::IsVibrationDeviceMounted(HLERequestContext& ctx) { IPC::RequestParser rp{ctx}; struct Parameters { Core::HID::VibrationDeviceHandle vibration_device_handle; @@ -1737,7 +1737,7 @@ void Hid::IsVibrationDeviceMounted(Kernel::HLERequestContext& ctx) { .IsVibrationDeviceMounted(parameters.vibration_device_handle)); } -void Hid::ActivateConsoleSixAxisSensor(Kernel::HLERequestContext& ctx) { +void Hid::ActivateConsoleSixAxisSensor(HLERequestContext& ctx) { IPC::RequestParser rp{ctx}; const auto applet_resource_user_id{rp.Pop<u64>()}; @@ -1749,7 +1749,7 @@ void Hid::ActivateConsoleSixAxisSensor(Kernel::HLERequestContext& ctx) { rb.Push(ResultSuccess); } -void Hid::StartConsoleSixAxisSensor(Kernel::HLERequestContext& ctx) { +void Hid::StartConsoleSixAxisSensor(HLERequestContext& ctx) { IPC::RequestParser rp{ctx}; struct Parameters { Core::HID::ConsoleSixAxisSensorHandle console_sixaxis_handle; @@ -1769,7 +1769,7 @@ void Hid::StartConsoleSixAxisSensor(Kernel::HLERequestContext& ctx) { rb.Push(ResultSuccess); } -void Hid::StopConsoleSixAxisSensor(Kernel::HLERequestContext& ctx) { +void Hid::StopConsoleSixAxisSensor(HLERequestContext& ctx) { IPC::RequestParser rp{ctx}; struct Parameters { Core::HID::ConsoleSixAxisSensorHandle console_sixaxis_handle; @@ -1789,7 +1789,7 @@ void Hid::StopConsoleSixAxisSensor(Kernel::HLERequestContext& ctx) { rb.Push(ResultSuccess); } -void Hid::ActivateSevenSixAxisSensor(Kernel::HLERequestContext& ctx) { +void Hid::ActivateSevenSixAxisSensor(HLERequestContext& ctx) { IPC::RequestParser rp{ctx}; const auto applet_resource_user_id{rp.Pop<u64>()}; @@ -1801,7 +1801,7 @@ void Hid::ActivateSevenSixAxisSensor(Kernel::HLERequestContext& ctx) { rb.Push(ResultSuccess); } -void Hid::StartSevenSixAxisSensor(Kernel::HLERequestContext& ctx) { +void Hid::StartSevenSixAxisSensor(HLERequestContext& ctx) { IPC::RequestParser rp{ctx}; const auto applet_resource_user_id{rp.Pop<u64>()}; @@ -1812,7 +1812,7 @@ void Hid::StartSevenSixAxisSensor(Kernel::HLERequestContext& ctx) { rb.Push(ResultSuccess); } -void Hid::StopSevenSixAxisSensor(Kernel::HLERequestContext& ctx) { +void Hid::StopSevenSixAxisSensor(HLERequestContext& ctx) { IPC::RequestParser rp{ctx}; const auto applet_resource_user_id{rp.Pop<u64>()}; @@ -1823,7 +1823,7 @@ void Hid::StopSevenSixAxisSensor(Kernel::HLERequestContext& ctx) { rb.Push(ResultSuccess); } -void Hid::InitializeSevenSixAxisSensor(Kernel::HLERequestContext& ctx) { +void Hid::InitializeSevenSixAxisSensor(HLERequestContext& ctx) { IPC::RequestParser rp{ctx}; const auto applet_resource_user_id{rp.Pop<u64>()}; const auto t_mem_1_size{rp.Pop<u64>()}; @@ -1873,7 +1873,7 @@ void Hid::InitializeSevenSixAxisSensor(Kernel::HLERequestContext& ctx) { rb.Push(ResultSuccess); } -void Hid::FinalizeSevenSixAxisSensor(Kernel::HLERequestContext& ctx) { +void Hid::FinalizeSevenSixAxisSensor(HLERequestContext& ctx) { IPC::RequestParser rp{ctx}; const auto applet_resource_user_id{rp.Pop<u64>()}; @@ -1884,7 +1884,7 @@ void Hid::FinalizeSevenSixAxisSensor(Kernel::HLERequestContext& ctx) { rb.Push(ResultSuccess); } -void Hid::ResetSevenSixAxisSensorTimestamp(Kernel::HLERequestContext& ctx) { +void Hid::ResetSevenSixAxisSensorTimestamp(HLERequestContext& ctx) { IPC::RequestParser rp{ctx}; const auto applet_resource_user_id{rp.Pop<u64>()}; @@ -1897,7 +1897,7 @@ void Hid::ResetSevenSixAxisSensorTimestamp(Kernel::HLERequestContext& ctx) { rb.Push(ResultSuccess); } -void Hid::IsUsbFullKeyControllerEnabled(Kernel::HLERequestContext& ctx) { +void Hid::IsUsbFullKeyControllerEnabled(HLERequestContext& ctx) { IPC::RequestParser rp{ctx}; LOG_WARNING(Service_HID, "(STUBBED) called"); @@ -1907,7 +1907,7 @@ void Hid::IsUsbFullKeyControllerEnabled(Kernel::HLERequestContext& ctx) { rb.Push(false); } -void Hid::GetPalmaConnectionHandle(Kernel::HLERequestContext& ctx) { +void Hid::GetPalmaConnectionHandle(HLERequestContext& ctx) { IPC::RequestParser rp{ctx}; struct Parameters { Core::HID::NpadIdType npad_id; @@ -1930,7 +1930,7 @@ void Hid::GetPalmaConnectionHandle(Kernel::HLERequestContext& ctx) { rb.PushRaw(handle); } -void Hid::InitializePalma(Kernel::HLERequestContext& ctx) { +void Hid::InitializePalma(HLERequestContext& ctx) { IPC::RequestParser rp{ctx}; const auto connection_handle{rp.PopRaw<Controller_Palma::PalmaConnectionHandle>()}; @@ -1943,7 +1943,7 @@ void Hid::InitializePalma(Kernel::HLERequestContext& ctx) { rb.Push(result); } -void Hid::AcquirePalmaOperationCompleteEvent(Kernel::HLERequestContext& ctx) { +void Hid::AcquirePalmaOperationCompleteEvent(HLERequestContext& ctx) { IPC::RequestParser rp{ctx}; const auto connection_handle{rp.PopRaw<Controller_Palma::PalmaConnectionHandle>()}; @@ -1956,7 +1956,7 @@ void Hid::AcquirePalmaOperationCompleteEvent(Kernel::HLERequestContext& ctx) { rb.PushCopyObjects(controller.AcquirePalmaOperationCompleteEvent(connection_handle)); } -void Hid::GetPalmaOperationInfo(Kernel::HLERequestContext& ctx) { +void Hid::GetPalmaOperationInfo(HLERequestContext& ctx) { IPC::RequestParser rp{ctx}; const auto connection_handle{rp.PopRaw<Controller_Palma::PalmaConnectionHandle>()}; @@ -1978,7 +1978,7 @@ void Hid::GetPalmaOperationInfo(Kernel::HLERequestContext& ctx) { rb.Push(static_cast<u64>(operation_type)); } -void Hid::PlayPalmaActivity(Kernel::HLERequestContext& ctx) { +void Hid::PlayPalmaActivity(HLERequestContext& ctx) { IPC::RequestParser rp{ctx}; const auto connection_handle{rp.PopRaw<Controller_Palma::PalmaConnectionHandle>()}; const auto palma_activity{rp.Pop<u64>()}; @@ -1993,7 +1993,7 @@ void Hid::PlayPalmaActivity(Kernel::HLERequestContext& ctx) { rb.Push(result); } -void Hid::SetPalmaFrModeType(Kernel::HLERequestContext& ctx) { +void Hid::SetPalmaFrModeType(HLERequestContext& ctx) { IPC::RequestParser rp{ctx}; const auto connection_handle{rp.PopRaw<Controller_Palma::PalmaConnectionHandle>()}; const auto fr_mode{rp.PopEnum<Controller_Palma::PalmaFrModeType>()}; @@ -2008,7 +2008,7 @@ void Hid::SetPalmaFrModeType(Kernel::HLERequestContext& ctx) { rb.Push(result); } -void Hid::ReadPalmaStep(Kernel::HLERequestContext& ctx) { +void Hid::ReadPalmaStep(HLERequestContext& ctx) { IPC::RequestParser rp{ctx}; const auto connection_handle{rp.PopRaw<Controller_Palma::PalmaConnectionHandle>()}; @@ -2021,7 +2021,7 @@ void Hid::ReadPalmaStep(Kernel::HLERequestContext& ctx) { rb.Push(result); } -void Hid::EnablePalmaStep(Kernel::HLERequestContext& ctx) { +void Hid::EnablePalmaStep(HLERequestContext& ctx) { IPC::RequestParser rp{ctx}; struct Parameters { bool is_enabled; @@ -2043,7 +2043,7 @@ void Hid::EnablePalmaStep(Kernel::HLERequestContext& ctx) { rb.Push(result); } -void Hid::ResetPalmaStep(Kernel::HLERequestContext& ctx) { +void Hid::ResetPalmaStep(HLERequestContext& ctx) { IPC::RequestParser rp{ctx}; const auto connection_handle{rp.PopRaw<Controller_Palma::PalmaConnectionHandle>()}; @@ -2056,21 +2056,21 @@ void Hid::ResetPalmaStep(Kernel::HLERequestContext& ctx) { rb.Push(result); } -void Hid::ReadPalmaApplicationSection(Kernel::HLERequestContext& ctx) { +void Hid::ReadPalmaApplicationSection(HLERequestContext& ctx) { LOG_WARNING(Service_HID, "(STUBBED) called"); IPC::ResponseBuilder rb{ctx, 2}; rb.Push(ResultSuccess); } -void Hid::WritePalmaApplicationSection(Kernel::HLERequestContext& ctx) { +void Hid::WritePalmaApplicationSection(HLERequestContext& ctx) { LOG_WARNING(Service_HID, "(STUBBED) called"); IPC::ResponseBuilder rb{ctx, 2}; rb.Push(ResultSuccess); } -void Hid::ReadPalmaUniqueCode(Kernel::HLERequestContext& ctx) { +void Hid::ReadPalmaUniqueCode(HLERequestContext& ctx) { IPC::RequestParser rp{ctx}; const auto connection_handle{rp.PopRaw<Controller_Palma::PalmaConnectionHandle>()}; @@ -2083,7 +2083,7 @@ void Hid::ReadPalmaUniqueCode(Kernel::HLERequestContext& ctx) { rb.Push(ResultSuccess); } -void Hid::SetPalmaUniqueCodeInvalid(Kernel::HLERequestContext& ctx) { +void Hid::SetPalmaUniqueCodeInvalid(HLERequestContext& ctx) { IPC::RequestParser rp{ctx}; const auto connection_handle{rp.PopRaw<Controller_Palma::PalmaConnectionHandle>()}; @@ -2096,14 +2096,14 @@ void Hid::SetPalmaUniqueCodeInvalid(Kernel::HLERequestContext& ctx) { rb.Push(ResultSuccess); } -void Hid::WritePalmaActivityEntry(Kernel::HLERequestContext& ctx) { +void Hid::WritePalmaActivityEntry(HLERequestContext& ctx) { LOG_CRITICAL(Service_HID, "(STUBBED) called"); IPC::ResponseBuilder rb{ctx, 2}; rb.Push(ResultSuccess); } -void Hid::WritePalmaRgbLedPatternEntry(Kernel::HLERequestContext& ctx) { +void Hid::WritePalmaRgbLedPatternEntry(HLERequestContext& ctx) { IPC::RequestParser rp{ctx}; const auto connection_handle{rp.PopRaw<Controller_Palma::PalmaConnectionHandle>()}; const auto unknown{rp.Pop<u64>()}; @@ -2120,7 +2120,7 @@ void Hid::WritePalmaRgbLedPatternEntry(Kernel::HLERequestContext& ctx) { rb.Push(ResultSuccess); } -void Hid::WritePalmaWaveEntry(Kernel::HLERequestContext& ctx) { +void Hid::WritePalmaWaveEntry(HLERequestContext& ctx) { IPC::RequestParser rp{ctx}; const auto connection_handle{rp.PopRaw<Controller_Palma::PalmaConnectionHandle>()}; const auto wave_set{rp.PopEnum<Controller_Palma::PalmaWaveSet>()}; @@ -2155,7 +2155,7 @@ void Hid::WritePalmaWaveEntry(Kernel::HLERequestContext& ctx) { rb.Push(ResultSuccess); } -void Hid::SetPalmaDataBaseIdentificationVersion(Kernel::HLERequestContext& ctx) { +void Hid::SetPalmaDataBaseIdentificationVersion(HLERequestContext& ctx) { IPC::RequestParser rp{ctx}; struct Parameters { s32 database_id_version; @@ -2177,7 +2177,7 @@ void Hid::SetPalmaDataBaseIdentificationVersion(Kernel::HLERequestContext& ctx) rb.Push(ResultSuccess); } -void Hid::GetPalmaDataBaseIdentificationVersion(Kernel::HLERequestContext& ctx) { +void Hid::GetPalmaDataBaseIdentificationVersion(HLERequestContext& ctx) { IPC::RequestParser rp{ctx}; const auto connection_handle{rp.PopRaw<Controller_Palma::PalmaConnectionHandle>()}; @@ -2190,14 +2190,14 @@ void Hid::GetPalmaDataBaseIdentificationVersion(Kernel::HLERequestContext& ctx) rb.Push(ResultSuccess); } -void Hid::SuspendPalmaFeature(Kernel::HLERequestContext& ctx) { +void Hid::SuspendPalmaFeature(HLERequestContext& ctx) { LOG_WARNING(Service_HID, "(STUBBED) called"); IPC::ResponseBuilder rb{ctx, 2}; rb.Push(ResultSuccess); } -void Hid::GetPalmaOperationResult(Kernel::HLERequestContext& ctx) { +void Hid::GetPalmaOperationResult(HLERequestContext& ctx) { IPC::RequestParser rp{ctx}; const auto connection_handle{rp.PopRaw<Controller_Palma::PalmaConnectionHandle>()}; @@ -2210,21 +2210,21 @@ void Hid::GetPalmaOperationResult(Kernel::HLERequestContext& ctx) { rb.Push(result); } -void Hid::ReadPalmaPlayLog(Kernel::HLERequestContext& ctx) { +void Hid::ReadPalmaPlayLog(HLERequestContext& ctx) { LOG_WARNING(Service_HID, "(STUBBED) called"); IPC::ResponseBuilder rb{ctx, 2}; rb.Push(ResultSuccess); } -void Hid::ResetPalmaPlayLog(Kernel::HLERequestContext& ctx) { +void Hid::ResetPalmaPlayLog(HLERequestContext& ctx) { LOG_WARNING(Service_HID, "(STUBBED) called"); IPC::ResponseBuilder rb{ctx, 2}; rb.Push(ResultSuccess); } -void Hid::SetIsPalmaAllConnectable(Kernel::HLERequestContext& ctx) { +void Hid::SetIsPalmaAllConnectable(HLERequestContext& ctx) { IPC::RequestParser rp{ctx}; struct Parameters { bool is_palma_all_connectable; @@ -2246,14 +2246,14 @@ void Hid::SetIsPalmaAllConnectable(Kernel::HLERequestContext& ctx) { rb.Push(ResultSuccess); } -void Hid::SetIsPalmaPairedConnectable(Kernel::HLERequestContext& ctx) { +void Hid::SetIsPalmaPairedConnectable(HLERequestContext& ctx) { LOG_WARNING(Service_HID, "(STUBBED) called"); IPC::ResponseBuilder rb{ctx, 2}; rb.Push(ResultSuccess); } -void Hid::PairPalma(Kernel::HLERequestContext& ctx) { +void Hid::PairPalma(HLERequestContext& ctx) { IPC::RequestParser rp{ctx}; const auto connection_handle{rp.PopRaw<Controller_Palma::PalmaConnectionHandle>()}; @@ -2266,7 +2266,7 @@ void Hid::PairPalma(Kernel::HLERequestContext& ctx) { rb.Push(ResultSuccess); } -void Hid::SetPalmaBoostMode(Kernel::HLERequestContext& ctx) { +void Hid::SetPalmaBoostMode(HLERequestContext& ctx) { IPC::RequestParser rp{ctx}; const auto palma_boost_mode{rp.Pop<bool>()}; @@ -2279,35 +2279,35 @@ void Hid::SetPalmaBoostMode(Kernel::HLERequestContext& ctx) { rb.Push(ResultSuccess); } -void Hid::CancelWritePalmaWaveEntry(Kernel::HLERequestContext& ctx) { +void Hid::CancelWritePalmaWaveEntry(HLERequestContext& ctx) { LOG_WARNING(Service_HID, "(STUBBED) called"); IPC::ResponseBuilder rb{ctx, 2}; rb.Push(ResultSuccess); } -void Hid::EnablePalmaBoostMode(Kernel::HLERequestContext& ctx) { +void Hid::EnablePalmaBoostMode(HLERequestContext& ctx) { LOG_WARNING(Service_HID, "(STUBBED) called"); IPC::ResponseBuilder rb{ctx, 2}; rb.Push(ResultSuccess); } -void Hid::GetPalmaBluetoothAddress(Kernel::HLERequestContext& ctx) { +void Hid::GetPalmaBluetoothAddress(HLERequestContext& ctx) { LOG_WARNING(Service_HID, "(STUBBED) called"); IPC::ResponseBuilder rb{ctx, 2}; rb.Push(ResultSuccess); } -void Hid::SetDisallowedPalmaConnection(Kernel::HLERequestContext& ctx) { +void Hid::SetDisallowedPalmaConnection(HLERequestContext& ctx) { LOG_WARNING(Service_HID, "(STUBBED) called"); IPC::ResponseBuilder rb{ctx, 2}; rb.Push(ResultSuccess); } -void Hid::SetNpadCommunicationMode(Kernel::HLERequestContext& ctx) { +void Hid::SetNpadCommunicationMode(HLERequestContext& ctx) { IPC::RequestParser rp{ctx}; const auto applet_resource_user_id{rp.Pop<u64>()}; const auto communication_mode{rp.PopEnum<Controller_NPad::NpadCommunicationMode>()}; @@ -2322,7 +2322,7 @@ void Hid::SetNpadCommunicationMode(Kernel::HLERequestContext& ctx) { rb.Push(ResultSuccess); } -void Hid::GetNpadCommunicationMode(Kernel::HLERequestContext& ctx) { +void Hid::GetNpadCommunicationMode(HLERequestContext& ctx) { IPC::RequestParser rp{ctx}; LOG_WARNING(Service_HID, "(STUBBED) called"); @@ -2333,7 +2333,7 @@ void Hid::GetNpadCommunicationMode(Kernel::HLERequestContext& ctx) { .GetNpadCommunicationMode()); } -void Hid::SetTouchScreenConfiguration(Kernel::HLERequestContext& ctx) { +void Hid::SetTouchScreenConfiguration(HLERequestContext& ctx) { IPC::RequestParser rp{ctx}; const auto touchscreen_mode{rp.PopRaw<Controller_Touchscreen::TouchScreenConfigurationForNx>()}; const auto applet_resource_user_id{rp.Pop<u64>()}; @@ -2345,7 +2345,7 @@ void Hid::SetTouchScreenConfiguration(Kernel::HLERequestContext& ctx) { rb.Push(ResultSuccess); } -void Hid::IsFirmwareUpdateNeededForNotification(Kernel::HLERequestContext& ctx) { +void Hid::IsFirmwareUpdateNeededForNotification(HLERequestContext& ctx) { IPC::RequestParser rp{ctx}; struct Parameters { s32 unknown; @@ -2719,7 +2719,7 @@ public: } private: - void ApplyNpadSystemCommonPolicy(Kernel::HLERequestContext& ctx) { + void ApplyNpadSystemCommonPolicy(HLERequestContext& ctx) { // We already do this for homebrew so we can just stub it out LOG_WARNING(Service_HID, "called"); @@ -2727,7 +2727,7 @@ private: rb.Push(ResultSuccess); } - void GetUniquePadsFromNpad(Kernel::HLERequestContext& ctx) { + void GetUniquePadsFromNpad(HLERequestContext& ctx) { IPC::RequestParser rp{ctx}; const auto npad_id_type{rp.PopEnum<Core::HID::NpadIdType>()}; diff --git a/src/core/hle/service/hid/hid.h b/src/core/hle/service/hid/hid.h index 9563654b6..c69e5f3fb 100644 --- a/src/core/hle/service/hid/hid.h +++ b/src/core/hle/service/hid/hid.h @@ -76,7 +76,7 @@ private: std::make_unique<T>(system.HIDCore(), shared_memory, service_context); } - void GetSharedMemoryHandle(Kernel::HLERequestContext& ctx); + void GetSharedMemoryHandle(HLERequestContext& ctx); void UpdateControllers(std::uintptr_t user_data, std::chrono::nanoseconds ns_late); void UpdateNpad(std::uintptr_t user_data, std::chrono::nanoseconds ns_late); void UpdateMouseKeyboard(std::uintptr_t user_data, std::chrono::nanoseconds ns_late); @@ -101,115 +101,115 @@ public: std::shared_ptr<IAppletResource> GetAppletResource(); private: - void CreateAppletResource(Kernel::HLERequestContext& ctx); - void ActivateDebugPad(Kernel::HLERequestContext& ctx); - void ActivateTouchScreen(Kernel::HLERequestContext& ctx); - void ActivateMouse(Kernel::HLERequestContext& ctx); - void ActivateKeyboard(Kernel::HLERequestContext& ctx); - void SendKeyboardLockKeyEvent(Kernel::HLERequestContext& ctx); - void ActivateXpad(Kernel::HLERequestContext& ctx); - void GetXpadIDs(Kernel::HLERequestContext& ctx); - void ActivateSixAxisSensor(Kernel::HLERequestContext& ctx); - void DeactivateSixAxisSensor(Kernel::HLERequestContext& ctx); - void StartSixAxisSensor(Kernel::HLERequestContext& ctx); - void StopSixAxisSensor(Kernel::HLERequestContext& ctx); - void IsSixAxisSensorFusionEnabled(Kernel::HLERequestContext& ctx); - void EnableSixAxisSensorFusion(Kernel::HLERequestContext& ctx); - void SetSixAxisSensorFusionParameters(Kernel::HLERequestContext& ctx); - void GetSixAxisSensorFusionParameters(Kernel::HLERequestContext& ctx); - void ResetSixAxisSensorFusionParameters(Kernel::HLERequestContext& ctx); - void SetGyroscopeZeroDriftMode(Kernel::HLERequestContext& ctx); - void GetGyroscopeZeroDriftMode(Kernel::HLERequestContext& ctx); - void ResetGyroscopeZeroDriftMode(Kernel::HLERequestContext& ctx); - void IsSixAxisSensorAtRest(Kernel::HLERequestContext& ctx); - void IsFirmwareUpdateAvailableForSixAxisSensor(Kernel::HLERequestContext& ctx); - void EnableSixAxisSensorUnalteredPassthrough(Kernel::HLERequestContext& ctx); - void IsSixAxisSensorUnalteredPassthroughEnabled(Kernel::HLERequestContext& ctx); - void LoadSixAxisSensorCalibrationParameter(Kernel::HLERequestContext& ctx); - void GetSixAxisSensorIcInformation(Kernel::HLERequestContext& ctx); - void ResetIsSixAxisSensorDeviceNewlyAssigned(Kernel::HLERequestContext& ctx); - void ActivateGesture(Kernel::HLERequestContext& ctx); - void SetSupportedNpadStyleSet(Kernel::HLERequestContext& ctx); - void GetSupportedNpadStyleSet(Kernel::HLERequestContext& ctx); - void SetSupportedNpadIdType(Kernel::HLERequestContext& ctx); - void ActivateNpad(Kernel::HLERequestContext& ctx); - void DeactivateNpad(Kernel::HLERequestContext& ctx); - void AcquireNpadStyleSetUpdateEventHandle(Kernel::HLERequestContext& ctx); - void DisconnectNpad(Kernel::HLERequestContext& ctx); - void GetPlayerLedPattern(Kernel::HLERequestContext& ctx); - void ActivateNpadWithRevision(Kernel::HLERequestContext& ctx); - void SetNpadJoyHoldType(Kernel::HLERequestContext& ctx); - void GetNpadJoyHoldType(Kernel::HLERequestContext& ctx); - void SetNpadJoyAssignmentModeSingleByDefault(Kernel::HLERequestContext& ctx); - void SetNpadJoyAssignmentModeSingle(Kernel::HLERequestContext& ctx); - void SetNpadJoyAssignmentModeDual(Kernel::HLERequestContext& ctx); - void MergeSingleJoyAsDualJoy(Kernel::HLERequestContext& ctx); - void StartLrAssignmentMode(Kernel::HLERequestContext& ctx); - void StopLrAssignmentMode(Kernel::HLERequestContext& ctx); - void SetNpadHandheldActivationMode(Kernel::HLERequestContext& ctx); - void GetNpadHandheldActivationMode(Kernel::HLERequestContext& ctx); - void SwapNpadAssignment(Kernel::HLERequestContext& ctx); - void IsUnintendedHomeButtonInputProtectionEnabled(Kernel::HLERequestContext& ctx); - void EnableUnintendedHomeButtonInputProtection(Kernel::HLERequestContext& ctx); - void SetNpadAnalogStickUseCenterClamp(Kernel::HLERequestContext& ctx); - void SetNpadCaptureButtonAssignment(Kernel::HLERequestContext& ctx); - void ClearNpadCaptureButtonAssignment(Kernel::HLERequestContext& ctx); - void GetVibrationDeviceInfo(Kernel::HLERequestContext& ctx); - void SendVibrationValue(Kernel::HLERequestContext& ctx); - void GetActualVibrationValue(Kernel::HLERequestContext& ctx); - void CreateActiveVibrationDeviceList(Kernel::HLERequestContext& ctx); - void PermitVibration(Kernel::HLERequestContext& ctx); - void IsVibrationPermitted(Kernel::HLERequestContext& ctx); - void SendVibrationValues(Kernel::HLERequestContext& ctx); - void SendVibrationGcErmCommand(Kernel::HLERequestContext& ctx); - void GetActualVibrationGcErmCommand(Kernel::HLERequestContext& ctx); - void BeginPermitVibrationSession(Kernel::HLERequestContext& ctx); - void EndPermitVibrationSession(Kernel::HLERequestContext& ctx); - void IsVibrationDeviceMounted(Kernel::HLERequestContext& ctx); - void ActivateConsoleSixAxisSensor(Kernel::HLERequestContext& ctx); - void StartConsoleSixAxisSensor(Kernel::HLERequestContext& ctx); - void StopConsoleSixAxisSensor(Kernel::HLERequestContext& ctx); - void ActivateSevenSixAxisSensor(Kernel::HLERequestContext& ctx); - void StartSevenSixAxisSensor(Kernel::HLERequestContext& ctx); - void StopSevenSixAxisSensor(Kernel::HLERequestContext& ctx); - void InitializeSevenSixAxisSensor(Kernel::HLERequestContext& ctx); - void FinalizeSevenSixAxisSensor(Kernel::HLERequestContext& ctx); - void ResetSevenSixAxisSensorTimestamp(Kernel::HLERequestContext& ctx); - void IsUsbFullKeyControllerEnabled(Kernel::HLERequestContext& ctx); - void GetPalmaConnectionHandle(Kernel::HLERequestContext& ctx); - void InitializePalma(Kernel::HLERequestContext& ctx); - void AcquirePalmaOperationCompleteEvent(Kernel::HLERequestContext& ctx); - void GetPalmaOperationInfo(Kernel::HLERequestContext& ctx); - void PlayPalmaActivity(Kernel::HLERequestContext& ctx); - void SetPalmaFrModeType(Kernel::HLERequestContext& ctx); - void ReadPalmaStep(Kernel::HLERequestContext& ctx); - void EnablePalmaStep(Kernel::HLERequestContext& ctx); - void ResetPalmaStep(Kernel::HLERequestContext& ctx); - void ReadPalmaApplicationSection(Kernel::HLERequestContext& ctx); - void WritePalmaApplicationSection(Kernel::HLERequestContext& ctx); - void ReadPalmaUniqueCode(Kernel::HLERequestContext& ctx); - void SetPalmaUniqueCodeInvalid(Kernel::HLERequestContext& ctx); - void WritePalmaActivityEntry(Kernel::HLERequestContext& ctx); - void WritePalmaRgbLedPatternEntry(Kernel::HLERequestContext& ctx); - void WritePalmaWaveEntry(Kernel::HLERequestContext& ctx); - void SetPalmaDataBaseIdentificationVersion(Kernel::HLERequestContext& ctx); - void GetPalmaDataBaseIdentificationVersion(Kernel::HLERequestContext& ctx); - void SuspendPalmaFeature(Kernel::HLERequestContext& ctx); - void GetPalmaOperationResult(Kernel::HLERequestContext& ctx); - void ReadPalmaPlayLog(Kernel::HLERequestContext& ctx); - void ResetPalmaPlayLog(Kernel::HLERequestContext& ctx); - void SetIsPalmaAllConnectable(Kernel::HLERequestContext& ctx); - void SetIsPalmaPairedConnectable(Kernel::HLERequestContext& ctx); - void PairPalma(Kernel::HLERequestContext& ctx); - void SetPalmaBoostMode(Kernel::HLERequestContext& ctx); - void CancelWritePalmaWaveEntry(Kernel::HLERequestContext& ctx); - void EnablePalmaBoostMode(Kernel::HLERequestContext& ctx); - void GetPalmaBluetoothAddress(Kernel::HLERequestContext& ctx); - void SetDisallowedPalmaConnection(Kernel::HLERequestContext& ctx); - void SetNpadCommunicationMode(Kernel::HLERequestContext& ctx); - void GetNpadCommunicationMode(Kernel::HLERequestContext& ctx); - void SetTouchScreenConfiguration(Kernel::HLERequestContext& ctx); - void IsFirmwareUpdateNeededForNotification(Kernel::HLERequestContext& ctx); + void CreateAppletResource(HLERequestContext& ctx); + void ActivateDebugPad(HLERequestContext& ctx); + void ActivateTouchScreen(HLERequestContext& ctx); + void ActivateMouse(HLERequestContext& ctx); + void ActivateKeyboard(HLERequestContext& ctx); + void SendKeyboardLockKeyEvent(HLERequestContext& ctx); + void ActivateXpad(HLERequestContext& ctx); + void GetXpadIDs(HLERequestContext& ctx); + void ActivateSixAxisSensor(HLERequestContext& ctx); + void DeactivateSixAxisSensor(HLERequestContext& ctx); + void StartSixAxisSensor(HLERequestContext& ctx); + void StopSixAxisSensor(HLERequestContext& ctx); + void IsSixAxisSensorFusionEnabled(HLERequestContext& ctx); + void EnableSixAxisSensorFusion(HLERequestContext& ctx); + void SetSixAxisSensorFusionParameters(HLERequestContext& ctx); + void GetSixAxisSensorFusionParameters(HLERequestContext& ctx); + void ResetSixAxisSensorFusionParameters(HLERequestContext& ctx); + void SetGyroscopeZeroDriftMode(HLERequestContext& ctx); + void GetGyroscopeZeroDriftMode(HLERequestContext& ctx); + void ResetGyroscopeZeroDriftMode(HLERequestContext& ctx); + void IsSixAxisSensorAtRest(HLERequestContext& ctx); + void IsFirmwareUpdateAvailableForSixAxisSensor(HLERequestContext& ctx); + void EnableSixAxisSensorUnalteredPassthrough(HLERequestContext& ctx); + void IsSixAxisSensorUnalteredPassthroughEnabled(HLERequestContext& ctx); + void LoadSixAxisSensorCalibrationParameter(HLERequestContext& ctx); + void GetSixAxisSensorIcInformation(HLERequestContext& ctx); + void ResetIsSixAxisSensorDeviceNewlyAssigned(HLERequestContext& ctx); + void ActivateGesture(HLERequestContext& ctx); + void SetSupportedNpadStyleSet(HLERequestContext& ctx); + void GetSupportedNpadStyleSet(HLERequestContext& ctx); + void SetSupportedNpadIdType(HLERequestContext& ctx); + void ActivateNpad(HLERequestContext& ctx); + void DeactivateNpad(HLERequestContext& ctx); + void AcquireNpadStyleSetUpdateEventHandle(HLERequestContext& ctx); + void DisconnectNpad(HLERequestContext& ctx); + void GetPlayerLedPattern(HLERequestContext& ctx); + void ActivateNpadWithRevision(HLERequestContext& ctx); + void SetNpadJoyHoldType(HLERequestContext& ctx); + void GetNpadJoyHoldType(HLERequestContext& ctx); + void SetNpadJoyAssignmentModeSingleByDefault(HLERequestContext& ctx); + void SetNpadJoyAssignmentModeSingle(HLERequestContext& ctx); + void SetNpadJoyAssignmentModeDual(HLERequestContext& ctx); + void MergeSingleJoyAsDualJoy(HLERequestContext& ctx); + void StartLrAssignmentMode(HLERequestContext& ctx); + void StopLrAssignmentMode(HLERequestContext& ctx); + void SetNpadHandheldActivationMode(HLERequestContext& ctx); + void GetNpadHandheldActivationMode(HLERequestContext& ctx); + void SwapNpadAssignment(HLERequestContext& ctx); + void IsUnintendedHomeButtonInputProtectionEnabled(HLERequestContext& ctx); + void EnableUnintendedHomeButtonInputProtection(HLERequestContext& ctx); + void SetNpadAnalogStickUseCenterClamp(HLERequestContext& ctx); + void SetNpadCaptureButtonAssignment(HLERequestContext& ctx); + void ClearNpadCaptureButtonAssignment(HLERequestContext& ctx); + void GetVibrationDeviceInfo(HLERequestContext& ctx); + void SendVibrationValue(HLERequestContext& ctx); + void GetActualVibrationValue(HLERequestContext& ctx); + void CreateActiveVibrationDeviceList(HLERequestContext& ctx); + void PermitVibration(HLERequestContext& ctx); + void IsVibrationPermitted(HLERequestContext& ctx); + void SendVibrationValues(HLERequestContext& ctx); + void SendVibrationGcErmCommand(HLERequestContext& ctx); + void GetActualVibrationGcErmCommand(HLERequestContext& ctx); + void BeginPermitVibrationSession(HLERequestContext& ctx); + void EndPermitVibrationSession(HLERequestContext& ctx); + void IsVibrationDeviceMounted(HLERequestContext& ctx); + void ActivateConsoleSixAxisSensor(HLERequestContext& ctx); + void StartConsoleSixAxisSensor(HLERequestContext& ctx); + void StopConsoleSixAxisSensor(HLERequestContext& ctx); + void ActivateSevenSixAxisSensor(HLERequestContext& ctx); + void StartSevenSixAxisSensor(HLERequestContext& ctx); + void StopSevenSixAxisSensor(HLERequestContext& ctx); + void InitializeSevenSixAxisSensor(HLERequestContext& ctx); + void FinalizeSevenSixAxisSensor(HLERequestContext& ctx); + void ResetSevenSixAxisSensorTimestamp(HLERequestContext& ctx); + void IsUsbFullKeyControllerEnabled(HLERequestContext& ctx); + void GetPalmaConnectionHandle(HLERequestContext& ctx); + void InitializePalma(HLERequestContext& ctx); + void AcquirePalmaOperationCompleteEvent(HLERequestContext& ctx); + void GetPalmaOperationInfo(HLERequestContext& ctx); + void PlayPalmaActivity(HLERequestContext& ctx); + void SetPalmaFrModeType(HLERequestContext& ctx); + void ReadPalmaStep(HLERequestContext& ctx); + void EnablePalmaStep(HLERequestContext& ctx); + void ResetPalmaStep(HLERequestContext& ctx); + void ReadPalmaApplicationSection(HLERequestContext& ctx); + void WritePalmaApplicationSection(HLERequestContext& ctx); + void ReadPalmaUniqueCode(HLERequestContext& ctx); + void SetPalmaUniqueCodeInvalid(HLERequestContext& ctx); + void WritePalmaActivityEntry(HLERequestContext& ctx); + void WritePalmaRgbLedPatternEntry(HLERequestContext& ctx); + void WritePalmaWaveEntry(HLERequestContext& ctx); + void SetPalmaDataBaseIdentificationVersion(HLERequestContext& ctx); + void GetPalmaDataBaseIdentificationVersion(HLERequestContext& ctx); + void SuspendPalmaFeature(HLERequestContext& ctx); + void GetPalmaOperationResult(HLERequestContext& ctx); + void ReadPalmaPlayLog(HLERequestContext& ctx); + void ResetPalmaPlayLog(HLERequestContext& ctx); + void SetIsPalmaAllConnectable(HLERequestContext& ctx); + void SetIsPalmaPairedConnectable(HLERequestContext& ctx); + void PairPalma(HLERequestContext& ctx); + void SetPalmaBoostMode(HLERequestContext& ctx); + void CancelWritePalmaWaveEntry(HLERequestContext& ctx); + void EnablePalmaBoostMode(HLERequestContext& ctx); + void GetPalmaBluetoothAddress(HLERequestContext& ctx); + void SetDisallowedPalmaConnection(HLERequestContext& ctx); + void SetNpadCommunicationMode(HLERequestContext& ctx); + void GetNpadCommunicationMode(HLERequestContext& ctx); + void SetTouchScreenConfiguration(HLERequestContext& ctx); + void IsFirmwareUpdateNeededForNotification(HLERequestContext& ctx); std::shared_ptr<IAppletResource> applet_resource; diff --git a/src/core/hle/service/hid/hidbus.cpp b/src/core/hle/service/hid/hidbus.cpp index 07199d5d5..5604a6fda 100644 --- a/src/core/hle/service/hid/hidbus.cpp +++ b/src/core/hle/service/hid/hidbus.cpp @@ -7,7 +7,6 @@ #include "core/core_timing.h" #include "core/core_timing_util.h" #include "core/hid/hid_types.h" -#include "core/hle/ipc_helpers.h" #include "core/hle/kernel/k_event.h" #include "core/hle/kernel/k_readable_event.h" #include "core/hle/kernel/k_shared_memory.h" @@ -16,6 +15,7 @@ #include "core/hle/service/hid/hidbus/ringcon.h" #include "core/hle/service/hid/hidbus/starlink.h" #include "core/hle/service/hid/hidbus/stubbed.h" +#include "core/hle/service/ipc_helpers.h" #include "core/hle/service/service.h" #include "core/memory.h" @@ -99,7 +99,7 @@ std::optional<std::size_t> HidBus::GetDeviceIndexFromHandle(BusHandle handle) co return std::nullopt; } -void HidBus::GetBusHandle(Kernel::HLERequestContext& ctx) { +void HidBus::GetBusHandle(HLERequestContext& ctx) { IPC::RequestParser rp{ctx}; struct Parameters { Core::HID::NpadIdType npad_id; @@ -165,7 +165,7 @@ void HidBus::GetBusHandle(Kernel::HLERequestContext& ctx) { rb.PushRaw(out_data); } -void HidBus::IsExternalDeviceConnected(Kernel::HLERequestContext& ctx) { +void HidBus::IsExternalDeviceConnected(HLERequestContext& ctx) { IPC::RequestParser rp{ctx}; const auto bus_handle_{rp.PopRaw<BusHandle>()}; @@ -193,7 +193,7 @@ void HidBus::IsExternalDeviceConnected(Kernel::HLERequestContext& ctx) { return; } -void HidBus::Initialize(Kernel::HLERequestContext& ctx) { +void HidBus::Initialize(HLERequestContext& ctx) { IPC::RequestParser rp{ctx}; const auto bus_handle_{rp.PopRaw<BusHandle>()}; const auto applet_resource_user_id{rp.Pop<u64>()}; @@ -245,7 +245,7 @@ void HidBus::Initialize(Kernel::HLERequestContext& ctx) { return; } -void HidBus::Finalize(Kernel::HLERequestContext& ctx) { +void HidBus::Finalize(HLERequestContext& ctx) { IPC::RequestParser rp{ctx}; const auto bus_handle_{rp.PopRaw<BusHandle>()}; const auto applet_resource_user_id{rp.Pop<u64>()}; @@ -284,7 +284,7 @@ void HidBus::Finalize(Kernel::HLERequestContext& ctx) { return; } -void HidBus::EnableExternalDevice(Kernel::HLERequestContext& ctx) { +void HidBus::EnableExternalDevice(HLERequestContext& ctx) { IPC::RequestParser rp{ctx}; struct Parameters { bool enable; @@ -322,7 +322,7 @@ void HidBus::EnableExternalDevice(Kernel::HLERequestContext& ctx) { return; } -void HidBus::GetExternalDeviceId(Kernel::HLERequestContext& ctx) { +void HidBus::GetExternalDeviceId(HLERequestContext& ctx) { IPC::RequestParser rp{ctx}; const auto bus_handle_{rp.PopRaw<BusHandle>()}; @@ -349,7 +349,7 @@ void HidBus::GetExternalDeviceId(Kernel::HLERequestContext& ctx) { return; } -void HidBus::SendCommandAsync(Kernel::HLERequestContext& ctx) { +void HidBus::SendCommandAsync(HLERequestContext& ctx) { IPC::RequestParser rp{ctx}; const auto data = ctx.ReadBuffer(); const auto bus_handle_{rp.PopRaw<BusHandle>()}; @@ -377,7 +377,7 @@ void HidBus::SendCommandAsync(Kernel::HLERequestContext& ctx) { return; }; -void HidBus::GetSendCommandAsynceResult(Kernel::HLERequestContext& ctx) { +void HidBus::GetSendCommandAsynceResult(HLERequestContext& ctx) { IPC::RequestParser rp{ctx}; const auto bus_handle_{rp.PopRaw<BusHandle>()}; @@ -406,7 +406,7 @@ void HidBus::GetSendCommandAsynceResult(Kernel::HLERequestContext& ctx) { return; }; -void HidBus::SetEventForSendCommandAsycResult(Kernel::HLERequestContext& ctx) { +void HidBus::SetEventForSendCommandAsycResult(HLERequestContext& ctx) { IPC::RequestParser rp{ctx}; const auto bus_handle_{rp.PopRaw<BusHandle>()}; @@ -432,7 +432,7 @@ void HidBus::SetEventForSendCommandAsycResult(Kernel::HLERequestContext& ctx) { return; }; -void HidBus::GetSharedMemoryHandle(Kernel::HLERequestContext& ctx) { +void HidBus::GetSharedMemoryHandle(HLERequestContext& ctx) { LOG_DEBUG(Service_HID, "called"); IPC::ResponseBuilder rb{ctx, 2, 1}; @@ -440,7 +440,7 @@ void HidBus::GetSharedMemoryHandle(Kernel::HLERequestContext& ctx) { rb.PushCopyObjects(&system.Kernel().GetHidBusSharedMem()); } -void HidBus::EnableJoyPollingReceiveMode(Kernel::HLERequestContext& ctx) { +void HidBus::EnableJoyPollingReceiveMode(HLERequestContext& ctx) { IPC::RequestParser rp{ctx}; const auto t_mem_size{rp.Pop<u32>()}; const auto t_mem_handle{ctx.GetCopyHandle(0)}; @@ -485,7 +485,7 @@ void HidBus::EnableJoyPollingReceiveMode(Kernel::HLERequestContext& ctx) { return; } -void HidBus::DisableJoyPollingReceiveMode(Kernel::HLERequestContext& ctx) { +void HidBus::DisableJoyPollingReceiveMode(HLERequestContext& ctx) { IPC::RequestParser rp{ctx}; const auto bus_handle_{rp.PopRaw<BusHandle>()}; @@ -512,7 +512,7 @@ void HidBus::DisableJoyPollingReceiveMode(Kernel::HLERequestContext& ctx) { return; } -void HidBus::SetStatusManagerType(Kernel::HLERequestContext& ctx) { +void HidBus::SetStatusManagerType(HLERequestContext& ctx) { IPC::RequestParser rp{ctx}; const auto manager_type{rp.PopEnum<StatusManagerType>()}; diff --git a/src/core/hle/service/hid/hidbus.h b/src/core/hle/service/hid/hidbus.h index 85ed96e2e..c29b5e882 100644 --- a/src/core/hle/service/hid/hidbus.h +++ b/src/core/hle/service/hid/hidbus.h @@ -94,19 +94,19 @@ private: std::unique_ptr<HidbusBase> device{nullptr}; }; - void GetBusHandle(Kernel::HLERequestContext& ctx); - void IsExternalDeviceConnected(Kernel::HLERequestContext& ctx); - void Initialize(Kernel::HLERequestContext& ctx); - void Finalize(Kernel::HLERequestContext& ctx); - void EnableExternalDevice(Kernel::HLERequestContext& ctx); - void GetExternalDeviceId(Kernel::HLERequestContext& ctx); - void SendCommandAsync(Kernel::HLERequestContext& ctx); - void GetSendCommandAsynceResult(Kernel::HLERequestContext& ctx); - void SetEventForSendCommandAsycResult(Kernel::HLERequestContext& ctx); - void GetSharedMemoryHandle(Kernel::HLERequestContext& ctx); - void EnableJoyPollingReceiveMode(Kernel::HLERequestContext& ctx); - void DisableJoyPollingReceiveMode(Kernel::HLERequestContext& ctx); - void SetStatusManagerType(Kernel::HLERequestContext& ctx); + void GetBusHandle(HLERequestContext& ctx); + void IsExternalDeviceConnected(HLERequestContext& ctx); + void Initialize(HLERequestContext& ctx); + void Finalize(HLERequestContext& ctx); + void EnableExternalDevice(HLERequestContext& ctx); + void GetExternalDeviceId(HLERequestContext& ctx); + void SendCommandAsync(HLERequestContext& ctx); + void GetSendCommandAsynceResult(HLERequestContext& ctx); + void SetEventForSendCommandAsycResult(HLERequestContext& ctx); + void GetSharedMemoryHandle(HLERequestContext& ctx); + void EnableJoyPollingReceiveMode(HLERequestContext& ctx); + void DisableJoyPollingReceiveMode(HLERequestContext& ctx); + void SetStatusManagerType(HLERequestContext& ctx); void UpdateHidbus(std::uintptr_t user_data, std::chrono::nanoseconds ns_late); std::optional<std::size_t> GetDeviceIndexFromHandle(BusHandle handle) const; diff --git a/src/core/hle/service/hid/irs.cpp b/src/core/hle/service/hid/irs.cpp index a40f61fde..221c33b86 100644 --- a/src/core/hle/service/hid/irs.cpp +++ b/src/core/hle/service/hid/irs.cpp @@ -8,7 +8,6 @@ #include "core/core_timing.h" #include "core/hid/emulated_controller.h" #include "core/hid/hid_core.h" -#include "core/hle/ipc_helpers.h" #include "core/hle/kernel/k_shared_memory.h" #include "core/hle/kernel/k_transfer_memory.h" #include "core/hle/kernel/kernel.h" @@ -20,6 +19,7 @@ #include "core/hle/service/hid/irsensor/moment_processor.h" #include "core/hle/service/hid/irsensor/pointing_processor.h" #include "core/hle/service/hid/irsensor/tera_plugin_processor.h" +#include "core/hle/service/ipc_helpers.h" #include "core/memory.h" namespace Service::IRS { @@ -56,7 +56,7 @@ IRS::IRS(Core::System& system_) : ServiceFramework{system_, "irs"} { } IRS::~IRS() = default; -void IRS::ActivateIrsensor(Kernel::HLERequestContext& ctx) { +void IRS::ActivateIrsensor(HLERequestContext& ctx) { IPC::RequestParser rp{ctx}; const auto applet_resource_user_id{rp.Pop<u64>()}; @@ -67,7 +67,7 @@ void IRS::ActivateIrsensor(Kernel::HLERequestContext& ctx) { rb.Push(ResultSuccess); } -void IRS::DeactivateIrsensor(Kernel::HLERequestContext& ctx) { +void IRS::DeactivateIrsensor(HLERequestContext& ctx) { IPC::RequestParser rp{ctx}; const auto applet_resource_user_id{rp.Pop<u64>()}; @@ -78,7 +78,7 @@ void IRS::DeactivateIrsensor(Kernel::HLERequestContext& ctx) { rb.Push(ResultSuccess); } -void IRS::GetIrsensorSharedMemoryHandle(Kernel::HLERequestContext& ctx) { +void IRS::GetIrsensorSharedMemoryHandle(HLERequestContext& ctx) { IPC::RequestParser rp{ctx}; const auto applet_resource_user_id{rp.Pop<u64>()}; @@ -89,7 +89,7 @@ void IRS::GetIrsensorSharedMemoryHandle(Kernel::HLERequestContext& ctx) { rb.PushCopyObjects(&system.Kernel().GetIrsSharedMem()); } -void IRS::StopImageProcessor(Kernel::HLERequestContext& ctx) { +void IRS::StopImageProcessor(HLERequestContext& ctx) { IPC::RequestParser rp{ctx}; struct Parameters { Core::IrSensor::IrCameraHandle camera_handle; @@ -117,7 +117,7 @@ void IRS::StopImageProcessor(Kernel::HLERequestContext& ctx) { rb.Push(result); } -void IRS::RunMomentProcessor(Kernel::HLERequestContext& ctx) { +void IRS::RunMomentProcessor(HLERequestContext& ctx) { IPC::RequestParser rp{ctx}; struct Parameters { Core::IrSensor::IrCameraHandle camera_handle; @@ -149,7 +149,7 @@ void IRS::RunMomentProcessor(Kernel::HLERequestContext& ctx) { rb.Push(result); } -void IRS::RunClusteringProcessor(Kernel::HLERequestContext& ctx) { +void IRS::RunClusteringProcessor(HLERequestContext& ctx) { IPC::RequestParser rp{ctx}; struct Parameters { Core::IrSensor::IrCameraHandle camera_handle; @@ -182,7 +182,7 @@ void IRS::RunClusteringProcessor(Kernel::HLERequestContext& ctx) { rb.Push(result); } -void IRS::RunImageTransferProcessor(Kernel::HLERequestContext& ctx) { +void IRS::RunImageTransferProcessor(HLERequestContext& ctx) { IPC::RequestParser rp{ctx}; struct Parameters { Core::IrSensor::IrCameraHandle camera_handle; @@ -231,7 +231,7 @@ void IRS::RunImageTransferProcessor(Kernel::HLERequestContext& ctx) { rb.Push(result); } -void IRS::GetImageTransferProcessorState(Kernel::HLERequestContext& ctx) { +void IRS::GetImageTransferProcessorState(HLERequestContext& ctx) { IPC::RequestParser rp{ctx}; struct Parameters { Core::IrSensor::IrCameraHandle camera_handle; @@ -272,7 +272,7 @@ void IRS::GetImageTransferProcessorState(Kernel::HLERequestContext& ctx) { rb.PushRaw(state); } -void IRS::RunTeraPluginProcessor(Kernel::HLERequestContext& ctx) { +void IRS::RunTeraPluginProcessor(HLERequestContext& ctx) { IPC::RequestParser rp{ctx}; struct Parameters { Core::IrSensor::IrCameraHandle camera_handle; @@ -308,7 +308,7 @@ void IRS::RunTeraPluginProcessor(Kernel::HLERequestContext& ctx) { rb.Push(result); } -void IRS::GetNpadIrCameraHandle(Kernel::HLERequestContext& ctx) { +void IRS::GetNpadIrCameraHandle(HLERequestContext& ctx) { IPC::RequestParser rp{ctx}; const auto npad_id{rp.PopEnum<Core::HID::NpadIdType>()}; @@ -332,7 +332,7 @@ void IRS::GetNpadIrCameraHandle(Kernel::HLERequestContext& ctx) { rb.PushRaw(camera_handle); } -void IRS::RunPointingProcessor(Kernel::HLERequestContext& ctx) { +void IRS::RunPointingProcessor(HLERequestContext& ctx) { IPC::RequestParser rp{ctx}; const auto camera_handle{rp.PopRaw<Core::IrSensor::IrCameraHandle>()}; const auto processor_config{rp.PopRaw<Core::IrSensor::PackedPointingProcessorConfig>()}; @@ -359,7 +359,7 @@ void IRS::RunPointingProcessor(Kernel::HLERequestContext& ctx) { rb.Push(result); } -void IRS::SuspendImageProcessor(Kernel::HLERequestContext& ctx) { +void IRS::SuspendImageProcessor(HLERequestContext& ctx) { IPC::RequestParser rp{ctx}; struct Parameters { Core::IrSensor::IrCameraHandle camera_handle; @@ -385,7 +385,7 @@ void IRS::SuspendImageProcessor(Kernel::HLERequestContext& ctx) { rb.Push(result); } -void IRS::CheckFirmwareVersion(Kernel::HLERequestContext& ctx) { +void IRS::CheckFirmwareVersion(HLERequestContext& ctx) { IPC::RequestParser rp{ctx}; const auto camera_handle{rp.PopRaw<Core::IrSensor::IrCameraHandle>()}; const auto mcu_version{rp.PopRaw<Core::IrSensor::PackedMcuVersion>()}; @@ -407,7 +407,7 @@ void IRS::CheckFirmwareVersion(Kernel::HLERequestContext& ctx) { rb.Push(result); } -void IRS::SetFunctionLevel(Kernel::HLERequestContext& ctx) { +void IRS::SetFunctionLevel(HLERequestContext& ctx) { IPC::RequestParser rp{ctx}; const auto camera_handle{rp.PopRaw<Core::IrSensor::IrCameraHandle>()}; const auto function_level{rp.PopRaw<Core::IrSensor::PackedFunctionLevel>()}; @@ -429,7 +429,7 @@ void IRS::SetFunctionLevel(Kernel::HLERequestContext& ctx) { rb.Push(result); } -void IRS::RunImageTransferExProcessor(Kernel::HLERequestContext& ctx) { +void IRS::RunImageTransferExProcessor(HLERequestContext& ctx) { IPC::RequestParser rp{ctx}; struct Parameters { Core::IrSensor::IrCameraHandle camera_handle; @@ -469,7 +469,7 @@ void IRS::RunImageTransferExProcessor(Kernel::HLERequestContext& ctx) { rb.Push(result); } -void IRS::RunIrLedProcessor(Kernel::HLERequestContext& ctx) { +void IRS::RunIrLedProcessor(HLERequestContext& ctx) { IPC::RequestParser rp{ctx}; const auto camera_handle{rp.PopRaw<Core::IrSensor::IrCameraHandle>()}; const auto processor_config{rp.PopRaw<Core::IrSensor::PackedIrLedProcessorConfig>()}; @@ -497,7 +497,7 @@ void IRS::RunIrLedProcessor(Kernel::HLERequestContext& ctx) { rb.Push(result); } -void IRS::StopImageProcessorAsync(Kernel::HLERequestContext& ctx) { +void IRS::StopImageProcessorAsync(HLERequestContext& ctx) { IPC::RequestParser rp{ctx}; struct Parameters { Core::IrSensor::IrCameraHandle camera_handle; @@ -525,7 +525,7 @@ void IRS::StopImageProcessorAsync(Kernel::HLERequestContext& ctx) { rb.Push(result); } -void IRS::ActivateIrsensorWithFunctionLevel(Kernel::HLERequestContext& ctx) { +void IRS::ActivateIrsensorWithFunctionLevel(HLERequestContext& ctx) { IPC::RequestParser rp{ctx}; struct Parameters { Core::IrSensor::PackedFunctionLevel function_level; diff --git a/src/core/hle/service/hid/irs.h b/src/core/hle/service/hid/irs.h index b76ad7854..a8fa19025 100644 --- a/src/core/hle/service/hid/irs.h +++ b/src/core/hle/service/hid/irs.h @@ -38,24 +38,24 @@ private: }; static_assert(sizeof(StatusManager) == 0x8000, "StatusManager is an invalid size"); - void ActivateIrsensor(Kernel::HLERequestContext& ctx); - void DeactivateIrsensor(Kernel::HLERequestContext& ctx); - void GetIrsensorSharedMemoryHandle(Kernel::HLERequestContext& ctx); - void StopImageProcessor(Kernel::HLERequestContext& ctx); - void RunMomentProcessor(Kernel::HLERequestContext& ctx); - void RunClusteringProcessor(Kernel::HLERequestContext& ctx); - void RunImageTransferProcessor(Kernel::HLERequestContext& ctx); - void GetImageTransferProcessorState(Kernel::HLERequestContext& ctx); - void RunTeraPluginProcessor(Kernel::HLERequestContext& ctx); - void GetNpadIrCameraHandle(Kernel::HLERequestContext& ctx); - void RunPointingProcessor(Kernel::HLERequestContext& ctx); - void SuspendImageProcessor(Kernel::HLERequestContext& ctx); - void CheckFirmwareVersion(Kernel::HLERequestContext& ctx); - void SetFunctionLevel(Kernel::HLERequestContext& ctx); - void RunImageTransferExProcessor(Kernel::HLERequestContext& ctx); - void RunIrLedProcessor(Kernel::HLERequestContext& ctx); - void StopImageProcessorAsync(Kernel::HLERequestContext& ctx); - void ActivateIrsensorWithFunctionLevel(Kernel::HLERequestContext& ctx); + void ActivateIrsensor(HLERequestContext& ctx); + void DeactivateIrsensor(HLERequestContext& ctx); + void GetIrsensorSharedMemoryHandle(HLERequestContext& ctx); + void StopImageProcessor(HLERequestContext& ctx); + void RunMomentProcessor(HLERequestContext& ctx); + void RunClusteringProcessor(HLERequestContext& ctx); + void RunImageTransferProcessor(HLERequestContext& ctx); + void GetImageTransferProcessorState(HLERequestContext& ctx); + void RunTeraPluginProcessor(HLERequestContext& ctx); + void GetNpadIrCameraHandle(HLERequestContext& ctx); + void RunPointingProcessor(HLERequestContext& ctx); + void SuspendImageProcessor(HLERequestContext& ctx); + void CheckFirmwareVersion(HLERequestContext& ctx); + void SetFunctionLevel(HLERequestContext& ctx); + void RunImageTransferExProcessor(HLERequestContext& ctx); + void RunIrLedProcessor(HLERequestContext& ctx); + void StopImageProcessorAsync(HLERequestContext& ctx); + void ActivateIrsensorWithFunctionLevel(HLERequestContext& ctx); Result IsIrCameraHandleValid(const Core::IrSensor::IrCameraHandle& camera_handle) const; Core::IrSensor::DeviceFormat& GetIrCameraSharedMemoryDeviceEntry( diff --git a/src/core/hle/service/hid/irsensor/image_transfer_processor.cpp b/src/core/hle/service/hid/irsensor/image_transfer_processor.cpp index bc896a1e3..a268750cd 100644 --- a/src/core/hle/service/hid/irsensor/image_transfer_processor.cpp +++ b/src/core/hle/service/hid/irsensor/image_transfer_processor.cpp @@ -51,7 +51,7 @@ void ImageTransferProcessor::OnControllerUpdate(Core::HID::ControllerTriggerType const auto camera_data = npad_device->GetCamera(); - // This indicates how much ambient light is precent + // This indicates how much ambient light is present processor_state.ambient_noise_level = Core::IrSensor::CameraAmbientNoiseLevel::Low; processor_state.sampling_number = camera_data.sample; diff --git a/src/core/hle/kernel/hle_ipc.cpp b/src/core/hle/service/hle_ipc.cpp index 876fbbe53..cca697c64 100644 --- a/src/core/hle/kernel/hle_ipc.cpp +++ b/src/core/hle/service/hle_ipc.cpp @@ -12,8 +12,6 @@ #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" #include "core/hle/kernel/k_handle_table.h" #include "core/hle/kernel/k_process.h" @@ -21,17 +19,19 @@ #include "core/hle/kernel/k_server_session.h" #include "core/hle/kernel/k_thread.h" #include "core/hle/kernel/kernel.h" +#include "core/hle/service/hle_ipc.h" +#include "core/hle/service/ipc_helpers.h" #include "core/memory.h" -namespace Kernel { +namespace Service { -SessionRequestHandler::SessionRequestHandler(KernelCore& kernel_, const char* service_name_) +SessionRequestHandler::SessionRequestHandler(Kernel::KernelCore& kernel_, const char* service_name_) : kernel{kernel_} {} SessionRequestHandler::~SessionRequestHandler() = default; -SessionRequestManager::SessionRequestManager(KernelCore& kernel_, - Service::ServerManager& server_manager_) +SessionRequestManager::SessionRequestManager(Kernel::KernelCore& kernel_, + ServerManager& server_manager_) : kernel{kernel_}, server_manager{server_manager_} {} SessionRequestManager::~SessionRequestManager() = default; @@ -51,7 +51,7 @@ bool SessionRequestManager::HasSessionRequestHandler(const HLERequestContext& co } } -Result SessionRequestManager::CompleteSyncRequest(KServerSession* server_session, +Result SessionRequestManager::CompleteSyncRequest(Kernel::KServerSession* server_session, HLERequestContext& context) { Result result = ResultSuccess; @@ -79,7 +79,7 @@ Result SessionRequestManager::CompleteSyncRequest(KServerSession* server_session return result; } -Result SessionRequestManager::HandleDomainSyncRequest(KServerSession* server_session, +Result SessionRequestManager::HandleDomainSyncRequest(Kernel::KServerSession* server_session, HLERequestContext& context) { if (!context.HasDomainMessageHeader()) { return ResultSuccess; @@ -124,16 +124,17 @@ Result SessionRequestManager::HandleDomainSyncRequest(KServerSession* server_ses return ResultSuccess; } -HLERequestContext::HLERequestContext(KernelCore& kernel_, Core::Memory::Memory& memory_, - KServerSession* server_session_, KThread* thread_) +HLERequestContext::HLERequestContext(Kernel::KernelCore& kernel_, Core::Memory::Memory& memory_, + Kernel::KServerSession* server_session_, + Kernel::KThread* thread_) : server_session(server_session_), thread(thread_), kernel{kernel_}, memory{memory_} { cmd_buf[0] = 0; } HLERequestContext::~HLERequestContext() = default; -void HLERequestContext::ParseCommandBuffer(const KHandleTable& handle_table, u32_le* src_cmdbuf, - bool incoming) { +void HLERequestContext::ParseCommandBuffer(const Kernel::KHandleTable& handle_table, + u32_le* src_cmdbuf, bool incoming) { IPC::RequestParser rp(src_cmdbuf); command_header = rp.PopRaw<IPC::CommandHeader>(); @@ -253,8 +254,8 @@ void HLERequestContext::ParseCommandBuffer(const KHandleTable& handle_table, u32 rp.Skip(1, false); // The command is actually an u64, but we don't use the high part. } -Result HLERequestContext::PopulateFromIncomingCommandBuffer(const KHandleTable& handle_table, - u32_le* src_cmdbuf) { +Result HLERequestContext::PopulateFromIncomingCommandBuffer( + const Kernel::KHandleTable& handle_table, u32_le* src_cmdbuf) { ParseCommandBuffer(handle_table, src_cmdbuf, true); if (command_header->IsCloseCommand()) { @@ -267,7 +268,7 @@ Result HLERequestContext::PopulateFromIncomingCommandBuffer(const KHandleTable& return ResultSuccess; } -Result HLERequestContext::WriteToOutgoingCommandBuffer(KThread& requesting_thread) { +Result HLERequestContext::WriteToOutgoingCommandBuffer(Kernel::KThread& requesting_thread) { auto current_offset = handles_offset; auto& owner_process = *requesting_thread.GetOwnerProcess(); auto& handle_table = owner_process.GetHandleTable(); @@ -302,7 +303,7 @@ Result HLERequestContext::WriteToOutgoingCommandBuffer(KThread& requesting_threa } // Copy the translated command buffer back into the thread's command buffer area. - memory.WriteBlock(owner_process, requesting_thread.GetTLSAddress(), cmd_buf.data(), + memory.WriteBlock(owner_process, requesting_thread.GetTlsAddress(), cmd_buf.data(), write_size * sizeof(u32)); return ResultSuccess; @@ -528,4 +529,4 @@ std::string HLERequestContext::Description() const { return s.str(); } -} // namespace Kernel +} // namespace Service diff --git a/src/core/hle/kernel/hle_ipc.h b/src/core/hle/service/hle_ipc.h index b4364f984..4bd24c899 100644 --- a/src/core/hle/kernel/hle_ipc.h +++ b/src/core/hle/service/hle_ipc.h @@ -35,20 +35,18 @@ class ServerManager; } // namespace Service namespace Kernel { - -class Domain; -class HLERequestContext; class KAutoObject; class KernelCore; -class KEvent; class KHandleTable; -class KServerPort; -class KProcess; class KServerSession; class KThread; -class KReadableEvent; -class KSession; -class SessionRequestManager; +} // namespace Kernel + +namespace Service { + +using Handle = Kernel::Handle; + +class HLERequestContext; /** * Interface implemented by HLE Session handlers. @@ -57,7 +55,7 @@ class SessionRequestManager; */ class SessionRequestHandler : public std::enable_shared_from_this<SessionRequestHandler> { public: - SessionRequestHandler(KernelCore& kernel_, const char* service_name_); + SessionRequestHandler(Kernel::KernelCore& kernel_, const char* service_name_); virtual ~SessionRequestHandler(); /** @@ -69,10 +67,10 @@ public: * @returns Result the result code of the translate operation. */ virtual Result HandleSyncRequest(Kernel::KServerSession& session, - Kernel::HLERequestContext& context) = 0; + HLERequestContext& context) = 0; protected: - KernelCore& kernel; + Kernel::KernelCore& kernel; }; using SessionRequestHandlerWeakPtr = std::weak_ptr<SessionRequestHandler>; @@ -85,7 +83,8 @@ using SessionRequestHandlerPtr = std::shared_ptr<SessionRequestHandler>; */ class SessionRequestManager final { public: - explicit SessionRequestManager(KernelCore& kernel, Service::ServerManager& server_manager); + explicit SessionRequestManager(Kernel::KernelCore& kernel, + Service::ServerManager& server_manager); ~SessionRequestManager(); bool IsDomain() const { @@ -140,8 +139,9 @@ public: bool HasSessionRequestHandler(const HLERequestContext& context) const; - Result HandleDomainSyncRequest(KServerSession* server_session, HLERequestContext& context); - Result CompleteSyncRequest(KServerSession* server_session, HLERequestContext& context); + Result HandleDomainSyncRequest(Kernel::KServerSession* server_session, + HLERequestContext& context); + Result CompleteSyncRequest(Kernel::KServerSession* server_session, HLERequestContext& context); Service::ServerManager& GetServerManager() { return server_manager; @@ -166,33 +166,18 @@ private: std::vector<SessionRequestHandlerPtr> domain_handlers; private: - KernelCore& kernel; + Kernel::KernelCore& kernel; Service::ServerManager& server_manager; }; /** * Class containing information about an in-flight IPC request being handled by an HLE service - * implementation. Services should avoid using old global APIs (e.g. Kernel::GetCommandBuffer()) and - * when possible use the APIs in this class to service the request. - * - * HLE handle protocol - * =================== - * - * To avoid needing HLE services to keep a separate handle table, or having to directly modify the - * requester's table, a tweaked protocol is used to receive and send handles in requests. The kernel - * will decode the incoming handles into object pointers and insert a id in the buffer where the - * handle would normally be. The service then calls GetIncomingHandle() with that id to get the - * pointer to the object. Similarly, instead of inserting a handle into the command buffer, the - * service calls AddOutgoingHandle() and stores the returned id where the handle would normally go. - * - * The end result is similar to just giving services their own real handle tables, but since these - * ids are local to a specific context, it avoids requiring services to manage handles for objects - * across multiple calls and ensuring that unneeded handles are cleaned up. + * implementation. */ class HLERequestContext { public: - explicit HLERequestContext(KernelCore& kernel, Core::Memory::Memory& memory, - KServerSession* session, KThread* thread); + explicit HLERequestContext(Kernel::KernelCore& kernel, Core::Memory::Memory& memory, + Kernel::KServerSession* session, Kernel::KThread* thread); ~HLERequestContext(); /// Returns a pointer to the IPC command buffer for this request. @@ -209,10 +194,11 @@ public: } /// Populates this context with data from the requesting process/thread. - Result PopulateFromIncomingCommandBuffer(const KHandleTable& handle_table, u32_le* src_cmdbuf); + Result PopulateFromIncomingCommandBuffer(const Kernel::KHandleTable& handle_table, + u32_le* src_cmdbuf); /// Writes data from this context back to the requesting process/thread. - Result WriteToOutgoingCommandBuffer(KThread& requesting_thread); + Result WriteToOutgoingCommandBuffer(Kernel::KThread& requesting_thread); [[nodiscard]] u32_le GetHipcCommand() const { return command; @@ -339,11 +325,11 @@ public: return incoming_move_handles.at(index); } - void AddMoveObject(KAutoObject* object) { + void AddMoveObject(Kernel::KAutoObject* object) { outgoing_move_objects.emplace_back(object); } - void AddCopyObject(KAutoObject* object) { + void AddCopyObject(Kernel::KAutoObject* object) { outgoing_copy_objects.emplace_back(object); } @@ -362,7 +348,7 @@ public: [[nodiscard]] std::string Description() const; - [[nodiscard]] KThread& GetThread() { + [[nodiscard]] Kernel::KThread& GetThread() { return *thread; } @@ -381,17 +367,18 @@ public: private: friend class IPC::ResponseBuilder; - void ParseCommandBuffer(const KHandleTable& handle_table, u32_le* src_cmdbuf, bool incoming); + void ParseCommandBuffer(const Kernel::KHandleTable& handle_table, u32_le* src_cmdbuf, + bool incoming); std::array<u32, IPC::COMMAND_BUFFER_LENGTH> cmd_buf; Kernel::KServerSession* server_session{}; - KThread* thread; + Kernel::KThread* thread; std::vector<Handle> incoming_move_handles; std::vector<Handle> incoming_copy_handles; - std::vector<KAutoObject*> outgoing_move_objects; - std::vector<KAutoObject*> outgoing_copy_objects; + std::vector<Kernel::KAutoObject*> outgoing_move_objects; + std::vector<Kernel::KAutoObject*> outgoing_copy_objects; std::vector<SessionRequestHandlerPtr> outgoing_domain_objects; std::optional<IPC::CommandHeader> command_header; @@ -414,8 +401,8 @@ private: std::weak_ptr<SessionRequestManager> manager{}; bool is_deferred{false}; - KernelCore& kernel; + Kernel::KernelCore& kernel; Core::Memory::Memory& memory; }; -} // namespace Kernel +} // namespace Service diff --git a/src/core/hle/ipc_helpers.h b/src/core/hle/service/ipc_helpers.h index f8ab55d83..e4cb4e1f2 100644 --- a/src/core/hle/ipc_helpers.h +++ b/src/core/hle/service/ipc_helpers.h @@ -10,27 +10,27 @@ #include "common/assert.h" #include "common/common_types.h" #include "core/hle/ipc.h" -#include "core/hle/kernel/hle_ipc.h" #include "core/hle/kernel/k_process.h" #include "core/hle/kernel/k_resource_limit.h" #include "core/hle/kernel/k_session.h" #include "core/hle/result.h" +#include "core/hle/service/hle_ipc.h" #include "core/hle/service/server_manager.h" namespace IPC { -constexpr Result ERR_REMOTE_PROCESS_DEAD{ErrorModule::HIPC, 301}; +constexpr Result ResultSessionClosed{ErrorModule::HIPC, 301}; class RequestHelperBase { protected: - Kernel::HLERequestContext* context = nullptr; + Service::HLERequestContext* context = nullptr; u32* cmdbuf; u32 index = 0; public: explicit RequestHelperBase(u32* command_buffer) : cmdbuf(command_buffer) {} - explicit RequestHelperBase(Kernel::HLERequestContext& ctx) + explicit RequestHelperBase(Service::HLERequestContext& ctx) : context(&ctx), cmdbuf(ctx.CommandBuffer()) {} void Skip(u32 size_in_words, bool set_to_null) { @@ -68,7 +68,7 @@ public: AlwaysMoveHandles = 1, }; - explicit ResponseBuilder(Kernel::HLERequestContext& ctx, u32 normal_params_size_, + explicit ResponseBuilder(Service::HLERequestContext& ctx, u32 normal_params_size_, u32 num_handles_to_copy_ = 0, u32 num_objects_to_move_ = 0, Flags flags = Flags::None) : RequestHelperBase(ctx), normal_params_size(normal_params_size_), @@ -155,9 +155,9 @@ public: Kernel::LimitableResource::SessionCountMax, 1); auto* session = Kernel::KSession::Create(kernel); - session->Initialize(nullptr, iface->GetServiceName()); + session->Initialize(nullptr, 0); - auto next_manager = std::make_shared<Kernel::SessionRequestManager>( + auto next_manager = std::make_shared<Service::SessionRequestManager>( kernel, manager->GetServerManager()); next_manager->SetSessionHandler(iface); manager->GetServerManager().RegisterSession(&session->GetServerSession(), next_manager); @@ -347,7 +347,7 @@ class RequestParser : public RequestHelperBase { public: explicit RequestParser(u32* command_buffer) : RequestHelperBase(command_buffer) {} - explicit RequestParser(Kernel::HLERequestContext& ctx) : RequestHelperBase(ctx) { + explicit RequestParser(Service::HLERequestContext& ctx) : RequestHelperBase(ctx) { // TIPC does not have data payload offset if (!ctx.IsTipc()) { ASSERT_MSG(ctx.GetDataPayloadOffset(), "context is incomplete"); diff --git a/src/core/hle/service/jit/jit.cpp b/src/core/hle/service/jit/jit.cpp index 005c212dc..46bcfd695 100644 --- a/src/core/hle/service/jit/jit.cpp +++ b/src/core/hle/service/jit/jit.cpp @@ -3,10 +3,10 @@ #include "core/arm/symbols.h" #include "core/core.h" -#include "core/hle/ipc_helpers.h" #include "core/hle/kernel/k_code_memory.h" #include "core/hle/kernel/k_transfer_memory.h" #include "core/hle/result.h" +#include "core/hle/service/ipc_helpers.h" #include "core/hle/service/jit/jit.h" #include "core/hle/service/jit/jit_context.h" #include "core/hle/service/server_manager.h" @@ -44,7 +44,7 @@ public: configuration.sys_rx_memory = user_rx; } - void GenerateCode(Kernel::HLERequestContext& ctx) { + void GenerateCode(HLERequestContext& ctx) { LOG_DEBUG(Service_JIT, "called"); struct InputParameters { @@ -126,7 +126,7 @@ public: } }; - void Control(Kernel::HLERequestContext& ctx) { + void Control(HLERequestContext& ctx) { LOG_DEBUG(Service_JIT, "called"); IPC::RequestParser rp{ctx}; @@ -171,7 +171,7 @@ public: } } - void LoadPlugin(Kernel::HLERequestContext& ctx) { + void LoadPlugin(HLERequestContext& ctx) { LOG_DEBUG(Service_JIT, "called"); IPC::RequestParser rp{ctx}; @@ -277,7 +277,7 @@ public: rb.Push(ResultSuccess); } - void GetCodeAddress(Kernel::HLERequestContext& ctx) { + void GetCodeAddress(HLERequestContext& ctx) { LOG_DEBUG(Service_JIT, "called"); IPC::ResponseBuilder rb{ctx, 6}; @@ -333,7 +333,7 @@ public: RegisterHandlers(functions); } - void CreateJitEnvironment(Kernel::HLERequestContext& ctx) { + void CreateJitEnvironment(HLERequestContext& ctx) { LOG_DEBUG(Service_JIT, "called"); struct Parameters { diff --git a/src/core/hle/service/lbl/lbl.cpp b/src/core/hle/service/lbl/lbl.cpp index 3f3c68d80..98a79365d 100644 --- a/src/core/hle/service/lbl/lbl.cpp +++ b/src/core/hle/service/lbl/lbl.cpp @@ -5,7 +5,7 @@ #include <memory> #include "common/logging/log.h" -#include "core/hle/ipc_helpers.h" +#include "core/hle/service/ipc_helpers.h" #include "core/hle/service/lbl/lbl.h" #include "core/hle/service/server_manager.h" #include "core/hle/service/service.h" @@ -60,7 +60,7 @@ private: On = 1, }; - void SetCurrentBrightnessSetting(Kernel::HLERequestContext& ctx) { + void SetCurrentBrightnessSetting(HLERequestContext& ctx) { IPC::RequestParser rp{ctx}; auto brightness = rp.Pop<float>(); @@ -78,7 +78,7 @@ private: rb.Push(ResultSuccess); } - void GetCurrentBrightnessSetting(Kernel::HLERequestContext& ctx) { + void GetCurrentBrightnessSetting(HLERequestContext& ctx) { auto brightness = current_brightness; if (!std::isfinite(brightness)) { LOG_ERROR(Service_LBL, "Brightness is infinite!"); @@ -92,7 +92,7 @@ private: rb.Push(brightness); } - void SwitchBacklightOn(Kernel::HLERequestContext& ctx) { + void SwitchBacklightOn(HLERequestContext& ctx) { IPC::RequestParser rp{ctx}; const auto fade_time = rp.Pop<u64_le>(); LOG_WARNING(Service_LBL, "(STUBBED) called, fade_time={}", fade_time); @@ -103,7 +103,7 @@ private: rb.Push(ResultSuccess); } - void SwitchBacklightOff(Kernel::HLERequestContext& ctx) { + void SwitchBacklightOff(HLERequestContext& ctx) { IPC::RequestParser rp{ctx}; const auto fade_time = rp.Pop<u64_le>(); LOG_WARNING(Service_LBL, "(STUBBED) called, fade_time={}", fade_time); @@ -114,7 +114,7 @@ private: rb.Push(ResultSuccess); } - void GetBacklightSwitchStatus(Kernel::HLERequestContext& ctx) { + void GetBacklightSwitchStatus(HLERequestContext& ctx) { LOG_DEBUG(Service_LBL, "called"); IPC::ResponseBuilder rb{ctx, 3}; @@ -123,7 +123,7 @@ private: : BacklightSwitchStatus::Off); } - void EnableDimming(Kernel::HLERequestContext& ctx) { + void EnableDimming(HLERequestContext& ctx) { LOG_DEBUG(Service_LBL, "called"); dimming = true; @@ -132,7 +132,7 @@ private: rb.Push(ResultSuccess); } - void DisableDimming(Kernel::HLERequestContext& ctx) { + void DisableDimming(HLERequestContext& ctx) { LOG_DEBUG(Service_LBL, "called"); dimming = false; @@ -141,7 +141,7 @@ private: rb.Push(ResultSuccess); } - void IsDimmingEnabled(Kernel::HLERequestContext& ctx) { + void IsDimmingEnabled(HLERequestContext& ctx) { LOG_DEBUG(Service_LBL, "called"); IPC::ResponseBuilder rb{ctx, 3}; @@ -149,7 +149,7 @@ private: rb.Push(dimming); } - void EnableAutoBrightnessControl(Kernel::HLERequestContext& ctx) { + void EnableAutoBrightnessControl(HLERequestContext& ctx) { LOG_DEBUG(Service_LBL, "called"); auto_brightness = true; update_instantly = true; @@ -158,7 +158,7 @@ private: rb.Push(ResultSuccess); } - void DisableAutoBrightnessControl(Kernel::HLERequestContext& ctx) { + void DisableAutoBrightnessControl(HLERequestContext& ctx) { LOG_DEBUG(Service_LBL, "called"); auto_brightness = false; @@ -166,7 +166,7 @@ private: rb.Push(ResultSuccess); } - void IsAutoBrightnessControlEnabled(Kernel::HLERequestContext& ctx) { + void IsAutoBrightnessControlEnabled(HLERequestContext& ctx) { LOG_DEBUG(Service_LBL, "called"); IPC::ResponseBuilder rb{ctx, 3}; @@ -174,7 +174,7 @@ private: rb.Push(auto_brightness); } - void SetAmbientLightSensorValue(Kernel::HLERequestContext& ctx) { + void SetAmbientLightSensorValue(HLERequestContext& ctx) { IPC::RequestParser rp{ctx}; const auto light_value = rp.Pop<float>(); @@ -186,7 +186,7 @@ private: rb.Push(ResultSuccess); } - void GetAmbientLightSensorValue(Kernel::HLERequestContext& ctx) { + void GetAmbientLightSensorValue(HLERequestContext& ctx) { LOG_DEBUG(Service_LBL, "called"); IPC::ResponseBuilder rb{ctx, 3}; @@ -194,7 +194,7 @@ private: rb.Push(ambient_light_value); } - void SetBrightnessReflectionDelayLevel(Kernel::HLERequestContext& ctx) { + void SetBrightnessReflectionDelayLevel(HLERequestContext& ctx) { // This is Intentional, this function does absolutely nothing LOG_DEBUG(Service_LBL, "called"); @@ -202,7 +202,7 @@ private: rb.Push(ResultSuccess); } - void GetBrightnessReflectionDelayLevel(Kernel::HLERequestContext& ctx) { + void GetBrightnessReflectionDelayLevel(HLERequestContext& ctx) { // This is intentional, the function is hard coded to return 0.0f on hardware LOG_DEBUG(Service_LBL, "called"); @@ -211,7 +211,7 @@ private: rb.Push(0.0f); } - void SetCurrentBrightnessMapping(Kernel::HLERequestContext& ctx) { + void SetCurrentBrightnessMapping(HLERequestContext& ctx) { // This is Intentional, this function does absolutely nothing LOG_DEBUG(Service_LBL, "called"); @@ -219,7 +219,7 @@ private: rb.Push(ResultSuccess); } - void GetCurrentBrightnessMapping(Kernel::HLERequestContext& ctx) { + void GetCurrentBrightnessMapping(HLERequestContext& ctx) { // This is Intentional, this function does absolutely nothing LOG_DEBUG(Service_LBL, "called"); @@ -228,7 +228,7 @@ private: // This function is suppose to return something but it seems like it doesn't } - void SetCurrentAmbientLightSensorMapping(Kernel::HLERequestContext& ctx) { + void SetCurrentAmbientLightSensorMapping(HLERequestContext& ctx) { // This is Intentional, this function does absolutely nothing LOG_DEBUG(Service_LBL, "called"); @@ -236,7 +236,7 @@ private: rb.Push(ResultSuccess); } - void GetCurrentAmbientLightSensorMapping(Kernel::HLERequestContext& ctx) { + void GetCurrentAmbientLightSensorMapping(HLERequestContext& ctx) { // This is Intentional, this function does absolutely nothing LOG_DEBUG(Service_LBL, "called"); @@ -245,7 +245,7 @@ private: // This function is suppose to return something but it seems like it doesn't } - void IsAmbientLightSensorAvailable(Kernel::HLERequestContext& ctx) { + void IsAmbientLightSensorAvailable(HLERequestContext& ctx) { LOG_WARNING(Service_LBL, "(STUBBED) called"); IPC::ResponseBuilder rb{ctx, 3}; rb.Push(ResultSuccess); @@ -253,7 +253,7 @@ private: rb.Push(true); } - void SetCurrentBrightnessSettingForVrMode(Kernel::HLERequestContext& ctx) { + void SetCurrentBrightnessSettingForVrMode(HLERequestContext& ctx) { IPC::RequestParser rp{ctx}; auto brightness = rp.Pop<float>(); @@ -270,7 +270,7 @@ private: rb.Push(ResultSuccess); } - void GetCurrentBrightnessSettingForVrMode(Kernel::HLERequestContext& ctx) { + void GetCurrentBrightnessSettingForVrMode(HLERequestContext& ctx) { auto brightness = current_vr_brightness; if (!std::isfinite(brightness)) { LOG_ERROR(Service_LBL, "Brightness is infinite!"); @@ -284,7 +284,7 @@ private: rb.Push(brightness); } - void EnableVrMode(Kernel::HLERequestContext& ctx) { + void EnableVrMode(HLERequestContext& ctx) { LOG_DEBUG(Service_LBL, "called"); IPC::ResponseBuilder rb{ctx, 2}; @@ -293,7 +293,7 @@ private: vr_mode_enabled = true; } - void DisableVrMode(Kernel::HLERequestContext& ctx) { + void DisableVrMode(HLERequestContext& ctx) { LOG_DEBUG(Service_LBL, "called"); IPC::ResponseBuilder rb{ctx, 2}; @@ -302,7 +302,7 @@ private: vr_mode_enabled = false; } - void IsVrModeEnabled(Kernel::HLERequestContext& ctx) { + void IsVrModeEnabled(HLERequestContext& ctx) { LOG_DEBUG(Service_LBL, "called"); IPC::ResponseBuilder rb{ctx, 3}; diff --git a/src/core/hle/service/ldn/ldn.cpp b/src/core/hle/service/ldn/ldn.cpp index 4c2abe7d3..9d149a7cd 100644 --- a/src/core/hle/service/ldn/ldn.cpp +++ b/src/core/hle/service/ldn/ldn.cpp @@ -50,7 +50,7 @@ public: RegisterHandlers(functions); } - void CreateMonitorService(Kernel::HLERequestContext& ctx) { + void CreateMonitorService(HLERequestContext& ctx) { LOG_DEBUG(Service_LDN, "called"); IPC::ResponseBuilder rb{ctx, 2, 0, 1}; @@ -169,7 +169,7 @@ public: state_change_event->Signal(); } - void GetState(Kernel::HLERequestContext& ctx) { + void GetState(HLERequestContext& ctx) { State state = State::Error; if (is_initialized) { @@ -181,7 +181,7 @@ public: rb.PushEnum(state); } - void GetNetworkInfo(Kernel::HLERequestContext& ctx) { + void GetNetworkInfo(HLERequestContext& ctx) { const auto write_buffer_size = ctx.GetWriteBufferSize(); if (write_buffer_size != sizeof(NetworkInfo)) { @@ -205,7 +205,7 @@ public: rb.Push(ResultSuccess); } - void GetIpv4Address(Kernel::HLERequestContext& ctx) { + void GetIpv4Address(HLERequestContext& ctx) { const auto network_interface = Network::GetSelectedNetworkInterface(); if (!network_interface) { @@ -234,13 +234,13 @@ public: rb.PushRaw(subnet_mask); } - void GetDisconnectReason(Kernel::HLERequestContext& ctx) { + void GetDisconnectReason(HLERequestContext& ctx) { IPC::ResponseBuilder rb{ctx, 3}; rb.Push(ResultSuccess); rb.PushEnum(lan_discovery.GetDisconnectReason()); } - void GetSecurityParameter(Kernel::HLERequestContext& ctx) { + void GetSecurityParameter(HLERequestContext& ctx) { SecurityParameter security_parameter{}; NetworkInfo info{}; const Result rc = lan_discovery.GetNetworkInfo(info); @@ -261,7 +261,7 @@ public: rb.PushRaw<SecurityParameter>(security_parameter); } - void GetNetworkConfig(Kernel::HLERequestContext& ctx) { + void GetNetworkConfig(HLERequestContext& ctx) { NetworkConfig config{}; NetworkInfo info{}; const Result rc = lan_discovery.GetNetworkInfo(info); @@ -283,7 +283,7 @@ public: rb.PushRaw<NetworkConfig>(config); } - void AttachStateChangeEvent(Kernel::HLERequestContext& ctx) { + void AttachStateChangeEvent(HLERequestContext& ctx) { LOG_INFO(Service_LDN, "called"); IPC::ResponseBuilder rb{ctx, 2, 1}; @@ -291,7 +291,7 @@ public: rb.PushCopyObjects(state_change_event->GetReadableEvent()); } - void GetNetworkInfoLatestUpdate(Kernel::HLERequestContext& ctx) { + void GetNetworkInfoLatestUpdate(HLERequestContext& ctx) { const std::size_t network_buffer_size = ctx.GetWriteBufferSize(0); const std::size_t node_buffer_count = ctx.GetWriteBufferNumElements<NodeLatestUpdate>(1); @@ -321,15 +321,15 @@ public: rb.Push(ResultSuccess); } - void Scan(Kernel::HLERequestContext& ctx) { + void Scan(HLERequestContext& ctx) { ScanImpl(ctx); } - void ScanPrivate(Kernel::HLERequestContext& ctx) { + void ScanPrivate(HLERequestContext& ctx) { ScanImpl(ctx, true); } - void ScanImpl(Kernel::HLERequestContext& ctx, bool is_private = false) { + void ScanImpl(HLERequestContext& ctx, bool is_private = false) { IPC::RequestParser rp{ctx}; const auto channel{rp.PopEnum<WifiChannel>()}; const auto scan_filter{rp.PopRaw<ScanFilter>()}; @@ -358,40 +358,40 @@ public: rb.Push<u32>(count); } - void SetWirelessControllerRestriction(Kernel::HLERequestContext& ctx) { + void SetWirelessControllerRestriction(HLERequestContext& ctx) { LOG_WARNING(Service_LDN, "(STUBBED) called"); IPC::ResponseBuilder rb{ctx, 2}; rb.Push(ResultSuccess); } - void OpenAccessPoint(Kernel::HLERequestContext& ctx) { + void OpenAccessPoint(HLERequestContext& ctx) { LOG_INFO(Service_LDN, "called"); IPC::ResponseBuilder rb{ctx, 2}; rb.Push(lan_discovery.OpenAccessPoint()); } - void CloseAccessPoint(Kernel::HLERequestContext& ctx) { + void CloseAccessPoint(HLERequestContext& ctx) { LOG_INFO(Service_LDN, "called"); IPC::ResponseBuilder rb{ctx, 2}; rb.Push(lan_discovery.CloseAccessPoint()); } - void CreateNetwork(Kernel::HLERequestContext& ctx) { + void CreateNetwork(HLERequestContext& ctx) { LOG_INFO(Service_LDN, "called"); CreateNetworkImpl(ctx); } - void CreateNetworkPrivate(Kernel::HLERequestContext& ctx) { + void CreateNetworkPrivate(HLERequestContext& ctx) { LOG_INFO(Service_LDN, "called"); CreateNetworkImpl(ctx, true); } - void CreateNetworkImpl(Kernel::HLERequestContext& ctx, bool is_private = false) { + void CreateNetworkImpl(HLERequestContext& ctx, bool is_private = false) { IPC::RequestParser rp{ctx}; const auto security_config{rp.PopRaw<SecurityConfig>()}; @@ -405,49 +405,49 @@ public: rb.Push(lan_discovery.CreateNetwork(security_config, user_config, network_Config)); } - void DestroyNetwork(Kernel::HLERequestContext& ctx) { + void DestroyNetwork(HLERequestContext& ctx) { LOG_INFO(Service_LDN, "called"); IPC::ResponseBuilder rb{ctx, 2}; rb.Push(lan_discovery.DestroyNetwork()); } - void SetAdvertiseData(Kernel::HLERequestContext& ctx) { + void SetAdvertiseData(HLERequestContext& ctx) { const auto read_buffer = ctx.ReadBuffer(); IPC::ResponseBuilder rb{ctx, 2}; rb.Push(lan_discovery.SetAdvertiseData(read_buffer)); } - void SetStationAcceptPolicy(Kernel::HLERequestContext& ctx) { + void SetStationAcceptPolicy(HLERequestContext& ctx) { LOG_WARNING(Service_LDN, "(STUBBED) called"); IPC::ResponseBuilder rb{ctx, 2}; rb.Push(ResultSuccess); } - void AddAcceptFilterEntry(Kernel::HLERequestContext& ctx) { + void AddAcceptFilterEntry(HLERequestContext& ctx) { LOG_WARNING(Service_LDN, "(STUBBED) called"); IPC::ResponseBuilder rb{ctx, 2}; rb.Push(ResultSuccess); } - void OpenStation(Kernel::HLERequestContext& ctx) { + void OpenStation(HLERequestContext& ctx) { LOG_INFO(Service_LDN, "called"); IPC::ResponseBuilder rb{ctx, 2}; rb.Push(lan_discovery.OpenStation()); } - void CloseStation(Kernel::HLERequestContext& ctx) { + void CloseStation(HLERequestContext& ctx) { LOG_INFO(Service_LDN, "called"); IPC::ResponseBuilder rb{ctx, 2}; rb.Push(lan_discovery.CloseStation()); } - void Connect(Kernel::HLERequestContext& ctx) { + void Connect(HLERequestContext& ctx) { IPC::RequestParser rp{ctx}; struct Parameters { SecurityConfig security_config; @@ -481,14 +481,14 @@ public: static_cast<u16>(parameters.local_communication_version))); } - void Disconnect(Kernel::HLERequestContext& ctx) { + void Disconnect(HLERequestContext& ctx) { LOG_INFO(Service_LDN, "called"); IPC::ResponseBuilder rb{ctx, 2}; rb.Push(lan_discovery.Disconnect()); } - void Initialize(Kernel::HLERequestContext& ctx) { + void Initialize(HLERequestContext& ctx) { const auto rc = InitializeImpl(ctx); if (rc.IsError()) { LOG_ERROR(Service_LDN, "Network isn't initialized, rc={}", rc.raw); @@ -498,7 +498,7 @@ public: rb.Push(rc); } - void Finalize(Kernel::HLERequestContext& ctx) { + void Finalize(HLERequestContext& ctx) { if (auto room_member = room_network.GetRoomMember().lock()) { room_member->Unbind(ldn_packet_received); } @@ -509,7 +509,7 @@ public: rb.Push(lan_discovery.Finalize()); } - void Initialize2(Kernel::HLERequestContext& ctx) { + void Initialize2(HLERequestContext& ctx) { const auto rc = InitializeImpl(ctx); if (rc.IsError()) { LOG_ERROR(Service_LDN, "Network isn't initialized, rc={}", rc.raw); @@ -519,7 +519,7 @@ public: rb.Push(rc); } - Result InitializeImpl(Kernel::HLERequestContext& ctx) { + Result InitializeImpl(HLERequestContext& ctx) { const auto network_interface = Network::GetSelectedNetworkInterface(); if (!network_interface) { LOG_ERROR(Service_LDN, "No network interface is set"); @@ -562,7 +562,7 @@ public: RegisterHandlers(functions); } - void CreateSystemLocalCommunicationService(Kernel::HLERequestContext& ctx) { + void CreateSystemLocalCommunicationService(HLERequestContext& ctx) { LOG_DEBUG(Service_LDN, "called"); IPC::ResponseBuilder rb{ctx, 2, 0, 1}; @@ -583,7 +583,7 @@ public: RegisterHandlers(functions); } - void CreateUserLocalCommunicationService(Kernel::HLERequestContext& ctx) { + void CreateUserLocalCommunicationService(HLERequestContext& ctx) { LOG_DEBUG(Service_LDN, "called"); IPC::ResponseBuilder rb{ctx, 2, 0, 1}; @@ -647,7 +647,7 @@ public: RegisterHandlers(functions); } - void Initialize(Kernel::HLERequestContext& ctx) { + void Initialize(HLERequestContext& ctx) { LOG_WARNING(Service_LDN, "(STUBBED) called"); IPC::ResponseBuilder rb{ctx, 2}; @@ -668,7 +668,7 @@ public: RegisterHandlers(functions); } - void CreateNetworkervice(Kernel::HLERequestContext& ctx) { + void CreateNetworkervice(HLERequestContext& ctx) { IPC::RequestParser rp{ctx}; const u64 reserved_input = rp.Pop<u64>(); const u32 input = rp.Pop<u32>(); @@ -681,7 +681,7 @@ public: rb.PushIpcInterface<INetworkService>(system); } - void CreateMonitorService(Kernel::HLERequestContext& ctx) { + void CreateMonitorService(HLERequestContext& ctx) { IPC::RequestParser rp{ctx}; const u64 reserved_input = rp.Pop<u64>(); @@ -706,7 +706,7 @@ public: RegisterHandlers(functions); } - void CreateNetworkervice(Kernel::HLERequestContext& ctx) { + void CreateNetworkervice(HLERequestContext& ctx) { IPC::RequestParser rp{ctx}; const u64 reserved_input = rp.Pop<u64>(); const u32 input = rp.Pop<u32>(); @@ -719,7 +719,7 @@ public: rb.PushIpcInterface<INetworkService>(system); } - void CreateMonitorService(Kernel::HLERequestContext& ctx) { + void CreateMonitorService(HLERequestContext& ctx) { IPC::RequestParser rp{ctx}; const u64 reserved_input = rp.Pop<u64>(); diff --git a/src/core/hle/service/ldn/ldn.h b/src/core/hle/service/ldn/ldn.h index fa869fa89..f4a319168 100644 --- a/src/core/hle/service/ldn/ldn.h +++ b/src/core/hle/service/ldn/ldn.h @@ -3,9 +3,9 @@ #pragma once -#include "core/hle/ipc_helpers.h" #include "core/hle/kernel/k_event.h" #include "core/hle/result.h" +#include "core/hle/service/ipc_helpers.h" #include "core/hle/service/kernel_helpers.h" #include "core/hle/service/sm/sm.h" diff --git a/src/core/hle/service/ldr/ldr.cpp b/src/core/hle/service/ldr/ldr.cpp index c82e189f4..6de96ed5b 100644 --- a/src/core/hle/service/ldr/ldr.cpp +++ b/src/core/hle/service/ldr/ldr.cpp @@ -9,10 +9,10 @@ #include "common/hex_util.h" #include "common/scope_exit.h" #include "core/core.h" -#include "core/hle/ipc_helpers.h" #include "core/hle/kernel/k_page_table.h" #include "core/hle/kernel/svc_results.h" #include "core/hle/kernel/svc_types.h" +#include "core/hle/service/ipc_helpers.h" #include "core/hle/service/ldr/ldr.h" #include "core/hle/service/server_manager.h" #include "core/hle/service/service.h" @@ -175,7 +175,7 @@ public: RegisterHandlers(functions); } - void RegisterModuleInfo(Kernel::HLERequestContext& ctx) { + void RegisterModuleInfo(HLERequestContext& ctx) { struct Parameters { u64_le process_id; u64_le nrr_address; @@ -272,7 +272,7 @@ public: rb.Push(ResultSuccess); } - void UnregisterModuleInfo(Kernel::HLERequestContext& ctx) { + void UnregisterModuleInfo(HLERequestContext& ctx) { IPC::RequestParser rp{ctx}; const auto pid = rp.Pop<u64>(); const auto nrr_address = rp.Pop<VAddr>(); @@ -446,7 +446,7 @@ public: data_start, bss_end_addr - data_start, Kernel::Svc::MemoryPermission::ReadWrite); } - void LoadModule(Kernel::HLERequestContext& ctx) { + void LoadModule(HLERequestContext& ctx) { struct Parameters { u64_le process_id; u64_le image_address; @@ -592,7 +592,7 @@ public: return ResultSuccess; } - void UnloadModule(Kernel::HLERequestContext& ctx) { + void UnloadModule(HLERequestContext& ctx) { if (!initialized) { LOG_ERROR(Service_LDR, "LDR:RO not initialized before use!"); IPC::ResponseBuilder rb{ctx, 2}; @@ -638,7 +638,7 @@ public: rb.Push(result); } - void Initialize(Kernel::HLERequestContext& ctx) { + void Initialize(HLERequestContext& ctx) { LOG_WARNING(Service_LDR, "(STUBBED) called"); initialized = true; diff --git a/src/core/hle/service/lm/lm.cpp b/src/core/hle/service/lm/lm.cpp index 7efd8e0ab..20df00233 100644 --- a/src/core/hle/service/lm/lm.cpp +++ b/src/core/hle/service/lm/lm.cpp @@ -8,7 +8,7 @@ #include <boost/container_hash/hash.hpp> #include "common/logging/log.h" #include "core/core.h" -#include "core/hle/ipc_helpers.h" +#include "core/hle/service/ipc_helpers.h" #include "core/hle/service/lm/lm.h" #include "core/hle/service/server_manager.h" #include "core/hle/service/service.h" @@ -93,7 +93,7 @@ public: } private: - void Log(Kernel::HLERequestContext& ctx) { + void Log(HLERequestContext& ctx) { std::size_t offset{}; const auto data = ctx.ReadBuffer(); @@ -148,7 +148,7 @@ private: } } - void SetDestination(Kernel::HLERequestContext& ctx) { + void SetDestination(HLERequestContext& ctx) { IPC::RequestParser rp{ctx}; const auto log_destination = rp.PopEnum<LogDestination>(); @@ -343,7 +343,7 @@ public: } private: - void OpenLogger(Kernel::HLERequestContext& ctx) { + void OpenLogger(HLERequestContext& ctx) { LOG_DEBUG(Service_LM, "called"); IPC::ResponseBuilder rb{ctx, 2, 0, 1}; diff --git a/src/core/hle/service/mii/mii.cpp b/src/core/hle/service/mii/mii.cpp index 50dc0ac64..5c7adf97d 100644 --- a/src/core/hle/service/mii/mii.cpp +++ b/src/core/hle/service/mii/mii.cpp @@ -4,7 +4,7 @@ #include <memory> #include "common/logging/log.h" -#include "core/hle/ipc_helpers.h" +#include "core/hle/service/ipc_helpers.h" #include "core/hle/service/mii/mii.h" #include "core/hle/service/mii/mii_manager.h" #include "core/hle/service/server_manager.h" @@ -65,7 +65,7 @@ private: return out; } - void IsUpdated(Kernel::HLERequestContext& ctx) { + void IsUpdated(HLERequestContext& ctx) { IPC::RequestParser rp{ctx}; const auto source_flag{rp.PopRaw<SourceFlag>()}; @@ -76,7 +76,7 @@ private: rb.Push(manager.CheckAndResetUpdateCounter(source_flag, current_update_counter)); } - void IsFullDatabase(Kernel::HLERequestContext& ctx) { + void IsFullDatabase(HLERequestContext& ctx) { LOG_DEBUG(Service_Mii, "called"); IPC::ResponseBuilder rb{ctx, 3}; @@ -84,7 +84,7 @@ private: rb.Push(manager.IsFullDatabase()); } - void GetCount(Kernel::HLERequestContext& ctx) { + void GetCount(HLERequestContext& ctx) { IPC::RequestParser rp{ctx}; const auto source_flag{rp.PopRaw<SourceFlag>()}; @@ -95,7 +95,7 @@ private: rb.Push<u32>(manager.GetCount(source_flag)); } - void Get(Kernel::HLERequestContext& ctx) { + void Get(HLERequestContext& ctx) { IPC::RequestParser rp{ctx}; const auto source_flag{rp.PopRaw<SourceFlag>()}; @@ -117,7 +117,7 @@ private: rb.Push<u32>(static_cast<u32>(result->size())); } - void Get1(Kernel::HLERequestContext& ctx) { + void Get1(HLERequestContext& ctx) { IPC::RequestParser rp{ctx}; const auto source_flag{rp.PopRaw<SourceFlag>()}; @@ -142,7 +142,7 @@ private: rb.Push<u32>(static_cast<u32>(result->size())); } - void UpdateLatest(Kernel::HLERequestContext& ctx) { + void UpdateLatest(HLERequestContext& ctx) { IPC::RequestParser rp{ctx}; const auto info{rp.PopRaw<CharInfo>()}; const auto source_flag{rp.PopRaw<SourceFlag>()}; @@ -161,7 +161,7 @@ private: rb.PushRaw<CharInfo>(*result); } - void BuildRandom(Kernel::HLERequestContext& ctx) { + void BuildRandom(HLERequestContext& ctx) { IPC::RequestParser rp{ctx}; const auto age{rp.PopRaw<Age>()}; @@ -196,7 +196,7 @@ private: rb.PushRaw<CharInfo>(manager.BuildRandom(age, gender, race)); } - void BuildDefault(Kernel::HLERequestContext& ctx) { + void BuildDefault(HLERequestContext& ctx) { IPC::RequestParser rp{ctx}; const auto index{rp.Pop<u32>()}; @@ -215,7 +215,7 @@ private: rb.PushRaw<CharInfo>(manager.BuildDefault(index)); } - void GetIndex(Kernel::HLERequestContext& ctx) { + void GetIndex(HLERequestContext& ctx) { IPC::RequestParser rp{ctx}; const auto info{rp.PopRaw<CharInfo>()}; @@ -227,7 +227,7 @@ private: rb.Push(index); } - void SetInterfaceVersion(Kernel::HLERequestContext& ctx) { + void SetInterfaceVersion(HLERequestContext& ctx) { IPC::RequestParser rp{ctx}; current_interface_version = rp.PopRaw<u32>(); @@ -239,7 +239,7 @@ private: rb.Push(ResultSuccess); } - void Convert(Kernel::HLERequestContext& ctx) { + void Convert(HLERequestContext& ctx) { IPC::RequestParser rp{ctx}; const auto mii_v3{rp.PopRaw<Ver3StoreData>()}; @@ -275,7 +275,7 @@ public: } private: - void GetDatabaseService(Kernel::HLERequestContext& ctx) { + void GetDatabaseService(HLERequestContext& ctx) { IPC::ResponseBuilder rb{ctx, 2, 0, 1}; rb.Push(ResultSuccess); rb.PushIpcInterface<IDatabaseService>(system); diff --git a/src/core/hle/service/mii/mii_manager.cpp b/src/core/hle/service/mii/mii_manager.cpp index 3a2fe938f..c920650f5 100644 --- a/src/core/hle/service/mii/mii_manager.cpp +++ b/src/core/hle/service/mii/mii_manager.cpp @@ -510,7 +510,7 @@ CharInfo MiiManager::ConvertV3ToCharInfo(const Ver3StoreData& mii_v3) const { return mii; } -Ver3StoreData MiiManager::ConvertCharInfoToV3(const CharInfo& mii) const { +Ver3StoreData MiiManager::BuildFromStoreData(const CharInfo& mii) const { Service::Mii::MiiManager manager; Ver3StoreData mii_v3{}; @@ -534,16 +534,13 @@ Ver3StoreData MiiManager::ConvertCharInfoToV3(const CharInfo& mii) const { mii_v3.region_information.character_set.Assign(mii.font_region); mii_v3.appearance_bits1.face_shape.Assign(mii.faceline_type); - mii_v3.appearance_bits1.skin_color.Assign(mii.faceline_color); mii_v3.appearance_bits2.wrinkles.Assign(mii.faceline_wrinkle); mii_v3.appearance_bits2.makeup.Assign(mii.faceline_make); mii_v3.hair_style = mii.hair_type; - mii_v3.appearance_bits3.hair_color.Assign(mii.hair_color); mii_v3.appearance_bits3.flip_hair.Assign(mii.hair_flip); mii_v3.appearance_bits4.eye_type.Assign(mii.eye_type); - mii_v3.appearance_bits4.eye_color.Assign(mii.eye_color); mii_v3.appearance_bits4.eye_scale.Assign(mii.eye_scale); mii_v3.appearance_bits4.eye_vertical_stretch.Assign(mii.eye_aspect); mii_v3.appearance_bits4.eye_rotation.Assign(mii.eye_rotate); @@ -551,7 +548,6 @@ Ver3StoreData MiiManager::ConvertCharInfoToV3(const CharInfo& mii) const { mii_v3.appearance_bits4.eye_y_position.Assign(mii.eye_y); mii_v3.appearance_bits5.eyebrow_style.Assign(mii.eyebrow_type); - mii_v3.appearance_bits5.eyebrow_color.Assign(mii.eyebrow_color); mii_v3.appearance_bits5.eyebrow_scale.Assign(mii.eyebrow_scale); mii_v3.appearance_bits5.eyebrow_yscale.Assign(mii.eyebrow_aspect); mii_v3.appearance_bits5.eyebrow_rotation.Assign(mii.eyebrow_rotate); @@ -563,7 +559,6 @@ Ver3StoreData MiiManager::ConvertCharInfoToV3(const CharInfo& mii) const { mii_v3.appearance_bits6.nose_y_position.Assign(mii.nose_y); mii_v3.appearance_bits7.mouth_type.Assign(mii.mouth_type); - mii_v3.appearance_bits7.mouth_color.Assign(mii.mouth_color); mii_v3.appearance_bits7.mouth_scale.Assign(mii.mouth_scale); mii_v3.appearance_bits7.mouth_horizontal_stretch.Assign(mii.mouth_aspect); mii_v3.appearance_bits8.mouth_y_position.Assign(mii.mouth_y); @@ -573,10 +568,7 @@ Ver3StoreData MiiManager::ConvertCharInfoToV3(const CharInfo& mii) const { mii_v3.appearance_bits9.mustache_y_position.Assign(mii.mustache_y); mii_v3.appearance_bits9.bear_type.Assign(mii.beard_type); - mii_v3.appearance_bits9.facial_hair_color.Assign(mii.beard_color); - mii_v3.appearance_bits10.glasses_type.Assign(mii.glasses_type); - mii_v3.appearance_bits10.glasses_color.Assign(mii.glasses_color); mii_v3.appearance_bits10.glasses_scale.Assign(mii.glasses_scale); mii_v3.appearance_bits10.glasses_y_position.Assign(mii.glasses_y); @@ -585,11 +577,36 @@ Ver3StoreData MiiManager::ConvertCharInfoToV3(const CharInfo& mii) const { mii_v3.appearance_bits11.mole_x_position.Assign(mii.mole_x); mii_v3.appearance_bits11.mole_y_position.Assign(mii.mole_y); + // These types are converted to V3 from a table + mii_v3.appearance_bits1.skin_color.Assign(Ver3FacelineColorTable[mii.faceline_color]); + mii_v3.appearance_bits3.hair_color.Assign(Ver3HairColorTable[mii.hair_color]); + mii_v3.appearance_bits4.eye_color.Assign(Ver3EyeColorTable[mii.eye_color]); + mii_v3.appearance_bits5.eyebrow_color.Assign(Ver3HairColorTable[mii.eyebrow_color]); + mii_v3.appearance_bits7.mouth_color.Assign(Ver3MouthlineColorTable[mii.mouth_color]); + mii_v3.appearance_bits9.facial_hair_color.Assign(Ver3HairColorTable[mii.beard_color]); + mii_v3.appearance_bits10.glasses_color.Assign(Ver3GlassColorTable[mii.glasses_color]); + mii_v3.appearance_bits10.glasses_type.Assign(Ver3GlassTypeTable[mii.glasses_type]); + + mii_v3.crc = GenerateCrc16(&mii_v3, sizeof(Ver3StoreData) - sizeof(u16)); + // TODO: Validate mii_v3 data return mii_v3; } +NfpStoreDataExtension MiiManager::SetFromStoreData(const CharInfo& mii) const { + return { + .faceline_color = static_cast<u8>(mii.faceline_color & 0xf), + .hair_color = static_cast<u8>(mii.hair_color & 0x7f), + .eye_color = static_cast<u8>(mii.eyebrow_color & 0x7f), + .eyebrow_color = static_cast<u8>(mii.eyebrow_color & 0x7f), + .mouth_color = static_cast<u8>(mii.mouth_color & 0x7f), + .beard_color = static_cast<u8>(mii.beard_color & 0x7f), + .glass_color = static_cast<u8>(mii.glasses_color & 0x7f), + .glass_type = static_cast<u8>(mii.glasses_type & 0x1f), + }; +} + bool MiiManager::ValidateV3Info(const Ver3StoreData& mii_v3) const { bool is_valid = mii_v3.version == 0 || mii_v3.version == 3; diff --git a/src/core/hle/service/mii/mii_manager.h b/src/core/hle/service/mii/mii_manager.h index 83ad3d343..5525fcd1c 100644 --- a/src/core/hle/service/mii/mii_manager.h +++ b/src/core/hle/service/mii/mii_manager.h @@ -23,11 +23,16 @@ public: CharInfo BuildRandom(Age age, Gender gender, Race race); CharInfo BuildDefault(std::size_t index); CharInfo ConvertV3ToCharInfo(const Ver3StoreData& mii_v3) const; - Ver3StoreData ConvertCharInfoToV3(const CharInfo& mii) const; bool ValidateV3Info(const Ver3StoreData& mii_v3) const; ResultVal<std::vector<MiiInfoElement>> GetDefault(SourceFlag source_flag); Result GetIndex(const CharInfo& info, u32& index); + // This is nn::mii::detail::Ver::StoreDataRaw::BuildFromStoreData + Ver3StoreData BuildFromStoreData(const CharInfo& mii) const; + + // This is nn::mii::detail::NfpStoreDataExtentionRaw::SetFromStoreData + NfpStoreDataExtension SetFromStoreData(const CharInfo& mii) const; + private: const Common::UUID user_id{}; u64 update_counter{}; diff --git a/src/core/hle/service/mii/types.h b/src/core/hle/service/mii/types.h index 9e3247397..c48d08d79 100644 --- a/src/core/hle/service/mii/types.h +++ b/src/core/hle/service/mii/types.h @@ -365,10 +365,68 @@ struct Ver3StoreData { } appearance_bits11; std::array<u16_le, 0xA> author_name; - INSERT_PADDING_BYTES(0x4); + INSERT_PADDING_BYTES(0x2); + u16_be crc; }; static_assert(sizeof(Ver3StoreData) == 0x60, "Ver3StoreData is an invalid size"); +struct NfpStoreDataExtension { + u8 faceline_color; + u8 hair_color; + u8 eye_color; + u8 eyebrow_color; + u8 mouth_color; + u8 beard_color; + u8 glass_color; + u8 glass_type; +}; +static_assert(sizeof(NfpStoreDataExtension) == 0x8, "NfpStoreDataExtension is an invalid size"); + +constexpr std::array<u8, 0x10> Ver3FacelineColorTable{ + 0x0, 0x1, 0x2, 0x3, 0x4, 0x5, 0x0, 0x1, 0x5, 0x5, +}; + +constexpr std::array<u8, 100> Ver3HairColorTable{ + 0x0, 0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7, 0x0, 0x4, 0x3, 0x5, 0x4, 0x4, 0x6, 0x2, 0x0, + 0x6, 0x4, 0x3, 0x2, 0x2, 0x7, 0x3, 0x2, 0x2, 0x2, 0x2, 0x2, 0x2, 0x2, 0x2, 0x2, 0x2, + 0x2, 0x2, 0x2, 0x2, 0x2, 0x2, 0x2, 0x4, 0x4, 0x4, 0x4, 0x4, 0x4, 0x4, 0x0, 0x0, 0x4, + 0x4, 0x4, 0x4, 0x4, 0x4, 0x0, 0x0, 0x0, 0x4, 0x4, 0x4, 0x4, 0x4, 0x4, 0x5, 0x5, 0x5, + 0x4, 0x4, 0x4, 0x4, 0x4, 0x4, 0x4, 0x5, 0x7, 0x5, 0x7, 0x7, 0x7, 0x7, 0x7, 0x6, 0x7, + 0x7, 0x7, 0x7, 0x7, 0x3, 0x7, 0x7, 0x7, 0x7, 0x7, 0x0, 0x4, 0x4, 0x4, 0x4, +}; + +constexpr std::array<u8, 100> Ver3EyeColorTable{ + 0x0, 0x2, 0x2, 0x2, 0x1, 0x3, 0x2, 0x3, 0x0, 0x1, 0x2, 0x3, 0x4, 0x5, 0x2, 0x2, 0x4, + 0x2, 0x1, 0x2, 0x2, 0x2, 0x2, 0x2, 0x2, 0x2, 0x2, 0x2, 0x2, 0x2, 0x2, 0x2, 0x2, 0x2, + 0x2, 0x2, 0x2, 0x2, 0x0, 0x0, 0x4, 0x4, 0x4, 0x4, 0x4, 0x4, 0x4, 0x1, 0x0, 0x4, 0x4, + 0x4, 0x4, 0x4, 0x4, 0x4, 0x0, 0x5, 0x5, 0x5, 0x5, 0x5, 0x5, 0x5, 0x5, 0x5, 0x5, 0x5, + 0x5, 0x5, 0x5, 0x5, 0x5, 0x5, 0x5, 0x3, 0x3, 0x3, 0x3, 0x3, 0x3, 0x3, 0x3, 0x2, 0x2, + 0x3, 0x3, 0x3, 0x3, 0x2, 0x2, 0x2, 0x2, 0x2, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, +}; + +constexpr std::array<u8, 100> Ver3MouthlineColorTable{ + 0x4, 0x4, 0x4, 0x4, 0x4, 0x4, 0x4, 0x3, 0x4, 0x4, 0x4, 0x4, 0x4, 0x4, 0x4, 0x1, 0x4, + 0x4, 0x4, 0x0, 0x1, 0x2, 0x3, 0x4, 0x4, 0x2, 0x3, 0x3, 0x4, 0x4, 0x4, 0x4, 0x1, 0x4, + 0x4, 0x2, 0x3, 0x3, 0x4, 0x4, 0x4, 0x4, 0x4, 0x4, 0x4, 0x3, 0x3, 0x3, 0x4, 0x4, 0x4, + 0x3, 0x3, 0x3, 0x3, 0x3, 0x4, 0x4, 0x4, 0x4, 0x4, 0x3, 0x3, 0x3, 0x3, 0x4, 0x4, 0x4, + 0x4, 0x3, 0x3, 0x3, 0x3, 0x3, 0x3, 0x4, 0x4, 0x3, 0x3, 0x3, 0x3, 0x3, 0x3, 0x4, 0x3, + 0x3, 0x3, 0x3, 0x3, 0x4, 0x0, 0x3, 0x3, 0x3, 0x3, 0x4, 0x3, 0x3, 0x3, 0x3, +}; + +constexpr std::array<u8, 100> Ver3GlassColorTable{ + 0x0, 0x1, 0x1, 0x1, 0x5, 0x1, 0x1, 0x4, 0x0, 0x5, 0x1, 0x1, 0x3, 0x5, 0x1, 0x2, 0x3, + 0x4, 0x5, 0x4, 0x2, 0x2, 0x4, 0x4, 0x2, 0x2, 0x2, 0x2, 0x2, 0x2, 0x2, 0x2, 0x2, 0x2, + 0x2, 0x2, 0x2, 0x2, 0x3, 0x3, 0x3, 0x3, 0x3, 0x3, 0x3, 0x3, 0x3, 0x3, 0x3, 0x3, 0x3, + 0x3, 0x3, 0x3, 0x3, 0x3, 0x0, 0x0, 0x0, 0x5, 0x5, 0x5, 0x5, 0x5, 0x5, 0x0, 0x5, 0x5, + 0x5, 0x5, 0x5, 0x5, 0x5, 0x5, 0x5, 0x5, 0x5, 0x5, 0x5, 0x5, 0x5, 0x5, 0x5, 0x1, 0x4, + 0x4, 0x4, 0x4, 0x4, 0x4, 0x4, 0x4, 0x4, 0x4, 0x5, 0x5, 0x5, 0x5, 0x5, 0x5, +}; + +constexpr std::array<u8, 20> Ver3GlassTypeTable{ + 0x0, 0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7, 0x8, 0x1, + 0x2, 0x1, 0x3, 0x7, 0x7, 0x6, 0x7, 0x8, 0x7, 0x7, +}; + struct MiiStoreData { using Name = std::array<char16_t, 10>; diff --git a/src/core/hle/service/mm/mm_u.cpp b/src/core/hle/service/mm/mm_u.cpp index bee72fa1b..6f43b1968 100644 --- a/src/core/hle/service/mm/mm_u.cpp +++ b/src/core/hle/service/mm/mm_u.cpp @@ -2,7 +2,7 @@ // SPDX-License-Identifier: GPL-2.0-or-later #include "common/logging/log.h" -#include "core/hle/ipc_helpers.h" +#include "core/hle/service/ipc_helpers.h" #include "core/hle/service/mm/mm_u.h" #include "core/hle/service/server_manager.h" #include "core/hle/service/sm/sm.h" @@ -29,21 +29,21 @@ public: } private: - void InitializeOld(Kernel::HLERequestContext& ctx) { + void InitializeOld(HLERequestContext& ctx) { LOG_WARNING(Service_MM, "(STUBBED) called"); IPC::ResponseBuilder rb{ctx, 2}; rb.Push(ResultSuccess); } - void FinalizeOld(Kernel::HLERequestContext& ctx) { + void FinalizeOld(HLERequestContext& ctx) { LOG_WARNING(Service_MM, "(STUBBED) called"); IPC::ResponseBuilder rb{ctx, 2}; rb.Push(ResultSuccess); } - void SetAndWaitOld(Kernel::HLERequestContext& ctx) { + void SetAndWaitOld(HLERequestContext& ctx) { IPC::RequestParser rp{ctx}; min = rp.Pop<u32>(); max = rp.Pop<u32>(); @@ -54,7 +54,7 @@ private: rb.Push(ResultSuccess); } - void GetOld(Kernel::HLERequestContext& ctx) { + void GetOld(HLERequestContext& ctx) { LOG_DEBUG(Service_MM, "(STUBBED) called"); IPC::ResponseBuilder rb{ctx, 3}; @@ -62,7 +62,7 @@ private: rb.Push(current); } - void Initialize(Kernel::HLERequestContext& ctx) { + void Initialize(HLERequestContext& ctx) { LOG_WARNING(Service_MM, "(STUBBED) called"); IPC::ResponseBuilder rb{ctx, 3}; @@ -70,14 +70,14 @@ private: rb.Push<u32>(id); // Any non zero value } - void Finalize(Kernel::HLERequestContext& ctx) { + void Finalize(HLERequestContext& ctx) { LOG_WARNING(Service_MM, "(STUBBED) called"); IPC::ResponseBuilder rb{ctx, 2}; rb.Push(ResultSuccess); } - void SetAndWait(Kernel::HLERequestContext& ctx) { + void SetAndWait(HLERequestContext& ctx) { IPC::RequestParser rp{ctx}; u32 input_id = rp.Pop<u32>(); min = rp.Pop<u32>(); @@ -90,7 +90,7 @@ private: rb.Push(ResultSuccess); } - void Get(Kernel::HLERequestContext& ctx) { + void Get(HLERequestContext& ctx) { LOG_DEBUG(Service_MM, "(STUBBED) called"); IPC::ResponseBuilder rb{ctx, 3}; diff --git a/src/core/hle/service/mnpp/mnpp_app.cpp b/src/core/hle/service/mnpp/mnpp_app.cpp index 4ce4672b7..b11a92056 100644 --- a/src/core/hle/service/mnpp/mnpp_app.cpp +++ b/src/core/hle/service/mnpp/mnpp_app.cpp @@ -2,7 +2,7 @@ // SPDX-License-Identifier: GPL-2.0-or-later #include "common/logging/log.h" -#include "core/hle/ipc_helpers.h" +#include "core/hle/service/ipc_helpers.h" #include "core/hle/service/mnpp/mnpp_app.h" #include "core/hle/service/server_manager.h" #include "core/hle/service/service.h" @@ -23,14 +23,14 @@ public: } private: - void Unknown0(Kernel::HLERequestContext& ctx) { + void Unknown0(HLERequestContext& ctx) { LOG_WARNING(Service_MNPP, "(STUBBED) called"); IPC::ResponseBuilder rb{ctx, 2}; rb.Push(ResultSuccess); } - void Unknown1(Kernel::HLERequestContext& ctx) { + void Unknown1(HLERequestContext& ctx) { LOG_WARNING(Service_MNPP, "(STUBBED) called"); IPC::ResponseBuilder rb{ctx, 2}; diff --git a/src/core/hle/service/ncm/ncm.cpp b/src/core/hle/service/ncm/ncm.cpp index 5ab24dc34..650666d6b 100644 --- a/src/core/hle/service/ncm/ncm.cpp +++ b/src/core/hle/service/ncm/ncm.cpp @@ -4,7 +4,7 @@ #include <memory> #include "core/file_sys/romfs_factory.h" -#include "core/hle/ipc_helpers.h" +#include "core/hle/service/ipc_helpers.h" #include "core/hle/service/ncm/ncm.h" #include "core/hle/service/server_manager.h" #include "core/hle/service/service.h" diff --git a/src/core/hle/service/nfc/mifare_user.cpp b/src/core/hle/service/nfc/mifare_user.cpp index 51523a3ae..e0bbd46e1 100644 --- a/src/core/hle/service/nfc/mifare_user.cpp +++ b/src/core/hle/service/nfc/mifare_user.cpp @@ -4,8 +4,8 @@ #include "common/logging/log.h" #include "core/core.h" #include "core/hid/hid_types.h" -#include "core/hle/ipc_helpers.h" #include "core/hle/kernel/k_event.h" +#include "core/hle/service/ipc_helpers.h" #include "core/hle/service/nfc/mifare_user.h" #include "core/hle/service/nfc/nfc_device.h" #include "core/hle/service/nfc/nfc_result.h" @@ -45,7 +45,7 @@ MFIUser ::~MFIUser() { availability_change_event->Close(); } -void MFIUser::Initialize(Kernel::HLERequestContext& ctx) { +void MFIUser::Initialize(HLERequestContext& ctx) { LOG_INFO(Service_NFC, "called"); state = State::Initialized; @@ -58,7 +58,7 @@ void MFIUser::Initialize(Kernel::HLERequestContext& ctx) { rb.Push(ResultSuccess); } -void MFIUser::Finalize(Kernel::HLERequestContext& ctx) { +void MFIUser::Finalize(HLERequestContext& ctx) { LOG_INFO(Service_NFC, "called"); state = State::NonInitialized; @@ -71,7 +71,7 @@ void MFIUser::Finalize(Kernel::HLERequestContext& ctx) { rb.Push(ResultSuccess); } -void MFIUser::ListDevices(Kernel::HLERequestContext& ctx) { +void MFIUser::ListDevices(HLERequestContext& ctx) { LOG_DEBUG(Service_NFC, "called"); if (state == State::NonInitialized) { @@ -117,7 +117,7 @@ void MFIUser::ListDevices(Kernel::HLERequestContext& ctx) { rb.Push(static_cast<s32>(nfp_devices.size())); } -void MFIUser::StartDetection(Kernel::HLERequestContext& ctx) { +void MFIUser::StartDetection(HLERequestContext& ctx) { IPC::RequestParser rp{ctx}; const auto device_handle{rp.Pop<u64>()}; LOG_INFO(Service_NFC, "called, device_handle={}", device_handle); @@ -141,7 +141,7 @@ void MFIUser::StartDetection(Kernel::HLERequestContext& ctx) { rb.Push(result); } -void MFIUser::StopDetection(Kernel::HLERequestContext& ctx) { +void MFIUser::StopDetection(HLERequestContext& ctx) { IPC::RequestParser rp{ctx}; const auto device_handle{rp.Pop<u64>()}; LOG_INFO(Service_NFC, "called, device_handle={}", device_handle); @@ -165,7 +165,7 @@ void MFIUser::StopDetection(Kernel::HLERequestContext& ctx) { rb.Push(result); } -void MFIUser::Read(Kernel::HLERequestContext& ctx) { +void MFIUser::Read(HLERequestContext& ctx) { IPC::RequestParser rp{ctx}; const auto device_handle{rp.Pop<u64>()}; const auto buffer{ctx.ReadBuffer()}; @@ -206,7 +206,7 @@ void MFIUser::Read(Kernel::HLERequestContext& ctx) { rb.Push(result); } -void MFIUser::Write(Kernel::HLERequestContext& ctx) { +void MFIUser::Write(HLERequestContext& ctx) { IPC::RequestParser rp{ctx}; const auto device_handle{rp.Pop<u64>()}; const auto buffer{ctx.ReadBuffer()}; @@ -250,7 +250,7 @@ void MFIUser::Write(Kernel::HLERequestContext& ctx) { rb.Push(result); } -void MFIUser::GetTagInfo(Kernel::HLERequestContext& ctx) { +void MFIUser::GetTagInfo(HLERequestContext& ctx) { IPC::RequestParser rp{ctx}; const auto device_handle{rp.Pop<u64>()}; LOG_INFO(Service_NFC, "called, device_handle={}", device_handle); @@ -276,7 +276,7 @@ void MFIUser::GetTagInfo(Kernel::HLERequestContext& ctx) { rb.Push(result); } -void MFIUser::GetActivateEventHandle(Kernel::HLERequestContext& ctx) { +void MFIUser::GetActivateEventHandle(HLERequestContext& ctx) { IPC::RequestParser rp{ctx}; const auto device_handle{rp.Pop<u64>()}; LOG_DEBUG(Service_NFC, "called, device_handle={}", device_handle); @@ -300,7 +300,7 @@ void MFIUser::GetActivateEventHandle(Kernel::HLERequestContext& ctx) { rb.PushCopyObjects(device.value()->GetActivateEvent()); } -void MFIUser::GetDeactivateEventHandle(Kernel::HLERequestContext& ctx) { +void MFIUser::GetDeactivateEventHandle(HLERequestContext& ctx) { IPC::RequestParser rp{ctx}; const auto device_handle{rp.Pop<u64>()}; LOG_DEBUG(Service_NFC, "called, device_handle={}", device_handle); @@ -324,7 +324,7 @@ void MFIUser::GetDeactivateEventHandle(Kernel::HLERequestContext& ctx) { rb.PushCopyObjects(device.value()->GetDeactivateEvent()); } -void MFIUser::GetState(Kernel::HLERequestContext& ctx) { +void MFIUser::GetState(HLERequestContext& ctx) { LOG_DEBUG(Service_NFC, "called"); IPC::ResponseBuilder rb{ctx, 3}; @@ -332,7 +332,7 @@ void MFIUser::GetState(Kernel::HLERequestContext& ctx) { rb.PushEnum(state); } -void MFIUser::GetDeviceState(Kernel::HLERequestContext& ctx) { +void MFIUser::GetDeviceState(HLERequestContext& ctx) { IPC::RequestParser rp{ctx}; const auto device_handle{rp.Pop<u64>()}; LOG_DEBUG(Service_NFC, "called, device_handle={}", device_handle); @@ -350,7 +350,7 @@ void MFIUser::GetDeviceState(Kernel::HLERequestContext& ctx) { rb.PushEnum(device.value()->GetCurrentState()); } -void MFIUser::GetNpadId(Kernel::HLERequestContext& ctx) { +void MFIUser::GetNpadId(HLERequestContext& ctx) { IPC::RequestParser rp{ctx}; const auto device_handle{rp.Pop<u64>()}; LOG_DEBUG(Service_NFC, "called, device_handle={}", device_handle); @@ -374,7 +374,7 @@ void MFIUser::GetNpadId(Kernel::HLERequestContext& ctx) { rb.PushEnum(device.value()->GetNpadId()); } -void MFIUser::GetAvailabilityChangeEventHandle(Kernel::HLERequestContext& ctx) { +void MFIUser::GetAvailabilityChangeEventHandle(HLERequestContext& ctx) { LOG_INFO(Service_NFC, "called"); if (state == State::NonInitialized) { diff --git a/src/core/hle/service/nfc/mifare_user.h b/src/core/hle/service/nfc/mifare_user.h index 0e0638cb6..9701f1d7f 100644 --- a/src/core/hle/service/nfc/mifare_user.h +++ b/src/core/hle/service/nfc/mifare_user.h @@ -24,20 +24,20 @@ private: Initialized, }; - void Initialize(Kernel::HLERequestContext& ctx); - void Finalize(Kernel::HLERequestContext& ctx); - void ListDevices(Kernel::HLERequestContext& ctx); - void StartDetection(Kernel::HLERequestContext& ctx); - void StopDetection(Kernel::HLERequestContext& ctx); - void Read(Kernel::HLERequestContext& ctx); - void Write(Kernel::HLERequestContext& ctx); - void GetTagInfo(Kernel::HLERequestContext& ctx); - void GetActivateEventHandle(Kernel::HLERequestContext& ctx); - void GetDeactivateEventHandle(Kernel::HLERequestContext& ctx); - void GetState(Kernel::HLERequestContext& ctx); - void GetDeviceState(Kernel::HLERequestContext& ctx); - void GetNpadId(Kernel::HLERequestContext& ctx); - void GetAvailabilityChangeEventHandle(Kernel::HLERequestContext& ctx); + void Initialize(HLERequestContext& ctx); + void Finalize(HLERequestContext& ctx); + void ListDevices(HLERequestContext& ctx); + void StartDetection(HLERequestContext& ctx); + void StopDetection(HLERequestContext& ctx); + void Read(HLERequestContext& ctx); + void Write(HLERequestContext& ctx); + void GetTagInfo(HLERequestContext& ctx); + void GetActivateEventHandle(HLERequestContext& ctx); + void GetDeactivateEventHandle(HLERequestContext& ctx); + void GetState(HLERequestContext& ctx); + void GetDeviceState(HLERequestContext& ctx); + void GetNpadId(HLERequestContext& ctx); + void GetAvailabilityChangeEventHandle(HLERequestContext& ctx); std::optional<std::shared_ptr<NfcDevice>> GetNfcDevice(u64 handle); diff --git a/src/core/hle/service/nfc/nfc.cpp b/src/core/hle/service/nfc/nfc.cpp index 34612b9df..6595e34ed 100644 --- a/src/core/hle/service/nfc/nfc.cpp +++ b/src/core/hle/service/nfc/nfc.cpp @@ -5,7 +5,7 @@ #include "common/logging/log.h" #include "common/settings.h" -#include "core/hle/ipc_helpers.h" +#include "core/hle/service/ipc_helpers.h" #include "core/hle/service/nfc/mifare_user.h" #include "core/hle/service/nfc/nfc.h" #include "core/hle/service/nfc/nfc_user.h" @@ -42,7 +42,7 @@ public: } private: - void CreateAmInterface(Kernel::HLERequestContext& ctx) { + void CreateAmInterface(HLERequestContext& ctx) { LOG_DEBUG(Service_NFC, "called"); IPC::ResponseBuilder rb{ctx, 2, 0, 1}; @@ -64,7 +64,7 @@ public: } private: - void CreateUserInterface(Kernel::HLERequestContext& ctx) { + void CreateUserInterface(HLERequestContext& ctx) { LOG_DEBUG(Service_NFC, "called"); IPC::ResponseBuilder rb{ctx, 2, 0, 1}; @@ -86,7 +86,7 @@ public: } private: - void CreateUserInterface(Kernel::HLERequestContext& ctx) { + void CreateUserInterface(HLERequestContext& ctx) { LOG_DEBUG(Service_NFC, "called"); IPC::ResponseBuilder rb{ctx, 2, 0, 1}; @@ -145,7 +145,7 @@ public: } private: - void CreateSystemInterface(Kernel::HLERequestContext& ctx) { + void CreateSystemInterface(HLERequestContext& ctx) { LOG_DEBUG(Service_NFC, "called"); IPC::ResponseBuilder rb{ctx, 2, 0, 1}; diff --git a/src/core/hle/service/nfc/nfc_device.cpp b/src/core/hle/service/nfc/nfc_device.cpp index 9a3234e8c..3f17d0c7a 100644 --- a/src/core/hle/service/nfc/nfc_device.cpp +++ b/src/core/hle/service/nfc/nfc_device.cpp @@ -7,8 +7,8 @@ #include "core/hid/emulated_controller.h" #include "core/hid/hid_core.h" #include "core/hid/hid_types.h" -#include "core/hle/ipc_helpers.h" #include "core/hle/kernel/k_event.h" +#include "core/hle/service/ipc_helpers.h" #include "core/hle/service/nfc/nfc_device.h" #include "core/hle/service/nfc/nfc_result.h" #include "core/hle/service/nfc/nfc_user.h" diff --git a/src/core/hle/service/nfc/nfc_user.cpp b/src/core/hle/service/nfc/nfc_user.cpp index 89aa6b3f5..7c162a4f3 100644 --- a/src/core/hle/service/nfc/nfc_user.cpp +++ b/src/core/hle/service/nfc/nfc_user.cpp @@ -4,8 +4,8 @@ #include "common/logging/log.h" #include "core/core.h" #include "core/hid/hid_types.h" -#include "core/hle/ipc_helpers.h" #include "core/hle/kernel/k_event.h" +#include "core/hle/service/ipc_helpers.h" #include "core/hle/service/nfc/nfc_device.h" #include "core/hle/service/nfc/nfc_result.h" #include "core/hle/service/nfc/nfc_user.h" @@ -54,7 +54,7 @@ IUser ::~IUser() { availability_change_event->Close(); } -void IUser::Initialize(Kernel::HLERequestContext& ctx) { +void IUser::Initialize(HLERequestContext& ctx) { LOG_INFO(Service_NFC, "called"); state = State::Initialized; @@ -67,7 +67,7 @@ void IUser::Initialize(Kernel::HLERequestContext& ctx) { rb.Push(ResultSuccess); } -void IUser::Finalize(Kernel::HLERequestContext& ctx) { +void IUser::Finalize(HLERequestContext& ctx) { LOG_INFO(Service_NFC, "called"); state = State::NonInitialized; @@ -80,7 +80,7 @@ void IUser::Finalize(Kernel::HLERequestContext& ctx) { rb.Push(ResultSuccess); } -void IUser::GetState(Kernel::HLERequestContext& ctx) { +void IUser::GetState(HLERequestContext& ctx) { LOG_DEBUG(Service_NFC, "called"); IPC::ResponseBuilder rb{ctx, 3}; @@ -88,7 +88,7 @@ void IUser::GetState(Kernel::HLERequestContext& ctx) { rb.PushEnum(state); } -void IUser::IsNfcEnabled(Kernel::HLERequestContext& ctx) { +void IUser::IsNfcEnabled(HLERequestContext& ctx) { LOG_DEBUG(Service_NFC, "called"); IPC::ResponseBuilder rb{ctx, 3}; @@ -96,7 +96,7 @@ void IUser::IsNfcEnabled(Kernel::HLERequestContext& ctx) { rb.Push(state != State::NonInitialized); } -void IUser::ListDevices(Kernel::HLERequestContext& ctx) { +void IUser::ListDevices(HLERequestContext& ctx) { LOG_DEBUG(Service_NFC, "called"); if (state == State::NonInitialized) { @@ -142,7 +142,7 @@ void IUser::ListDevices(Kernel::HLERequestContext& ctx) { rb.Push(static_cast<s32>(nfp_devices.size())); } -void IUser::GetDeviceState(Kernel::HLERequestContext& ctx) { +void IUser::GetDeviceState(HLERequestContext& ctx) { IPC::RequestParser rp{ctx}; const auto device_handle{rp.Pop<u64>()}; LOG_DEBUG(Service_NFC, "called, device_handle={}", device_handle); @@ -160,7 +160,7 @@ void IUser::GetDeviceState(Kernel::HLERequestContext& ctx) { rb.PushEnum(device.value()->GetCurrentState()); } -void IUser::GetNpadId(Kernel::HLERequestContext& ctx) { +void IUser::GetNpadId(HLERequestContext& ctx) { IPC::RequestParser rp{ctx}; const auto device_handle{rp.Pop<u64>()}; LOG_DEBUG(Service_NFC, "called, device_handle={}", device_handle); @@ -184,7 +184,7 @@ void IUser::GetNpadId(Kernel::HLERequestContext& ctx) { rb.PushEnum(device.value()->GetNpadId()); } -void IUser::AttachAvailabilityChangeEvent(Kernel::HLERequestContext& ctx) { +void IUser::AttachAvailabilityChangeEvent(HLERequestContext& ctx) { LOG_INFO(Service_NFC, "called"); if (state == State::NonInitialized) { @@ -198,7 +198,7 @@ void IUser::AttachAvailabilityChangeEvent(Kernel::HLERequestContext& ctx) { rb.PushCopyObjects(availability_change_event->GetReadableEvent()); } -void IUser::StartDetection(Kernel::HLERequestContext& ctx) { +void IUser::StartDetection(HLERequestContext& ctx) { IPC::RequestParser rp{ctx}; const auto device_handle{rp.Pop<u64>()}; const auto nfp_protocol{rp.PopEnum<NFP::TagProtocol>()}; @@ -223,7 +223,7 @@ void IUser::StartDetection(Kernel::HLERequestContext& ctx) { rb.Push(result); } -void IUser::StopDetection(Kernel::HLERequestContext& ctx) { +void IUser::StopDetection(HLERequestContext& ctx) { IPC::RequestParser rp{ctx}; const auto device_handle{rp.Pop<u64>()}; LOG_INFO(Service_NFC, "called, device_handle={}", device_handle); @@ -247,7 +247,7 @@ void IUser::StopDetection(Kernel::HLERequestContext& ctx) { rb.Push(result); } -void IUser::GetTagInfo(Kernel::HLERequestContext& ctx) { +void IUser::GetTagInfo(HLERequestContext& ctx) { IPC::RequestParser rp{ctx}; const auto device_handle{rp.Pop<u64>()}; LOG_INFO(Service_NFC, "called, device_handle={}", device_handle); @@ -273,7 +273,7 @@ void IUser::GetTagInfo(Kernel::HLERequestContext& ctx) { rb.Push(result); } -void IUser::AttachActivateEvent(Kernel::HLERequestContext& ctx) { +void IUser::AttachActivateEvent(HLERequestContext& ctx) { IPC::RequestParser rp{ctx}; const auto device_handle{rp.Pop<u64>()}; LOG_DEBUG(Service_NFC, "called, device_handle={}", device_handle); @@ -297,7 +297,7 @@ void IUser::AttachActivateEvent(Kernel::HLERequestContext& ctx) { rb.PushCopyObjects(device.value()->GetActivateEvent()); } -void IUser::AttachDeactivateEvent(Kernel::HLERequestContext& ctx) { +void IUser::AttachDeactivateEvent(HLERequestContext& ctx) { IPC::RequestParser rp{ctx}; const auto device_handle{rp.Pop<u64>()}; LOG_DEBUG(Service_NFC, "called, device_handle={}", device_handle); @@ -321,7 +321,7 @@ void IUser::AttachDeactivateEvent(Kernel::HLERequestContext& ctx) { rb.PushCopyObjects(device.value()->GetDeactivateEvent()); } -void IUser::SendCommandByPassThrough(Kernel::HLERequestContext& ctx) { +void IUser::SendCommandByPassThrough(HLERequestContext& ctx) { IPC::RequestParser rp{ctx}; const auto device_handle{rp.Pop<u64>()}; const auto timeout{rp.PopRaw<Time::Clock::TimeSpanType>()}; diff --git a/src/core/hle/service/nfc/nfc_user.h b/src/core/hle/service/nfc/nfc_user.h index a5a4f12f9..aee046ae8 100644 --- a/src/core/hle/service/nfc/nfc_user.h +++ b/src/core/hle/service/nfc/nfc_user.h @@ -24,20 +24,20 @@ private: Initialized, }; - void Initialize(Kernel::HLERequestContext& ctx); - void Finalize(Kernel::HLERequestContext& ctx); - void GetState(Kernel::HLERequestContext& ctx); - void IsNfcEnabled(Kernel::HLERequestContext& ctx); - void ListDevices(Kernel::HLERequestContext& ctx); - void GetDeviceState(Kernel::HLERequestContext& ctx); - void GetNpadId(Kernel::HLERequestContext& ctx); - void AttachAvailabilityChangeEvent(Kernel::HLERequestContext& ctx); - void StartDetection(Kernel::HLERequestContext& ctx); - void StopDetection(Kernel::HLERequestContext& ctx); - void GetTagInfo(Kernel::HLERequestContext& ctx); - void AttachActivateEvent(Kernel::HLERequestContext& ctx); - void AttachDeactivateEvent(Kernel::HLERequestContext& ctx); - void SendCommandByPassThrough(Kernel::HLERequestContext& ctx); + void Initialize(HLERequestContext& ctx); + void Finalize(HLERequestContext& ctx); + void GetState(HLERequestContext& ctx); + void IsNfcEnabled(HLERequestContext& ctx); + void ListDevices(HLERequestContext& ctx); + void GetDeviceState(HLERequestContext& ctx); + void GetNpadId(HLERequestContext& ctx); + void AttachAvailabilityChangeEvent(HLERequestContext& ctx); + void StartDetection(HLERequestContext& ctx); + void StopDetection(HLERequestContext& ctx); + void GetTagInfo(HLERequestContext& ctx); + void AttachActivateEvent(HLERequestContext& ctx); + void AttachDeactivateEvent(HLERequestContext& ctx); + void SendCommandByPassThrough(HLERequestContext& ctx); std::optional<std::shared_ptr<NfcDevice>> GetNfcDevice(u64 handle); diff --git a/src/core/hle/service/nfp/amiibo_crypto.cpp b/src/core/hle/service/nfp/amiibo_crypto.cpp index ffb2f959c..bba862fb2 100644 --- a/src/core/hle/service/nfp/amiibo_crypto.cpp +++ b/src/core/hle/service/nfp/amiibo_crypto.cpp @@ -80,13 +80,17 @@ NTAG215File NfcDataToEncodedData(const EncryptedNTAG215File& nfc_data) { encoded_data.hmac_data = nfc_data.user_memory.hmac_data; encoded_data.constant_value = nfc_data.user_memory.constant_value; encoded_data.write_counter = nfc_data.user_memory.write_counter; + encoded_data.amiibo_version = nfc_data.user_memory.amiibo_version; encoded_data.settings = nfc_data.user_memory.settings; encoded_data.owner_mii = nfc_data.user_memory.owner_mii; - encoded_data.title_id = nfc_data.user_memory.title_id; - encoded_data.applicaton_write_counter = nfc_data.user_memory.applicaton_write_counter; + encoded_data.application_id = nfc_data.user_memory.application_id; + encoded_data.application_write_counter = nfc_data.user_memory.application_write_counter; encoded_data.application_area_id = nfc_data.user_memory.application_area_id; + encoded_data.application_id_byte = nfc_data.user_memory.application_id_byte; encoded_data.unknown = nfc_data.user_memory.unknown; + encoded_data.mii_extension = nfc_data.user_memory.mii_extension; encoded_data.unknown2 = nfc_data.user_memory.unknown2; + encoded_data.register_info_crc = nfc_data.user_memory.register_info_crc; encoded_data.application_area = nfc_data.user_memory.application_area; encoded_data.hmac_tag = nfc_data.user_memory.hmac_tag; encoded_data.lock_bytes = nfc_data.uuid.lock_bytes; @@ -111,13 +115,17 @@ EncryptedNTAG215File EncodedDataToNfcData(const NTAG215File& encoded_data) { nfc_data.user_memory.hmac_data = encoded_data.hmac_data; nfc_data.user_memory.constant_value = encoded_data.constant_value; nfc_data.user_memory.write_counter = encoded_data.write_counter; + nfc_data.user_memory.amiibo_version = encoded_data.amiibo_version; nfc_data.user_memory.settings = encoded_data.settings; nfc_data.user_memory.owner_mii = encoded_data.owner_mii; - nfc_data.user_memory.title_id = encoded_data.title_id; - nfc_data.user_memory.applicaton_write_counter = encoded_data.applicaton_write_counter; + nfc_data.user_memory.application_id = encoded_data.application_id; + nfc_data.user_memory.application_write_counter = encoded_data.application_write_counter; nfc_data.user_memory.application_area_id = encoded_data.application_area_id; + nfc_data.user_memory.application_id_byte = encoded_data.application_id_byte; nfc_data.user_memory.unknown = encoded_data.unknown; + nfc_data.user_memory.mii_extension = encoded_data.mii_extension; nfc_data.user_memory.unknown2 = encoded_data.unknown2; + nfc_data.user_memory.register_info_crc = encoded_data.register_info_crc; nfc_data.user_memory.application_area = encoded_data.application_area; nfc_data.user_memory.hmac_tag = encoded_data.hmac_tag; nfc_data.user_memory.model_info = encoded_data.model_info; @@ -131,7 +139,7 @@ EncryptedNTAG215File EncodedDataToNfcData(const NTAG215File& encoded_data) { } u32 GetTagPassword(const TagUuid& uuid) { - // Verifiy that the generated password is correct + // Verify that the generated password is correct u32 password = 0xAA ^ (uuid.uid[1] ^ uuid.uid[3]); password &= (0x55 ^ (uuid.uid[2] ^ uuid.uid[4])) << 8; password &= (0xAA ^ (uuid.uid[3] ^ uuid.uid[5])) << 16; diff --git a/src/core/hle/service/nfp/amiibo_crypto.h b/src/core/hle/service/nfp/amiibo_crypto.h index 1fa61174e..c9fd67a39 100644 --- a/src/core/hle/service/nfp/amiibo_crypto.h +++ b/src/core/hle/service/nfp/amiibo_crypto.h @@ -94,7 +94,7 @@ bool LoadKeys(InternalKey& locked_secret, InternalKey& unfixed_info); /// Returns true if key_retail.bin exist bool IsKeyAvailable(); -/// Decodes encripted amiibo data returns true if output is valid +/// Decodes encrypted amiibo data returns true if output is valid bool DecodeAmiibo(const EncryptedNTAG215File& encrypted_tag_data, NTAG215File& tag_data); /// Encodes plain amiibo data returns true if output is valid diff --git a/src/core/hle/service/nfp/nfp.cpp b/src/core/hle/service/nfp/nfp.cpp index 1b59aba8e..e262dc2f2 100644 --- a/src/core/hle/service/nfp/nfp.cpp +++ b/src/core/hle/service/nfp/nfp.cpp @@ -2,7 +2,7 @@ // SPDX-License-Identifier: GPL-2.0-or-later #include "common/logging/log.h" -#include "core/hle/ipc_helpers.h" +#include "core/hle/service/ipc_helpers.h" #include "core/hle/service/nfp/nfp.h" #include "core/hle/service/nfp/nfp_user.h" #include "core/hle/service/server_manager.h" @@ -22,7 +22,7 @@ public: } private: - void CreateUserInterface(Kernel::HLERequestContext& ctx) { + void CreateUserInterface(HLERequestContext& ctx) { LOG_DEBUG(Service_NFP, "called"); if (user_interface == nullptr) { diff --git a/src/core/hle/service/nfp/nfp_device.cpp b/src/core/hle/service/nfp/nfp_device.cpp index 7a6bbbba7..268337d2e 100644 --- a/src/core/hle/service/nfp/nfp_device.cpp +++ b/src/core/hle/service/nfp/nfp_device.cpp @@ -3,6 +3,17 @@ #include <array> +#ifdef _MSC_VER +#pragma warning(push) +#pragma warning(disable : 4701) // Potentially uninitialized local variable 'result' used +#endif + +#include <boost/crc.hpp> + +#ifdef _MSC_VER +#pragma warning(pop) +#endif + #include "common/input.h" #include "common/logging/log.h" #include "common/string_util.h" @@ -11,8 +22,8 @@ #include "core/hid/emulated_controller.h" #include "core/hid/hid_core.h" #include "core/hid/hid_types.h" -#include "core/hle/ipc_helpers.h" #include "core/hle/kernel/k_event.h" +#include "core/hle/service/ipc_helpers.h" #include "core/hle/service/mii/mii_manager.h" #include "core/hle/service/mii/types.h" #include "core/hle/service/nfp/amiibo_crypto.h" @@ -174,8 +185,8 @@ Result NfpDevice::StopDetection() { if (device_state == DeviceState::TagFound || device_state == DeviceState::TagMounted) { CloseAmiibo(); - return ResultSuccess; } + if (device_state == DeviceState::SearchingForTag || device_state == DeviceState::TagRemoved) { device_state = DeviceState::Initialized; return ResultSuccess; @@ -204,9 +215,7 @@ Result NfpDevice::Flush() { const auto& current_date = GetAmiiboDate(current_posix_time); if (settings.write_date.raw_date != current_date.raw_date) { settings.write_date = current_date; - settings.crc_counter++; - // TODO: Find how to calculate the crc check - // settings.crc = CalculateCRC(settings); + UpdateSettingsCrc(); } tag_data.write_counter++; @@ -318,7 +327,7 @@ Result NfpDevice::GetCommonInfo(CommonInfo& common_info) const { common_info = { .last_write_date = settings.write_date.GetWriteDate(), .write_counter = tag_data.write_counter, - .version = 0, + .version = tag_data.amiibo_version, .application_area_size = sizeof(ApplicationArea), }; return ResultSuccess; @@ -370,13 +379,95 @@ Result NfpDevice::GetRegisterInfo(RegisterInfo& register_info) const { .mii_char_info = manager.ConvertV3ToCharInfo(tag_data.owner_mii), .creation_date = settings.init_date.GetWriteDate(), .amiibo_name = GetAmiiboName(settings), - .font_region = {}, + .font_region = settings.settings.font_region, }; return ResultSuccess; } -Result NfpDevice::SetNicknameAndOwner(const AmiiboName& amiibo_name) { +Result NfpDevice::GetAdminInfo(AdminInfo& admin_info) const { + if (device_state != DeviceState::TagMounted) { + LOG_ERROR(Service_NFC, "Wrong device state {}", device_state); + if (device_state == DeviceState::TagRemoved) { + return TagRemoved; + } + return WrongDeviceState; + } + + if (mount_target == MountTarget::None || mount_target == MountTarget::Rom) { + LOG_ERROR(Service_NFC, "Amiibo is read only", device_state); + return WrongDeviceState; + } + + u8 flags = static_cast<u8>(tag_data.settings.settings.raw >> 0x4); + if (tag_data.settings.settings.amiibo_initialized == 0) { + flags = flags & 0xfe; + } + + u64 application_id = 0; + u32 application_area_id = 0; + AppAreaVersion app_area_version = AppAreaVersion::NotSet; + if (tag_data.settings.settings.appdata_initialized != 0) { + application_id = tag_data.application_id; + app_area_version = + static_cast<AppAreaVersion>(application_id >> application_id_version_offset & 0xf); + + // Restore application id to original value + if (application_id >> 0x38 != 0) { + const u8 application_byte = tag_data.application_id_byte & 0xf; + application_id = RemoveVersionByte(application_id) | + (static_cast<u64>(application_byte) << application_id_version_offset); + } + + application_area_id = tag_data.application_area_id; + } + + // TODO: Validate this data + admin_info = { + .application_id = application_id, + .application_area_id = application_area_id, + .crc_change_counter = tag_data.settings.crc_counter, + .flags = flags, + .tag_type = PackedTagType::Type2, + .app_area_version = app_area_version, + }; + + return ResultSuccess; +} + +Result NfpDevice::DeleteRegisterInfo() { + if (device_state != DeviceState::TagMounted) { + LOG_ERROR(Service_NFC, "Wrong device state {}", device_state); + if (device_state == DeviceState::TagRemoved) { + return TagRemoved; + } + return WrongDeviceState; + } + + if (mount_target == MountTarget::None || mount_target == MountTarget::Rom) { + LOG_ERROR(Service_NFC, "Amiibo is read only", device_state); + return WrongDeviceState; + } + + if (tag_data.settings.settings.amiibo_initialized == 0) { + return RegistrationIsNotInitialized; + } + + Common::TinyMT rng{}; + rng.GenerateRandomBytes(&tag_data.owner_mii, sizeof(tag_data.owner_mii)); + rng.GenerateRandomBytes(&tag_data.settings.amiibo_name, sizeof(tag_data.settings.amiibo_name)); + rng.GenerateRandomBytes(&tag_data.unknown, sizeof(u8)); + rng.GenerateRandomBytes(&tag_data.unknown2[0], sizeof(u32)); + rng.GenerateRandomBytes(&tag_data.unknown2[1], sizeof(u32)); + rng.GenerateRandomBytes(&tag_data.register_info_crc, sizeof(u32)); + rng.GenerateRandomBytes(&tag_data.settings.init_date, sizeof(u32)); + tag_data.settings.settings.font_region.Assign(0); + tag_data.settings.settings.amiibo_initialized.Assign(0); + + return Flush(); +} + +Result NfpDevice::SetRegisterInfoPrivate(const AmiiboName& amiibo_name) { if (device_state != DeviceState::TagMounted) { LOG_ERROR(Service_NFP, "Wrong device state {}", device_state); if (device_state == DeviceState::TagRemoved) { @@ -391,18 +482,25 @@ Result NfpDevice::SetNicknameAndOwner(const AmiiboName& amiibo_name) { } Service::Mii::MiiManager manager; + const auto mii = manager.BuildDefault(0); auto& settings = tag_data.settings; - settings.init_date = GetAmiiboDate(current_posix_time); - settings.write_date = GetAmiiboDate(current_posix_time); - settings.crc_counter++; - // TODO: Find how to calculate the crc check - // settings.crc = CalculateCRC(settings); + if (tag_data.settings.settings.amiibo_initialized == 0) { + settings.init_date = GetAmiiboDate(current_posix_time); + settings.write_date.raw_date = 0; + } SetAmiiboName(settings, amiibo_name); - tag_data.owner_mii = manager.ConvertCharInfoToV3(manager.BuildDefault(0)); + tag_data.owner_mii = manager.BuildFromStoreData(mii); + tag_data.mii_extension = manager.SetFromStoreData(mii); + tag_data.unknown = 0; + tag_data.unknown2 = {}; + settings.country_code_id = 0; + settings.settings.font_region.Assign(0); settings.settings.amiibo_initialized.Assign(1); + UpdateRegisterInfoCrc(); + return Flush(); } @@ -425,23 +523,17 @@ Result NfpDevice::RestoreAmiibo() { return ResultSuccess; } -Result NfpDevice::DeleteAllData() { - const auto result = DeleteApplicationArea(); - if (result.IsError()) { - return result; - } +Result NfpDevice::Format() { + auto result1 = DeleteApplicationArea(); + auto result2 = DeleteRegisterInfo(); - if (device_state != DeviceState::TagMounted) { - LOG_ERROR(Service_NFP, "Wrong device state {}", device_state); - if (device_state == DeviceState::TagRemoved) { - return TagRemoved; - } - return WrongDeviceState; + if (result1.IsError()) { + return result1; } - Common::TinyMT rng{}; - rng.GenerateRandomBytes(&tag_data.owner_mii, sizeof(tag_data.owner_mii)); - tag_data.settings.settings.amiibo_initialized.Assign(0); + if (result2.IsError()) { + return result2; + } return Flush(); } @@ -569,7 +661,10 @@ Result NfpDevice::SetApplicationArea(std::span<const u8> data) { rng.GenerateRandomBytes(tag_data.application_area.data() + data.size(), sizeof(ApplicationArea) - data.size()); - tag_data.applicaton_write_counter++; + if (tag_data.application_write_counter != counter_limit) { + tag_data.application_write_counter++; + } + is_data_moddified = true; return ResultSuccess; @@ -601,6 +696,11 @@ Result NfpDevice::RecreateApplicationArea(u32 access_id, std::span<const u8> dat return WrongDeviceState; } + if (is_app_area_open) { + LOG_ERROR(Service_NFP, "Application area is open"); + return WrongDeviceState; + } + if (mount_target == MountTarget::None || mount_target == MountTarget::Rom) { LOG_ERROR(Service_NFP, "Amiibo is read only", device_state); return WrongDeviceState; @@ -617,13 +717,23 @@ Result NfpDevice::RecreateApplicationArea(u32 access_id, std::span<const u8> dat rng.GenerateRandomBytes(tag_data.application_area.data() + data.size(), sizeof(ApplicationArea) - data.size()); - // TODO: Investigate why the title id needs to be moddified - tag_data.title_id = system.GetApplicationProcessProgramID(); - tag_data.title_id = tag_data.title_id | 0x30000000ULL; + if (tag_data.application_write_counter != counter_limit) { + tag_data.application_write_counter++; + } + + const u64 application_id = system.GetApplicationProcessProgramID(); + + tag_data.application_id_byte = + static_cast<u8>(application_id >> application_id_version_offset & 0xf); + tag_data.application_id = + RemoveVersionByte(application_id) | + (static_cast<u64>(AppAreaVersion::NintendoSwitch) << application_id_version_offset); tag_data.settings.settings.appdata_initialized.Assign(1); tag_data.application_area_id = access_id; - tag_data.applicaton_write_counter++; tag_data.unknown = {}; + tag_data.unknown2 = {}; + + UpdateRegisterInfoCrc(); return Flush(); } @@ -642,13 +752,25 @@ Result NfpDevice::DeleteApplicationArea() { return WrongDeviceState; } + if (tag_data.settings.settings.appdata_initialized == 0) { + return ApplicationAreaIsNotInitialized; + } + + if (tag_data.application_write_counter != counter_limit) { + tag_data.application_write_counter++; + } + Common::TinyMT rng{}; rng.GenerateRandomBytes(tag_data.application_area.data(), sizeof(ApplicationArea)); - rng.GenerateRandomBytes(&tag_data.title_id, sizeof(u64)); + rng.GenerateRandomBytes(&tag_data.application_id, sizeof(u64)); rng.GenerateRandomBytes(&tag_data.application_area_id, sizeof(u32)); + rng.GenerateRandomBytes(&tag_data.application_id_byte, sizeof(u8)); tag_data.settings.settings.appdata_initialized.Assign(0); - tag_data.applicaton_write_counter++; tag_data.unknown = {}; + tag_data.unknown2 = {}; + is_app_area_open = false; + + UpdateRegisterInfoCrc(); return Flush(); } @@ -719,4 +841,47 @@ AmiiboDate NfpDevice::GetAmiiboDate(s64 posix_time) const { return amiibo_date; } +u64 NfpDevice::RemoveVersionByte(u64 application_id) const { + return application_id & ~(0xfULL << application_id_version_offset); +} + +void NfpDevice::UpdateSettingsCrc() { + auto& settings = tag_data.settings; + + if (settings.crc_counter != counter_limit) { + settings.crc_counter++; + } + + // TODO: this reads data from a global, find what it is + std::array<u8, 8> unknown_input{}; + boost::crc_32_type crc; + crc.process_bytes(&unknown_input, sizeof(unknown_input)); + settings.crc = crc.checksum(); +} + +void NfpDevice::UpdateRegisterInfoCrc() { +#pragma pack(push, 1) + struct CrcData { + Mii::Ver3StoreData mii; + u8 application_id_byte; + u8 unknown; + Mii::NfpStoreDataExtension mii_extension; + std::array<u32, 0x5> unknown2; + }; + static_assert(sizeof(CrcData) == 0x7e, "CrcData is an invalid size"); +#pragma pack(pop) + + const CrcData crc_data{ + .mii = tag_data.owner_mii, + .application_id_byte = tag_data.application_id_byte, + .unknown = tag_data.unknown, + .mii_extension = tag_data.mii_extension, + .unknown2 = tag_data.unknown2, + }; + + boost::crc_32_type crc; + crc.process_bytes(&crc_data, sizeof(CrcData)); + tag_data.register_info_crc = crc.checksum(); +} + } // namespace Service::NFP diff --git a/src/core/hle/service/nfp/nfp_device.h b/src/core/hle/service/nfp/nfp_device.h index b6a46f2ac..8813df998 100644 --- a/src/core/hle/service/nfp/nfp_device.h +++ b/src/core/hle/service/nfp/nfp_device.h @@ -47,10 +47,12 @@ public: Result GetCommonInfo(CommonInfo& common_info) const; Result GetModelInfo(ModelInfo& model_info) const; Result GetRegisterInfo(RegisterInfo& register_info) const; + Result GetAdminInfo(AdminInfo& admin_info) const; - Result SetNicknameAndOwner(const AmiiboName& amiibo_name); + Result DeleteRegisterInfo(); + Result SetRegisterInfoPrivate(const AmiiboName& amiibo_name); Result RestoreAmiibo(); - Result DeleteAllData(); + Result Format(); Result OpenApplicationArea(u32 access_id); Result GetApplicationAreaId(u32& application_area_id) const; @@ -76,6 +78,9 @@ private: AmiiboName GetAmiiboName(const AmiiboSettings& settings) const; void SetAmiiboName(AmiiboSettings& settings, const AmiiboName& amiibo_name); AmiiboDate GetAmiiboDate(s64 posix_time) const; + u64 RemoveVersionByte(u64 application_id) const; + void UpdateSettingsCrc(); + void UpdateRegisterInfoCrc(); bool is_controller_set{}; int callback_key; diff --git a/src/core/hle/service/nfp/nfp_types.h b/src/core/hle/service/nfp/nfp_types.h index fc228c2b2..b3599a513 100644 --- a/src/core/hle/service/nfp/nfp_types.h +++ b/src/core/hle/service/nfp/nfp_types.h @@ -10,6 +10,8 @@ namespace Service::NFP { static constexpr std::size_t amiibo_name_length = 0xA; +static constexpr std::size_t application_id_version_offset = 0x1c; +static constexpr std::size_t counter_limit = 0xffff; enum class ServiceType : u32 { User, @@ -99,6 +101,14 @@ enum class TagProtocol : u32 { All = 0xFFFFFFFFU, }; +enum class AppAreaVersion : u8 { + Nintendo3DS = 0, + NintendoWiiU = 1, + Nintendo3DSv2 = 2, + NintendoSwitch = 3, + NotSet = 0xFF, +}; + enum class CabinetMode : u8 { StartNicknameAndOwnerSettings, StartGameDataEraser, @@ -197,6 +207,7 @@ struct Settings { union { u8 raw{}; + BitField<0, 4, u8> font_region; BitField<4, 1, u8> amiibo_initialized; BitField<5, 1, u8> appdata_initialized; }; @@ -236,18 +247,21 @@ static_assert(sizeof(NTAG215Password) == 0x8, "NTAG215Password is an invalid siz struct EncryptedAmiiboFile { u8 constant_value; // Must be A5 u16_be write_counter; // Number of times the amiibo has been written? - INSERT_PADDING_BYTES(0x1); // Unknown 1 + u8 amiibo_version; // Amiibo file version AmiiboSettings settings; // Encrypted amiibo settings HashData hmac_tag; // Hash AmiiboModelInfo model_info; // Encrypted amiibo model info HashData keygen_salt; // Salt HashData hmac_data; // Hash Service::Mii::Ver3StoreData owner_mii; // Encrypted Mii data - u64_be title_id; // Encrypted Game id - u16_be applicaton_write_counter; // Encrypted Counter + u64_be application_id; // Encrypted Game id + u16_be application_write_counter; // Encrypted Counter u32_be application_area_id; // Encrypted Game id - std::array<u8, 0x2> unknown; - std::array<u32, 0x8> unknown2; + u8 application_id_byte; + u8 unknown; + Service::Mii::NfpStoreDataExtension mii_extension; + std::array<u32, 0x5> unknown2; + u32_be register_info_crc; ApplicationArea application_area; // Encrypted Game data }; static_assert(sizeof(EncryptedAmiiboFile) == 0x1F8, "AmiiboFile is an invalid size"); @@ -259,14 +273,17 @@ struct NTAG215File { HashData hmac_data; // Hash u8 constant_value; // Must be A5 u16_be write_counter; // Number of times the amiibo has been written? - INSERT_PADDING_BYTES(0x1); // Unknown 1 + u8 amiibo_version; // Amiibo file version AmiiboSettings settings; - Service::Mii::Ver3StoreData owner_mii; // Encrypted Mii data - u64_be title_id; - u16_be applicaton_write_counter; // Encrypted Counter + Service::Mii::Ver3StoreData owner_mii; // Mii data + u64_be application_id; // Game id + u16_be application_write_counter; // Counter u32_be application_area_id; - std::array<u8, 0x2> unknown; - std::array<u32, 0x8> unknown2; + u8 application_id_byte; + u8 unknown; + Service::Mii::NfpStoreDataExtension mii_extension; + std::array<u32, 0x5> unknown2; + u32_be register_info_crc; ApplicationArea application_area; // Encrypted Game data HashData hmac_tag; // Hash UniqueSerialNumber uid; // Unique serial number @@ -336,6 +353,18 @@ struct RegisterInfo { }; static_assert(sizeof(RegisterInfo) == 0x100, "RegisterInfo is an invalid size"); +struct AdminInfo { + u64 application_id; + u32 application_area_id; + u16 crc_change_counter; + u8 flags; + PackedTagType tag_type; + AppAreaVersion app_area_version; + INSERT_PADDING_BYTES(0x7); + INSERT_PADDING_BYTES(0x28); +}; +static_assert(sizeof(AdminInfo) == 0x40, "AdminInfo is an invalid size"); + struct SectorKey { MifareCmd command; u8 unknown; // Usually 1 diff --git a/src/core/hle/service/nfp/nfp_user.cpp b/src/core/hle/service/nfp/nfp_user.cpp index a4d3d1bc7..4e8534113 100644 --- a/src/core/hle/service/nfp/nfp_user.cpp +++ b/src/core/hle/service/nfp/nfp_user.cpp @@ -4,8 +4,8 @@ #include "common/logging/log.h" #include "core/core.h" #include "core/hid/hid_types.h" -#include "core/hle/ipc_helpers.h" #include "core/hle/kernel/k_event.h" +#include "core/hle/service/ipc_helpers.h" #include "core/hle/service/nfp/nfp_device.h" #include "core/hle/service/nfp/nfp_result.h" #include "core/hle/service/nfp/nfp_user.h" @@ -56,7 +56,7 @@ IUser ::~IUser() { availability_change_event->Close(); } -void IUser::Initialize(Kernel::HLERequestContext& ctx) { +void IUser::Initialize(HLERequestContext& ctx) { LOG_INFO(Service_NFP, "called"); state = State::Initialized; @@ -69,7 +69,7 @@ void IUser::Initialize(Kernel::HLERequestContext& ctx) { rb.Push(ResultSuccess); } -void IUser::Finalize(Kernel::HLERequestContext& ctx) { +void IUser::Finalize(HLERequestContext& ctx) { LOG_INFO(Service_NFP, "called"); state = State::NonInitialized; @@ -82,7 +82,7 @@ void IUser::Finalize(Kernel::HLERequestContext& ctx) { rb.Push(ResultSuccess); } -void IUser::ListDevices(Kernel::HLERequestContext& ctx) { +void IUser::ListDevices(HLERequestContext& ctx) { LOG_DEBUG(Service_NFP, "called"); if (state == State::NonInitialized) { @@ -128,7 +128,7 @@ void IUser::ListDevices(Kernel::HLERequestContext& ctx) { rb.Push(static_cast<s32>(nfp_devices.size())); } -void IUser::StartDetection(Kernel::HLERequestContext& ctx) { +void IUser::StartDetection(HLERequestContext& ctx) { IPC::RequestParser rp{ctx}; const auto device_handle{rp.Pop<u64>()}; const auto nfp_protocol{rp.PopEnum<TagProtocol>()}; @@ -153,7 +153,7 @@ void IUser::StartDetection(Kernel::HLERequestContext& ctx) { rb.Push(result); } -void IUser::StopDetection(Kernel::HLERequestContext& ctx) { +void IUser::StopDetection(HLERequestContext& ctx) { IPC::RequestParser rp{ctx}; const auto device_handle{rp.Pop<u64>()}; LOG_INFO(Service_NFP, "called, device_handle={}", device_handle); @@ -177,7 +177,7 @@ void IUser::StopDetection(Kernel::HLERequestContext& ctx) { rb.Push(result); } -void IUser::Mount(Kernel::HLERequestContext& ctx) { +void IUser::Mount(HLERequestContext& ctx) { IPC::RequestParser rp{ctx}; const auto device_handle{rp.Pop<u64>()}; const auto model_type{rp.PopEnum<ModelType>()}; @@ -204,7 +204,7 @@ void IUser::Mount(Kernel::HLERequestContext& ctx) { rb.Push(result); } -void IUser::Unmount(Kernel::HLERequestContext& ctx) { +void IUser::Unmount(HLERequestContext& ctx) { IPC::RequestParser rp{ctx}; const auto device_handle{rp.Pop<u64>()}; LOG_INFO(Service_NFP, "called, device_handle={}", device_handle); @@ -228,7 +228,7 @@ void IUser::Unmount(Kernel::HLERequestContext& ctx) { rb.Push(result); } -void IUser::OpenApplicationArea(Kernel::HLERequestContext& ctx) { +void IUser::OpenApplicationArea(HLERequestContext& ctx) { IPC::RequestParser rp{ctx}; const auto device_handle{rp.Pop<u64>()}; const auto access_id{rp.Pop<u32>()}; @@ -253,7 +253,7 @@ void IUser::OpenApplicationArea(Kernel::HLERequestContext& ctx) { rb.Push(result); } -void IUser::GetApplicationArea(Kernel::HLERequestContext& ctx) { +void IUser::GetApplicationArea(HLERequestContext& ctx) { IPC::RequestParser rp{ctx}; const auto device_handle{rp.Pop<u64>()}; const auto data_size = ctx.GetWriteBufferSize(); @@ -287,7 +287,7 @@ void IUser::GetApplicationArea(Kernel::HLERequestContext& ctx) { rb.Push(static_cast<u32>(data_size)); } -void IUser::SetApplicationArea(Kernel::HLERequestContext& ctx) { +void IUser::SetApplicationArea(HLERequestContext& ctx) { IPC::RequestParser rp{ctx}; const auto device_handle{rp.Pop<u64>()}; const auto data{ctx.ReadBuffer()}; @@ -318,7 +318,7 @@ void IUser::SetApplicationArea(Kernel::HLERequestContext& ctx) { rb.Push(result); } -void IUser::Flush(Kernel::HLERequestContext& ctx) { +void IUser::Flush(HLERequestContext& ctx) { IPC::RequestParser rp{ctx}; const auto device_handle{rp.Pop<u64>()}; LOG_INFO(Service_NFP, "called, device_handle={}", device_handle); @@ -342,7 +342,7 @@ void IUser::Flush(Kernel::HLERequestContext& ctx) { rb.Push(result); } -void IUser::Restore(Kernel::HLERequestContext& ctx) { +void IUser::Restore(HLERequestContext& ctx) { IPC::RequestParser rp{ctx}; const auto device_handle{rp.Pop<u64>()}; LOG_WARNING(Service_NFP, "(STUBBED) called, device_handle={}", device_handle); @@ -366,7 +366,7 @@ void IUser::Restore(Kernel::HLERequestContext& ctx) { rb.Push(result); } -void IUser::CreateApplicationArea(Kernel::HLERequestContext& ctx) { +void IUser::CreateApplicationArea(HLERequestContext& ctx) { IPC::RequestParser rp{ctx}; const auto device_handle{rp.Pop<u64>()}; const auto access_id{rp.Pop<u32>()}; @@ -399,7 +399,7 @@ void IUser::CreateApplicationArea(Kernel::HLERequestContext& ctx) { rb.Push(result); } -void IUser::GetTagInfo(Kernel::HLERequestContext& ctx) { +void IUser::GetTagInfo(HLERequestContext& ctx) { IPC::RequestParser rp{ctx}; const auto device_handle{rp.Pop<u64>()}; LOG_INFO(Service_NFP, "called, device_handle={}", device_handle); @@ -425,7 +425,7 @@ void IUser::GetTagInfo(Kernel::HLERequestContext& ctx) { rb.Push(result); } -void IUser::GetRegisterInfo(Kernel::HLERequestContext& ctx) { +void IUser::GetRegisterInfo(HLERequestContext& ctx) { IPC::RequestParser rp{ctx}; const auto device_handle{rp.Pop<u64>()}; LOG_INFO(Service_NFP, "called, device_handle={}", device_handle); @@ -451,7 +451,7 @@ void IUser::GetRegisterInfo(Kernel::HLERequestContext& ctx) { rb.Push(result); } -void IUser::GetCommonInfo(Kernel::HLERequestContext& ctx) { +void IUser::GetCommonInfo(HLERequestContext& ctx) { IPC::RequestParser rp{ctx}; const auto device_handle{rp.Pop<u64>()}; LOG_INFO(Service_NFP, "called, device_handle={}", device_handle); @@ -477,7 +477,7 @@ void IUser::GetCommonInfo(Kernel::HLERequestContext& ctx) { rb.Push(result); } -void IUser::GetModelInfo(Kernel::HLERequestContext& ctx) { +void IUser::GetModelInfo(HLERequestContext& ctx) { IPC::RequestParser rp{ctx}; const auto device_handle{rp.Pop<u64>()}; LOG_INFO(Service_NFP, "called, device_handle={}", device_handle); @@ -503,7 +503,7 @@ void IUser::GetModelInfo(Kernel::HLERequestContext& ctx) { rb.Push(result); } -void IUser::AttachActivateEvent(Kernel::HLERequestContext& ctx) { +void IUser::AttachActivateEvent(HLERequestContext& ctx) { IPC::RequestParser rp{ctx}; const auto device_handle{rp.Pop<u64>()}; LOG_DEBUG(Service_NFP, "called, device_handle={}", device_handle); @@ -527,7 +527,7 @@ void IUser::AttachActivateEvent(Kernel::HLERequestContext& ctx) { rb.PushCopyObjects(device.value()->GetActivateEvent()); } -void IUser::AttachDeactivateEvent(Kernel::HLERequestContext& ctx) { +void IUser::AttachDeactivateEvent(HLERequestContext& ctx) { IPC::RequestParser rp{ctx}; const auto device_handle{rp.Pop<u64>()}; LOG_DEBUG(Service_NFP, "called, device_handle={}", device_handle); @@ -551,7 +551,7 @@ void IUser::AttachDeactivateEvent(Kernel::HLERequestContext& ctx) { rb.PushCopyObjects(device.value()->GetDeactivateEvent()); } -void IUser::GetState(Kernel::HLERequestContext& ctx) { +void IUser::GetState(HLERequestContext& ctx) { LOG_DEBUG(Service_NFP, "called"); IPC::ResponseBuilder rb{ctx, 3}; @@ -559,7 +559,7 @@ void IUser::GetState(Kernel::HLERequestContext& ctx) { rb.PushEnum(state); } -void IUser::GetDeviceState(Kernel::HLERequestContext& ctx) { +void IUser::GetDeviceState(HLERequestContext& ctx) { IPC::RequestParser rp{ctx}; const auto device_handle{rp.Pop<u64>()}; LOG_DEBUG(Service_NFP, "called, device_handle={}", device_handle); @@ -577,7 +577,7 @@ void IUser::GetDeviceState(Kernel::HLERequestContext& ctx) { rb.PushEnum(device.value()->GetCurrentState()); } -void IUser::GetNpadId(Kernel::HLERequestContext& ctx) { +void IUser::GetNpadId(HLERequestContext& ctx) { IPC::RequestParser rp{ctx}; const auto device_handle{rp.Pop<u64>()}; LOG_DEBUG(Service_NFP, "called, device_handle={}", device_handle); @@ -601,7 +601,7 @@ void IUser::GetNpadId(Kernel::HLERequestContext& ctx) { rb.PushEnum(device.value()->GetNpadId()); } -void IUser::GetApplicationAreaSize(Kernel::HLERequestContext& ctx) { +void IUser::GetApplicationAreaSize(HLERequestContext& ctx) { IPC::RequestParser rp{ctx}; const auto device_handle{rp.Pop<u64>()}; LOG_DEBUG(Service_NFP, "called, device_handle={}", device_handle); @@ -619,7 +619,7 @@ void IUser::GetApplicationAreaSize(Kernel::HLERequestContext& ctx) { rb.Push(device.value()->GetApplicationAreaSize()); } -void IUser::AttachAvailabilityChangeEvent(Kernel::HLERequestContext& ctx) { +void IUser::AttachAvailabilityChangeEvent(HLERequestContext& ctx) { LOG_INFO(Service_NFP, "called"); if (state == State::NonInitialized) { @@ -633,7 +633,7 @@ void IUser::AttachAvailabilityChangeEvent(Kernel::HLERequestContext& ctx) { rb.PushCopyObjects(availability_change_event->GetReadableEvent()); } -void IUser::RecreateApplicationArea(Kernel::HLERequestContext& ctx) { +void IUser::RecreateApplicationArea(HLERequestContext& ctx) { IPC::RequestParser rp{ctx}; const auto device_handle{rp.Pop<u64>()}; const auto access_id{rp.Pop<u32>()}; diff --git a/src/core/hle/service/nfp/nfp_user.h b/src/core/hle/service/nfp/nfp_user.h index 7e9a90af8..1f3ff2ea8 100644 --- a/src/core/hle/service/nfp/nfp_user.h +++ b/src/core/hle/service/nfp/nfp_user.h @@ -24,31 +24,31 @@ private: Initialized, }; - void Initialize(Kernel::HLERequestContext& ctx); - void Finalize(Kernel::HLERequestContext& ctx); - void ListDevices(Kernel::HLERequestContext& ctx); - void StartDetection(Kernel::HLERequestContext& ctx); - void StopDetection(Kernel::HLERequestContext& ctx); - void Mount(Kernel::HLERequestContext& ctx); - void Unmount(Kernel::HLERequestContext& ctx); - void OpenApplicationArea(Kernel::HLERequestContext& ctx); - void GetApplicationArea(Kernel::HLERequestContext& ctx); - void SetApplicationArea(Kernel::HLERequestContext& ctx); - void Flush(Kernel::HLERequestContext& ctx); - void Restore(Kernel::HLERequestContext& ctx); - void CreateApplicationArea(Kernel::HLERequestContext& ctx); - void GetTagInfo(Kernel::HLERequestContext& ctx); - void GetRegisterInfo(Kernel::HLERequestContext& ctx); - void GetCommonInfo(Kernel::HLERequestContext& ctx); - void GetModelInfo(Kernel::HLERequestContext& ctx); - void AttachActivateEvent(Kernel::HLERequestContext& ctx); - void AttachDeactivateEvent(Kernel::HLERequestContext& ctx); - void GetState(Kernel::HLERequestContext& ctx); - void GetDeviceState(Kernel::HLERequestContext& ctx); - void GetNpadId(Kernel::HLERequestContext& ctx); - void GetApplicationAreaSize(Kernel::HLERequestContext& ctx); - void AttachAvailabilityChangeEvent(Kernel::HLERequestContext& ctx); - void RecreateApplicationArea(Kernel::HLERequestContext& ctx); + void Initialize(HLERequestContext& ctx); + void Finalize(HLERequestContext& ctx); + void ListDevices(HLERequestContext& ctx); + void StartDetection(HLERequestContext& ctx); + void StopDetection(HLERequestContext& ctx); + void Mount(HLERequestContext& ctx); + void Unmount(HLERequestContext& ctx); + void OpenApplicationArea(HLERequestContext& ctx); + void GetApplicationArea(HLERequestContext& ctx); + void SetApplicationArea(HLERequestContext& ctx); + void Flush(HLERequestContext& ctx); + void Restore(HLERequestContext& ctx); + void CreateApplicationArea(HLERequestContext& ctx); + void GetTagInfo(HLERequestContext& ctx); + void GetRegisterInfo(HLERequestContext& ctx); + void GetCommonInfo(HLERequestContext& ctx); + void GetModelInfo(HLERequestContext& ctx); + void AttachActivateEvent(HLERequestContext& ctx); + void AttachDeactivateEvent(HLERequestContext& ctx); + void GetState(HLERequestContext& ctx); + void GetDeviceState(HLERequestContext& ctx); + void GetNpadId(HLERequestContext& ctx); + void GetApplicationAreaSize(HLERequestContext& ctx); + void AttachAvailabilityChangeEvent(HLERequestContext& ctx); + void RecreateApplicationArea(HLERequestContext& ctx); std::optional<std::shared_ptr<NfpDevice>> GetNfpDevice(u64 handle); diff --git a/src/core/hle/service/ngct/ngct.cpp b/src/core/hle/service/ngct/ngct.cpp index 76897d05c..493c80ed2 100644 --- a/src/core/hle/service/ngct/ngct.cpp +++ b/src/core/hle/service/ngct/ngct.cpp @@ -3,7 +3,7 @@ #include "common/string_util.h" #include "core/core.h" -#include "core/hle/ipc_helpers.h" +#include "core/hle/service/ipc_helpers.h" #include "core/hle/service/ngct/ngct.h" #include "core/hle/service/server_manager.h" #include "core/hle/service/service.h" @@ -24,7 +24,7 @@ public: } private: - void Match(Kernel::HLERequestContext& ctx) { + void Match(HLERequestContext& ctx) { const auto buffer = ctx.ReadBuffer(); const auto text = Common::StringFromFixedZeroTerminatedBuffer( reinterpret_cast<const char*>(buffer.data()), buffer.size()); @@ -37,7 +37,7 @@ private: rb.Push(false); } - void Filter(Kernel::HLERequestContext& ctx) { + void Filter(HLERequestContext& ctx) { const auto buffer = ctx.ReadBuffer(); const auto text = Common::StringFromFixedZeroTerminatedBuffer( reinterpret_cast<const char*>(buffer.data()), buffer.size()); diff --git a/src/core/hle/service/nifm/nifm.cpp b/src/core/hle/service/nifm/nifm.cpp index 3d176b3c2..0c042f412 100644 --- a/src/core/hle/service/nifm/nifm.cpp +++ b/src/core/hle/service/nifm/nifm.cpp @@ -2,8 +2,8 @@ // SPDX-License-Identifier: GPL-2.0-or-later #include "core/core.h" -#include "core/hle/ipc_helpers.h" #include "core/hle/kernel/k_event.h" +#include "core/hle/service/ipc_helpers.h" #include "core/hle/service/kernel_helpers.h" #include "core/hle/service/nifm/nifm.h" #include "core/hle/service/server_manager.h" @@ -217,7 +217,7 @@ public: } private: - void Submit(Kernel::HLERequestContext& ctx) { + void Submit(HLERequestContext& ctx) { LOG_WARNING(Service_NIFM, "(STUBBED) called"); if (state == RequestState::NotSubmitted) { @@ -228,7 +228,7 @@ private: rb.Push(ResultSuccess); } - void GetRequestState(Kernel::HLERequestContext& ctx) { + void GetRequestState(HLERequestContext& ctx) { LOG_WARNING(Service_NIFM, "(STUBBED) called"); IPC::ResponseBuilder rb{ctx, 3}; @@ -236,7 +236,7 @@ private: rb.PushEnum(state); } - void GetResult(Kernel::HLERequestContext& ctx) { + void GetResult(HLERequestContext& ctx) { LOG_WARNING(Service_NIFM, "(STUBBED) called"); const auto result = [this] { @@ -261,7 +261,7 @@ private: rb.Push(result); } - void GetSystemEventReadableHandles(Kernel::HLERequestContext& ctx) { + void GetSystemEventReadableHandles(HLERequestContext& ctx) { LOG_WARNING(Service_NIFM, "(STUBBED) called"); IPC::ResponseBuilder rb{ctx, 2, 2}; @@ -269,21 +269,21 @@ private: rb.PushCopyObjects(event1->GetReadableEvent(), event2->GetReadableEvent()); } - void Cancel(Kernel::HLERequestContext& ctx) { + void Cancel(HLERequestContext& ctx) { LOG_WARNING(Service_NIFM, "(STUBBED) called"); IPC::ResponseBuilder rb{ctx, 2}; rb.Push(ResultSuccess); } - void SetConnectionConfirmationOption(Kernel::HLERequestContext& ctx) { + void SetConnectionConfirmationOption(HLERequestContext& ctx) { LOG_WARNING(Service_NIFM, "(STUBBED) called"); IPC::ResponseBuilder rb{ctx, 2}; rb.Push(ResultSuccess); } - void GetAppletInfo(Kernel::HLERequestContext& ctx) { + void GetAppletInfo(HLERequestContext& ctx) { LOG_WARNING(Service_NIFM, "(STUBBED) called"); std::vector<u8> out_buffer(ctx.GetWriteBufferSize()); @@ -322,7 +322,7 @@ public: } }; -void IGeneralService::GetClientId(Kernel::HLERequestContext& ctx) { +void IGeneralService::GetClientId(HLERequestContext& ctx) { static constexpr u32 client_id = 1; LOG_WARNING(Service_NIFM, "(STUBBED) called"); @@ -331,7 +331,7 @@ void IGeneralService::GetClientId(Kernel::HLERequestContext& ctx) { rb.Push<u64>(client_id); // Client ID needs to be non zero otherwise it's considered invalid } -void IGeneralService::CreateScanRequest(Kernel::HLERequestContext& ctx) { +void IGeneralService::CreateScanRequest(HLERequestContext& ctx) { LOG_DEBUG(Service_NIFM, "called"); IPC::ResponseBuilder rb{ctx, 2, 0, 1}; @@ -340,7 +340,7 @@ void IGeneralService::CreateScanRequest(Kernel::HLERequestContext& ctx) { rb.PushIpcInterface<IScanRequest>(system); } -void IGeneralService::CreateRequest(Kernel::HLERequestContext& ctx) { +void IGeneralService::CreateRequest(HLERequestContext& ctx) { LOG_DEBUG(Service_NIFM, "called"); IPC::ResponseBuilder rb{ctx, 2, 0, 1}; @@ -349,7 +349,7 @@ void IGeneralService::CreateRequest(Kernel::HLERequestContext& ctx) { rb.PushIpcInterface<IRequest>(system); } -void IGeneralService::GetCurrentNetworkProfile(Kernel::HLERequestContext& ctx) { +void IGeneralService::GetCurrentNetworkProfile(HLERequestContext& ctx) { LOG_WARNING(Service_NIFM, "(STUBBED) called"); const auto net_iface = Network::GetSelectedNetworkInterface(); @@ -408,14 +408,14 @@ void IGeneralService::GetCurrentNetworkProfile(Kernel::HLERequestContext& ctx) { rb.Push(ResultSuccess); } -void IGeneralService::RemoveNetworkProfile(Kernel::HLERequestContext& ctx) { +void IGeneralService::RemoveNetworkProfile(HLERequestContext& ctx) { LOG_WARNING(Service_NIFM, "(STUBBED) called"); IPC::ResponseBuilder rb{ctx, 2}; rb.Push(ResultSuccess); } -void IGeneralService::GetCurrentIpAddress(Kernel::HLERequestContext& ctx) { +void IGeneralService::GetCurrentIpAddress(HLERequestContext& ctx) { LOG_WARNING(Service_NIFM, "(STUBBED) called"); auto ipv4 = Network::GetHostIPv4Address(); @@ -436,7 +436,7 @@ void IGeneralService::GetCurrentIpAddress(Kernel::HLERequestContext& ctx) { rb.PushRaw(*ipv4); } -void IGeneralService::CreateTemporaryNetworkProfile(Kernel::HLERequestContext& ctx) { +void IGeneralService::CreateTemporaryNetworkProfile(HLERequestContext& ctx) { LOG_DEBUG(Service_NIFM, "called"); ASSERT_MSG(ctx.GetReadBufferSize() == 0x17c, "SfNetworkProfileData is not the correct size"); @@ -451,7 +451,7 @@ void IGeneralService::CreateTemporaryNetworkProfile(Kernel::HLERequestContext& c rb.PushRaw<u128>(uuid); } -void IGeneralService::GetCurrentIpConfigInfo(Kernel::HLERequestContext& ctx) { +void IGeneralService::GetCurrentIpConfigInfo(HLERequestContext& ctx) { LOG_WARNING(Service_NIFM, "(STUBBED) called"); struct IpConfigInfo { @@ -495,7 +495,7 @@ void IGeneralService::GetCurrentIpConfigInfo(Kernel::HLERequestContext& ctx) { rb.PushRaw<IpConfigInfo>(ip_config_info); } -void IGeneralService::IsWirelessCommunicationEnabled(Kernel::HLERequestContext& ctx) { +void IGeneralService::IsWirelessCommunicationEnabled(HLERequestContext& ctx) { LOG_WARNING(Service_NIFM, "(STUBBED) called"); IPC::ResponseBuilder rb{ctx, 3}; @@ -503,7 +503,7 @@ void IGeneralService::IsWirelessCommunicationEnabled(Kernel::HLERequestContext& rb.Push<u8>(1); } -void IGeneralService::GetInternetConnectionStatus(Kernel::HLERequestContext& ctx) { +void IGeneralService::GetInternetConnectionStatus(HLERequestContext& ctx) { LOG_WARNING(Service_NIFM, "(STUBBED) called"); struct Output { @@ -520,7 +520,7 @@ void IGeneralService::GetInternetConnectionStatus(Kernel::HLERequestContext& ctx rb.PushRaw(out); } -void IGeneralService::IsEthernetCommunicationEnabled(Kernel::HLERequestContext& ctx) { +void IGeneralService::IsEthernetCommunicationEnabled(HLERequestContext& ctx) { LOG_WARNING(Service_NIFM, "(STUBBED) called"); IPC::ResponseBuilder rb{ctx, 3}; @@ -532,7 +532,7 @@ void IGeneralService::IsEthernetCommunicationEnabled(Kernel::HLERequestContext& } } -void IGeneralService::IsAnyInternetRequestAccepted(Kernel::HLERequestContext& ctx) { +void IGeneralService::IsAnyInternetRequestAccepted(HLERequestContext& ctx) { LOG_ERROR(Service_NIFM, "(STUBBED) called"); IPC::ResponseBuilder rb{ctx, 3}; @@ -610,7 +610,7 @@ public: } private: - void CreateGeneralServiceOld(Kernel::HLERequestContext& ctx) { + void CreateGeneralServiceOld(HLERequestContext& ctx) { LOG_DEBUG(Service_NIFM, "called"); IPC::ResponseBuilder rb{ctx, 2, 0, 1}; @@ -618,7 +618,7 @@ private: rb.PushIpcInterface<IGeneralService>(system); } - void CreateGeneralService(Kernel::HLERequestContext& ctx) { + void CreateGeneralService(HLERequestContext& ctx) { LOG_DEBUG(Service_NIFM, "called"); IPC::ResponseBuilder rb{ctx, 2, 0, 1}; diff --git a/src/core/hle/service/nifm/nifm.h b/src/core/hle/service/nifm/nifm.h index b5da7ae12..9b20e6823 100644 --- a/src/core/hle/service/nifm/nifm.h +++ b/src/core/hle/service/nifm/nifm.h @@ -22,18 +22,18 @@ public: ~IGeneralService() override; private: - void GetClientId(Kernel::HLERequestContext& ctx); - void CreateScanRequest(Kernel::HLERequestContext& ctx); - void CreateRequest(Kernel::HLERequestContext& ctx); - void GetCurrentNetworkProfile(Kernel::HLERequestContext& ctx); - void RemoveNetworkProfile(Kernel::HLERequestContext& ctx); - void GetCurrentIpAddress(Kernel::HLERequestContext& ctx); - void CreateTemporaryNetworkProfile(Kernel::HLERequestContext& ctx); - void GetCurrentIpConfigInfo(Kernel::HLERequestContext& ctx); - void IsWirelessCommunicationEnabled(Kernel::HLERequestContext& ctx); - void GetInternetConnectionStatus(Kernel::HLERequestContext& ctx); - void IsEthernetCommunicationEnabled(Kernel::HLERequestContext& ctx); - void IsAnyInternetRequestAccepted(Kernel::HLERequestContext& ctx); + void GetClientId(HLERequestContext& ctx); + void CreateScanRequest(HLERequestContext& ctx); + void CreateRequest(HLERequestContext& ctx); + void GetCurrentNetworkProfile(HLERequestContext& ctx); + void RemoveNetworkProfile(HLERequestContext& ctx); + void GetCurrentIpAddress(HLERequestContext& ctx); + void CreateTemporaryNetworkProfile(HLERequestContext& ctx); + void GetCurrentIpConfigInfo(HLERequestContext& ctx); + void IsWirelessCommunicationEnabled(HLERequestContext& ctx); + void GetInternetConnectionStatus(HLERequestContext& ctx); + void IsEthernetCommunicationEnabled(HLERequestContext& ctx); + void IsAnyInternetRequestAccepted(HLERequestContext& ctx); Network::RoomNetwork& network; }; diff --git a/src/core/hle/service/nim/nim.cpp b/src/core/hle/service/nim/nim.cpp index aff7cc5bd..42de87f9a 100644 --- a/src/core/hle/service/nim/nim.cpp +++ b/src/core/hle/service/nim/nim.cpp @@ -4,8 +4,8 @@ #include <chrono> #include <ctime> #include "core/core.h" -#include "core/hle/ipc_helpers.h" #include "core/hle/kernel/k_event.h" +#include "core/hle/service/ipc_helpers.h" #include "core/hle/service/kernel_helpers.h" #include "core/hle/service/nim/nim.h" #include "core/hle/service/server_manager.h" @@ -46,7 +46,7 @@ public: } private: - void CreateAsyncInterface(Kernel::HLERequestContext& ctx) { + void CreateAsyncInterface(HLERequestContext& ctx) { LOG_WARNING(Service_NIM, "(STUBBED) called"); IPC::ResponseBuilder rb{ctx, 2, 0, 1}; rb.Push(ResultSuccess); @@ -68,7 +68,7 @@ public: } private: - void CreateAccessorInterface(Kernel::HLERequestContext& ctx) { + void CreateAccessorInterface(HLERequestContext& ctx) { LOG_WARNING(Service_NIM, "(STUBBED) called"); IPC::ResponseBuilder rb{ctx, 2, 0, 1}; rb.Push(ResultSuccess); @@ -239,14 +239,14 @@ public: } private: - void CreateServerInterface(Kernel::HLERequestContext& ctx) { + void CreateServerInterface(HLERequestContext& ctx) { LOG_WARNING(Service_NIM, "(STUBBED) called"); IPC::ResponseBuilder rb{ctx, 2, 0, 1}; rb.Push(ResultSuccess); rb.PushIpcInterface<IShopServiceAccessServer>(system); } - void IsLargeResourceAvailable(Kernel::HLERequestContext& ctx) { + void IsLargeResourceAvailable(HLERequestContext& ctx) { IPC::RequestParser rp{ctx}; const auto unknown{rp.Pop<u64>()}; @@ -325,7 +325,7 @@ public: } private: - void StartTask(Kernel::HLERequestContext& ctx) { + void StartTask(HLERequestContext& ctx) { // No need to connect to the internet, just finish the task straight away. LOG_DEBUG(Service_NIM, "called"); finished_event->Signal(); @@ -333,7 +333,7 @@ private: rb.Push(ResultSuccess); } - void GetFinishNotificationEvent(Kernel::HLERequestContext& ctx) { + void GetFinishNotificationEvent(HLERequestContext& ctx) { LOG_DEBUG(Service_NIM, "called"); IPC::ResponseBuilder rb{ctx, 2, 1}; @@ -341,21 +341,21 @@ private: rb.PushCopyObjects(finished_event->GetReadableEvent()); } - void GetResult(Kernel::HLERequestContext& ctx) { + void GetResult(HLERequestContext& ctx) { LOG_DEBUG(Service_NIM, "called"); IPC::ResponseBuilder rb{ctx, 2}; rb.Push(ResultSuccess); } - void Cancel(Kernel::HLERequestContext& ctx) { + void Cancel(HLERequestContext& ctx) { LOG_DEBUG(Service_NIM, "called"); finished_event->Clear(); IPC::ResponseBuilder rb{ctx, 2}; rb.Push(ResultSuccess); } - void IsProcessing(Kernel::HLERequestContext& ctx) { + void IsProcessing(HLERequestContext& ctx) { LOG_DEBUG(Service_NIM, "called"); IPC::ResponseBuilder rb{ctx, 3}; @@ -363,7 +363,7 @@ private: rb.PushRaw<u32>(0); // We instantly process the request } - void GetServerTime(Kernel::HLERequestContext& ctx) { + void GetServerTime(HLERequestContext& ctx) { LOG_DEBUG(Service_NIM, "called"); const s64 server_time{std::chrono::duration_cast<std::chrono::seconds>( @@ -394,7 +394,7 @@ public: } private: - void OpenEnsureNetworkClockAvailabilityService(Kernel::HLERequestContext& ctx) { + void OpenEnsureNetworkClockAvailabilityService(HLERequestContext& ctx) { LOG_DEBUG(Service_NIM, "called"); IPC::ResponseBuilder rb{ctx, 2, 0, 1}; @@ -403,14 +403,14 @@ private: } // TODO(ogniK): Do we need these? - void SuspendAutonomicTimeCorrection(Kernel::HLERequestContext& ctx) { + void SuspendAutonomicTimeCorrection(HLERequestContext& ctx) { LOG_WARNING(Service_NIM, "(STUBBED) called"); IPC::ResponseBuilder rb{ctx, 2}; rb.Push(ResultSuccess); } - void ResumeAutonomicTimeCorrection(Kernel::HLERequestContext& ctx) { + void ResumeAutonomicTimeCorrection(HLERequestContext& ctx) { LOG_WARNING(Service_NIM, "(STUBBED) called"); IPC::ResponseBuilder rb{ctx, 2}; diff --git a/src/core/hle/service/ns/errors.h b/src/core/hle/service/ns/errors.h index 8a7621798..16d2ea6f7 100644 --- a/src/core/hle/service/ns/errors.h +++ b/src/core/hle/service/ns/errors.h @@ -7,5 +7,6 @@ namespace Service::NS { -constexpr Result ERR_APPLICATION_LANGUAGE_NOT_FOUND{ErrorModule::NS, 300}; -}
\ No newline at end of file +constexpr Result ResultApplicationLanguageNotFound{ErrorModule::NS, 300}; + +} diff --git a/src/core/hle/service/ns/iplatform_service_manager.cpp b/src/core/hle/service/ns/iplatform_service_manager.cpp index 1fab2f0dd..6c2f5e70b 100644 --- a/src/core/hle/service/ns/iplatform_service_manager.cpp +++ b/src/core/hle/service/ns/iplatform_service_manager.cpp @@ -15,11 +15,11 @@ #include "core/file_sys/registered_cache.h" #include "core/file_sys/romfs.h" #include "core/file_sys/system_archive/system_archive.h" -#include "core/hle/ipc_helpers.h" #include "core/hle/kernel/k_shared_memory.h" #include "core/hle/kernel/kernel.h" #include "core/hle/kernel/physical_memory.h" #include "core/hle/service/filesystem/filesystem.h" +#include "core/hle/service/ipc_helpers.h" #include "core/hle/service/ns/iplatform_service_manager.h" namespace Service::NS { @@ -119,7 +119,7 @@ struct IPlatformServiceManager::Impl { break; } - // Derive key withing inverse xor + // Derive key within inverse xor const u32 KEY = GetU32Swapped(input.data() + cur_offset) ^ EXPECTED_MAGIC; const u32 SIZE = GetU32Swapped(input.data() + cur_offset + 4) ^ KEY; shared_font_regions.push_back(FontRegion{cur_offset + 8, SIZE}); @@ -208,7 +208,7 @@ IPlatformServiceManager::IPlatformServiceManager(Core::System& system_, const ch IPlatformServiceManager::~IPlatformServiceManager() = default; -void IPlatformServiceManager::RequestLoad(Kernel::HLERequestContext& ctx) { +void IPlatformServiceManager::RequestLoad(HLERequestContext& ctx) { IPC::RequestParser rp{ctx}; const u32 shared_font_type{rp.Pop<u32>()}; // Games don't call this so all fonts should be loaded @@ -218,7 +218,7 @@ void IPlatformServiceManager::RequestLoad(Kernel::HLERequestContext& ctx) { rb.Push(ResultSuccess); } -void IPlatformServiceManager::GetLoadState(Kernel::HLERequestContext& ctx) { +void IPlatformServiceManager::GetLoadState(HLERequestContext& ctx) { IPC::RequestParser rp{ctx}; const u32 font_id{rp.Pop<u32>()}; LOG_DEBUG(Service_NS, "called, font_id={}", font_id); @@ -228,7 +228,7 @@ void IPlatformServiceManager::GetLoadState(Kernel::HLERequestContext& ctx) { rb.Push<u32>(static_cast<u32>(LoadState::Done)); } -void IPlatformServiceManager::GetSize(Kernel::HLERequestContext& ctx) { +void IPlatformServiceManager::GetSize(HLERequestContext& ctx) { IPC::RequestParser rp{ctx}; const u32 font_id{rp.Pop<u32>()}; LOG_DEBUG(Service_NS, "called, font_id={}", font_id); @@ -238,7 +238,7 @@ void IPlatformServiceManager::GetSize(Kernel::HLERequestContext& ctx) { rb.Push<u32>(impl->GetSharedFontRegion(font_id).size); } -void IPlatformServiceManager::GetSharedMemoryAddressOffset(Kernel::HLERequestContext& ctx) { +void IPlatformServiceManager::GetSharedMemoryAddressOffset(HLERequestContext& ctx) { IPC::RequestParser rp{ctx}; const u32 font_id{rp.Pop<u32>()}; LOG_DEBUG(Service_NS, "called, font_id={}", font_id); @@ -248,7 +248,7 @@ void IPlatformServiceManager::GetSharedMemoryAddressOffset(Kernel::HLERequestCon rb.Push<u32>(impl->GetSharedFontRegion(font_id).offset); } -void IPlatformServiceManager::GetSharedMemoryNativeHandle(Kernel::HLERequestContext& ctx) { +void IPlatformServiceManager::GetSharedMemoryNativeHandle(HLERequestContext& ctx) { // Map backing memory for the font data LOG_DEBUG(Service_NS, "called"); @@ -261,7 +261,7 @@ void IPlatformServiceManager::GetSharedMemoryNativeHandle(Kernel::HLERequestCont rb.PushCopyObjects(&kernel.GetFontSharedMem()); } -void IPlatformServiceManager::GetSharedFontInOrderOfPriority(Kernel::HLERequestContext& ctx) { +void IPlatformServiceManager::GetSharedFontInOrderOfPriority(HLERequestContext& ctx) { IPC::RequestParser rp{ctx}; const u64 language_code{rp.Pop<u64>()}; // TODO(ogniK): Find out what this is used for LOG_DEBUG(Service_NS, "called, language_code={:X}", language_code); diff --git a/src/core/hle/service/ns/iplatform_service_manager.h b/src/core/hle/service/ns/iplatform_service_manager.h index ed6eda89f..03071e02b 100644 --- a/src/core/hle/service/ns/iplatform_service_manager.h +++ b/src/core/hle/service/ns/iplatform_service_manager.h @@ -42,12 +42,12 @@ public: ~IPlatformServiceManager() override; private: - void RequestLoad(Kernel::HLERequestContext& ctx); - void GetLoadState(Kernel::HLERequestContext& ctx); - void GetSize(Kernel::HLERequestContext& ctx); - void GetSharedMemoryAddressOffset(Kernel::HLERequestContext& ctx); - void GetSharedMemoryNativeHandle(Kernel::HLERequestContext& ctx); - void GetSharedFontInOrderOfPriority(Kernel::HLERequestContext& ctx); + void RequestLoad(HLERequestContext& ctx); + void GetLoadState(HLERequestContext& ctx); + void GetSize(HLERequestContext& ctx); + void GetSharedMemoryAddressOffset(HLERequestContext& ctx); + void GetSharedMemoryNativeHandle(HLERequestContext& ctx); + void GetSharedFontInOrderOfPriority(HLERequestContext& ctx); struct Impl; std::unique_ptr<Impl> impl; diff --git a/src/core/hle/service/ns/ns.cpp b/src/core/hle/service/ns/ns.cpp index 062e96ef9..376067a95 100644 --- a/src/core/hle/service/ns/ns.cpp +++ b/src/core/hle/service/ns/ns.cpp @@ -7,8 +7,8 @@ #include "core/file_sys/control_metadata.h" #include "core/file_sys/patch_manager.h" #include "core/file_sys/vfs.h" -#include "core/hle/ipc_helpers.h" #include "core/hle/service/glue/glue_manager.h" +#include "core/hle/service/ipc_helpers.h" #include "core/hle/service/ns/errors.h" #include "core/hle/service/ns/iplatform_service_manager.h" #include "core/hle/service/ns/language.h" @@ -329,7 +329,7 @@ IApplicationManagerInterface::IApplicationManagerInterface(Core::System& system_ IApplicationManagerInterface::~IApplicationManagerInterface() = default; -void IApplicationManagerInterface::GetApplicationControlData(Kernel::HLERequestContext& ctx) { +void IApplicationManagerInterface::GetApplicationControlData(HLERequestContext& ctx) { IPC::RequestParser rp{ctx}; const auto flag = rp.PopRaw<u64>(); LOG_DEBUG(Service_NS, "called with flag={:016X}", flag); @@ -388,7 +388,7 @@ void IApplicationManagerInterface::GetApplicationControlData(Kernel::HLERequestC rb.Push<u32>(static_cast<u32>(out.size())); } -void IApplicationManagerInterface::GetApplicationDesiredLanguage(Kernel::HLERequestContext& ctx) { +void IApplicationManagerInterface::GetApplicationDesiredLanguage(HLERequestContext& ctx) { IPC::RequestParser rp{ctx}; const auto supported_languages = rp.Pop<u32>(); @@ -416,14 +416,14 @@ ResultVal<u8> IApplicationManagerInterface::GetApplicationDesiredLanguage( if (application_language == std::nullopt) { LOG_ERROR(Service_NS, "Could not convert application language! language_code={}", language_code); - return ERR_APPLICATION_LANGUAGE_NOT_FOUND; + return Service::NS::ResultApplicationLanguageNotFound; } const auto priority_list = GetApplicationLanguagePriorityList(*application_language); if (!priority_list) { LOG_ERROR(Service_NS, "Could not find application language priorities! application_language={}", *application_language); - return ERR_APPLICATION_LANGUAGE_NOT_FOUND; + return Service::NS::ResultApplicationLanguageNotFound; } // Try to find a valid language. @@ -436,11 +436,11 @@ ResultVal<u8> IApplicationManagerInterface::GetApplicationDesiredLanguage( LOG_ERROR(Service_NS, "Could not find a valid language! supported_languages={:08X}", supported_languages); - return ERR_APPLICATION_LANGUAGE_NOT_FOUND; + return Service::NS::ResultApplicationLanguageNotFound; } void IApplicationManagerInterface::ConvertApplicationLanguageToLanguageCode( - Kernel::HLERequestContext& ctx) { + HLERequestContext& ctx) { IPC::RequestParser rp{ctx}; const auto application_language = rp.Pop<u8>(); @@ -461,7 +461,7 @@ ResultVal<u64> IApplicationManagerInterface::ConvertApplicationLanguageToLanguag ConvertToLanguageCode(static_cast<ApplicationLanguage>(application_language)); if (language_code == std::nullopt) { LOG_ERROR(Service_NS, "Language not found! application_language={}", application_language); - return ERR_APPLICATION_LANGUAGE_NOT_FOUND; + return Service::NS::ResultApplicationLanguageNotFound; } return static_cast<u64>(*language_code); @@ -604,8 +604,7 @@ IReadOnlyApplicationControlDataInterface::IReadOnlyApplicationControlDataInterfa IReadOnlyApplicationControlDataInterface::~IReadOnlyApplicationControlDataInterface() = default; -void IReadOnlyApplicationControlDataInterface::GetApplicationControlData( - Kernel::HLERequestContext& ctx) { +void IReadOnlyApplicationControlDataInterface::GetApplicationControlData(HLERequestContext& ctx) { enum class ApplicationControlSource : u8 { CacheOnly, Storage, @@ -753,7 +752,7 @@ public: } private: - void OpenSystemUpdateControl(Kernel::HLERequestContext& ctx) { + void OpenSystemUpdateControl(HLERequestContext& ctx) { LOG_DEBUG(Service_NS, "called"); IPC::ResponseBuilder rb{ctx, 2, 0, 1}; @@ -777,7 +776,7 @@ public: } private: - void NeedsUpdateVulnerability(Kernel::HLERequestContext& ctx) { + void NeedsUpdateVulnerability(HLERequestContext& ctx) { LOG_WARNING(Service_NS, "(STUBBED) called"); IPC::ResponseBuilder rb{ctx, 3}; diff --git a/src/core/hle/service/ns/ns.h b/src/core/hle/service/ns/ns.h index 797e69a13..203388e1f 100644 --- a/src/core/hle/service/ns/ns.h +++ b/src/core/hle/service/ns/ns.h @@ -32,9 +32,9 @@ public: ResultVal<u64> ConvertApplicationLanguageToLanguageCode(u8 application_language); private: - void GetApplicationControlData(Kernel::HLERequestContext& ctx); - void GetApplicationDesiredLanguage(Kernel::HLERequestContext& ctx); - void ConvertApplicationLanguageToLanguageCode(Kernel::HLERequestContext& ctx); + void GetApplicationControlData(HLERequestContext& ctx); + void GetApplicationDesiredLanguage(HLERequestContext& ctx); + void ConvertApplicationLanguageToLanguageCode(HLERequestContext& ctx); }; class IApplicationVersionInterface final : public ServiceFramework<IApplicationVersionInterface> { @@ -80,7 +80,7 @@ public: ~IReadOnlyApplicationControlDataInterface() override; private: - void GetApplicationControlData(Kernel::HLERequestContext& ctx); + void GetApplicationControlData(HLERequestContext& ctx); }; class NS final : public ServiceFramework<NS> { @@ -92,7 +92,7 @@ public: private: template <typename T, typename... Args> - void PushInterface(Kernel::HLERequestContext& ctx) { + void PushInterface(HLERequestContext& ctx) { LOG_DEBUG(Service_NS, "called"); IPC::ResponseBuilder rb{ctx, 2, 0, 1}; @@ -100,7 +100,7 @@ private: rb.PushIpcInterface<T>(system); } - void PushIApplicationManagerInterface(Kernel::HLERequestContext& ctx) { + void PushIApplicationManagerInterface(HLERequestContext& ctx) { LOG_DEBUG(Service_NS, "called"); IPC::ResponseBuilder rb{ctx, 2, 0, 1}; @@ -110,7 +110,7 @@ private: template <typename T, typename... Args> std::shared_ptr<T> GetInterface(Args&&... args) const { - static_assert(std::is_base_of_v<Kernel::SessionRequestHandler, T>, + static_assert(std::is_base_of_v<SessionRequestHandler, T>, "Not a base of ServiceFrameworkBase"); return std::make_shared<T>(std::forward<Args>(args)...); diff --git a/src/core/hle/service/ns/pdm_qry.cpp b/src/core/hle/service/ns/pdm_qry.cpp index aac8f573f..ce0ee30e0 100644 --- a/src/core/hle/service/ns/pdm_qry.cpp +++ b/src/core/hle/service/ns/pdm_qry.cpp @@ -5,7 +5,7 @@ #include "common/logging/log.h" #include "common/uuid.h" -#include "core/hle/ipc_helpers.h" +#include "core/hle/service/ipc_helpers.h" #include "core/hle/service/ns/pdm_qry.h" #include "core/hle/service/service.h" @@ -42,7 +42,7 @@ PDM_QRY::PDM_QRY(Core::System& system_) : ServiceFramework{system_, "pdm:qry"} { PDM_QRY::~PDM_QRY() = default; -void PDM_QRY::QueryPlayStatisticsByApplicationIdAndUserAccountId(Kernel::HLERequestContext& ctx) { +void PDM_QRY::QueryPlayStatisticsByApplicationIdAndUserAccountId(HLERequestContext& ctx) { IPC::RequestParser rp{ctx}; const auto unknown = rp.Pop<bool>(); rp.Pop<u8>(); // Padding diff --git a/src/core/hle/service/ns/pdm_qry.h b/src/core/hle/service/ns/pdm_qry.h index abcc3bef3..c98e01660 100644 --- a/src/core/hle/service/ns/pdm_qry.h +++ b/src/core/hle/service/ns/pdm_qry.h @@ -26,7 +26,7 @@ public: ~PDM_QRY() override; private: - void QueryPlayStatisticsByApplicationIdAndUserAccountId(Kernel::HLERequestContext& ctx); + void QueryPlayStatisticsByApplicationIdAndUserAccountId(HLERequestContext& ctx); }; } // namespace Service::NS diff --git a/src/core/hle/service/nvdrv/devices/nvdevice.h b/src/core/hle/service/nvdrv/devices/nvdevice.h index c562e04d2..ab1f30f9e 100644 --- a/src/core/hle/service/nvdrv/devices/nvdevice.h +++ b/src/core/hle/service/nvdrv/devices/nvdevice.h @@ -59,7 +59,7 @@ public: std::vector<u8>& output, std::vector<u8>& inline_output) = 0; /** - * Called once a device is openned + * Called once a device is opened * @param fd The device fd */ virtual void OnOpen(DeviceFD fd) = 0; diff --git a/src/core/hle/service/nvdrv/devices/nvdisp_disp0.h b/src/core/hle/service/nvdrv/devices/nvdisp_disp0.h index 81bd7960a..bcd0e3ed5 100644 --- a/src/core/hle/service/nvdrv/devices/nvdisp_disp0.h +++ b/src/core/hle/service/nvdrv/devices/nvdisp_disp0.h @@ -8,8 +8,8 @@ #include "common/common_types.h" #include "common/math_util.h" #include "core/hle/service/nvdrv/devices/nvdevice.h" -#include "core/hle/service/nvflinger/buffer_transform_flags.h" -#include "core/hle/service/nvflinger/pixel_format.h" +#include "core/hle/service/nvnflinger/buffer_transform_flags.h" +#include "core/hle/service/nvnflinger/pixel_format.h" namespace Service::Nvidia::NvCore { class Container; diff --git a/src/core/hle/service/nvdrv/devices/nvmap.cpp b/src/core/hle/service/nvdrv/devices/nvmap.cpp index 277afe0b4..07417f045 100644 --- a/src/core/hle/service/nvdrv/devices/nvmap.cpp +++ b/src/core/hle/service/nvdrv/devices/nvmap.cpp @@ -264,7 +264,7 @@ NvResult nvmap::IocFree(std::span<const u8> input, std::vector<u8>& output) { params.flags.raw = 0; params.flags.map_uncached.Assign(freeInfo->was_uncached); } else { - // This is possible when there's internel dups or other duplicates. + // This is possible when there's internal dups or other duplicates. } std::memcpy(output.data(), ¶ms, sizeof(params)); diff --git a/src/core/hle/service/nvdrv/nvdrv.cpp b/src/core/hle/service/nvdrv/nvdrv.cpp index a70ea9385..3d774eec4 100644 --- a/src/core/hle/service/nvdrv/nvdrv.cpp +++ b/src/core/hle/service/nvdrv/nvdrv.cpp @@ -6,8 +6,8 @@ #include <fmt/format.h> #include "core/core.h" -#include "core/hle/ipc_helpers.h" #include "core/hle/kernel/k_event.h" +#include "core/hle/service/ipc_helpers.h" #include "core/hle/service/nvdrv/core/container.h" #include "core/hle/service/nvdrv/devices/nvdevice.h" #include "core/hle/service/nvdrv/devices/nvdisp_disp0.h" @@ -23,7 +23,7 @@ #include "core/hle/service/nvdrv/nvdrv.h" #include "core/hle/service/nvdrv/nvdrv_interface.h" #include "core/hle/service/nvdrv/nvmemp.h" -#include "core/hle/service/nvflinger/nvflinger.h" +#include "core/hle/service/nvnflinger/nvnflinger.h" #include "core/hle/service/server_manager.h" #include "video_core/gpu.h" @@ -42,7 +42,7 @@ void EventInterface::FreeEvent(Kernel::KEvent* event) { module.service_context.CloseEvent(event); } -void LoopProcess(NVFlinger::NVFlinger& nvflinger, Core::System& system) { +void LoopProcess(Nvnflinger::Nvnflinger& nvnflinger, Core::System& system) { auto server_manager = std::make_unique<ServerManager>(system); auto module = std::make_shared<Module>(system); server_manager->RegisterNamedService("nvdrv", std::make_shared<NVDRV>(system, module, "nvdrv")); @@ -53,7 +53,7 @@ void LoopProcess(NVFlinger::NVFlinger& nvflinger, Core::System& system) { server_manager->RegisterNamedService("nvdrv:t", std::make_shared<NVDRV>(system, module, "nvdrv:t")); server_manager->RegisterNamedService("nvmemp", std::make_shared<NVMEMP>(system)); - nvflinger.SetNVDrvInstance(module); + nvnflinger.SetNVDrvInstance(module); ServerManager::RunServer(std::move(server_manager)); } diff --git a/src/core/hle/service/nvdrv/nvdrv.h b/src/core/hle/service/nvdrv/nvdrv.h index b2270cf76..668be742b 100644 --- a/src/core/hle/service/nvdrv/nvdrv.h +++ b/src/core/hle/service/nvdrv/nvdrv.h @@ -16,7 +16,7 @@ #include "core/hle/service/kernel_helpers.h" #include "core/hle/service/nvdrv/core/container.h" #include "core/hle/service/nvdrv/nvdata.h" -#include "core/hle/service/nvflinger/ui/fence.h" +#include "core/hle/service/nvnflinger/ui/fence.h" #include "core/hle/service/service.h" namespace Core { @@ -27,8 +27,8 @@ namespace Kernel { class KEvent; } -namespace Service::NVFlinger { -class NVFlinger; +namespace Service::Nvnflinger { +class Nvnflinger; } namespace Service::Nvidia { @@ -95,7 +95,7 @@ public: private: friend class EventInterface; - friend class Service::NVFlinger::NVFlinger; + friend class Service::Nvnflinger::Nvnflinger; /// Manages syncpoints on the host NvCore::Container container; @@ -114,6 +114,6 @@ private: std::unordered_map<std::string, std::function<FilesContainerType::iterator(DeviceFD)>> builders; }; -void LoopProcess(NVFlinger::NVFlinger& nvflinger, Core::System& system); +void LoopProcess(Nvnflinger::Nvnflinger& nvnflinger, Core::System& system); } // namespace Service::Nvidia diff --git a/src/core/hle/service/nvdrv/nvdrv_interface.cpp b/src/core/hle/service/nvdrv/nvdrv_interface.cpp index 396fa7ed5..d010a1e03 100644 --- a/src/core/hle/service/nvdrv/nvdrv_interface.cpp +++ b/src/core/hle/service/nvdrv/nvdrv_interface.cpp @@ -5,16 +5,16 @@ #include <cinttypes> #include "common/logging/log.h" #include "core/core.h" -#include "core/hle/ipc_helpers.h" #include "core/hle/kernel/k_event.h" #include "core/hle/kernel/k_readable_event.h" +#include "core/hle/service/ipc_helpers.h" #include "core/hle/service/nvdrv/nvdata.h" #include "core/hle/service/nvdrv/nvdrv.h" #include "core/hle/service/nvdrv/nvdrv_interface.h" namespace Service::Nvidia { -void NVDRV::Open(Kernel::HLERequestContext& ctx) { +void NVDRV::Open(HLERequestContext& ctx) { LOG_DEBUG(Service_NVDRV, "called"); IPC::ResponseBuilder rb{ctx, 4}; rb.Push(ResultSuccess); @@ -44,13 +44,13 @@ void NVDRV::Open(Kernel::HLERequestContext& ctx) { rb.PushEnum(fd != INVALID_NVDRV_FD ? NvResult::Success : NvResult::FileOperationFailed); } -void NVDRV::ServiceError(Kernel::HLERequestContext& ctx, NvResult result) { +void NVDRV::ServiceError(HLERequestContext& ctx, NvResult result) { IPC::ResponseBuilder rb{ctx, 3}; rb.Push(ResultSuccess); rb.PushEnum(result); } -void NVDRV::Ioctl1(Kernel::HLERequestContext& ctx) { +void NVDRV::Ioctl1(HLERequestContext& ctx) { IPC::RequestParser rp{ctx}; const auto fd = rp.Pop<DeviceFD>(); const auto command = rp.PopRaw<Ioctl>(); @@ -76,7 +76,7 @@ void NVDRV::Ioctl1(Kernel::HLERequestContext& ctx) { rb.PushEnum(nv_result); } -void NVDRV::Ioctl2(Kernel::HLERequestContext& ctx) { +void NVDRV::Ioctl2(HLERequestContext& ctx) { IPC::RequestParser rp{ctx}; const auto fd = rp.Pop<DeviceFD>(); const auto command = rp.PopRaw<Ioctl>(); @@ -103,7 +103,7 @@ void NVDRV::Ioctl2(Kernel::HLERequestContext& ctx) { rb.PushEnum(nv_result); } -void NVDRV::Ioctl3(Kernel::HLERequestContext& ctx) { +void NVDRV::Ioctl3(HLERequestContext& ctx) { IPC::RequestParser rp{ctx}; const auto fd = rp.Pop<DeviceFD>(); const auto command = rp.PopRaw<Ioctl>(); @@ -131,7 +131,7 @@ void NVDRV::Ioctl3(Kernel::HLERequestContext& ctx) { rb.PushEnum(nv_result); } -void NVDRV::Close(Kernel::HLERequestContext& ctx) { +void NVDRV::Close(HLERequestContext& ctx) { LOG_DEBUG(Service_NVDRV, "called"); if (!is_initialized) { @@ -149,7 +149,7 @@ void NVDRV::Close(Kernel::HLERequestContext& ctx) { rb.PushEnum(result); } -void NVDRV::Initialize(Kernel::HLERequestContext& ctx) { +void NVDRV::Initialize(HLERequestContext& ctx) { LOG_WARNING(Service_NVDRV, "(STUBBED) called"); is_initialized = true; @@ -159,7 +159,7 @@ void NVDRV::Initialize(Kernel::HLERequestContext& ctx) { rb.PushEnum(NvResult::Success); } -void NVDRV::QueryEvent(Kernel::HLERequestContext& ctx) { +void NVDRV::QueryEvent(HLERequestContext& ctx) { IPC::RequestParser rp{ctx}; const auto fd = rp.Pop<DeviceFD>(); const auto event_id = rp.Pop<u32>(); @@ -187,7 +187,7 @@ void NVDRV::QueryEvent(Kernel::HLERequestContext& ctx) { } } -void NVDRV::SetAruid(Kernel::HLERequestContext& ctx) { +void NVDRV::SetAruid(HLERequestContext& ctx) { IPC::RequestParser rp{ctx}; pid = rp.Pop<u64>(); LOG_WARNING(Service_NVDRV, "(STUBBED) called, pid=0x{:X}", pid); @@ -197,14 +197,14 @@ void NVDRV::SetAruid(Kernel::HLERequestContext& ctx) { rb.PushEnum(NvResult::Success); } -void NVDRV::SetGraphicsFirmwareMemoryMarginEnabled(Kernel::HLERequestContext& ctx) { +void NVDRV::SetGraphicsFirmwareMemoryMarginEnabled(HLERequestContext& ctx) { LOG_WARNING(Service_NVDRV, "(STUBBED) called"); IPC::ResponseBuilder rb{ctx, 2}; rb.Push(ResultSuccess); } -void NVDRV::GetStatus(Kernel::HLERequestContext& ctx) { +void NVDRV::GetStatus(HLERequestContext& ctx) { LOG_WARNING(Service_NVDRV, "(STUBBED) called"); IPC::ResponseBuilder rb{ctx, 3}; @@ -212,7 +212,7 @@ void NVDRV::GetStatus(Kernel::HLERequestContext& ctx) { rb.PushEnum(NvResult::Success); } -void NVDRV::DumpGraphicsMemoryInfo(Kernel::HLERequestContext& ctx) { +void NVDRV::DumpGraphicsMemoryInfo(HLERequestContext& ctx) { // According to SwitchBrew, this has no inputs and no outputs, so effectively does nothing on // retail hardware. LOG_DEBUG(Service_NVDRV, "called"); diff --git a/src/core/hle/service/nvdrv/nvdrv_interface.h b/src/core/hle/service/nvdrv/nvdrv_interface.h index 5ac06ee30..881ea1a6b 100644 --- a/src/core/hle/service/nvdrv/nvdrv_interface.h +++ b/src/core/hle/service/nvdrv/nvdrv_interface.h @@ -15,19 +15,19 @@ public: ~NVDRV() override; private: - void Open(Kernel::HLERequestContext& ctx); - void Ioctl1(Kernel::HLERequestContext& ctx); - void Ioctl2(Kernel::HLERequestContext& ctx); - void Ioctl3(Kernel::HLERequestContext& ctx); - void Close(Kernel::HLERequestContext& ctx); - void Initialize(Kernel::HLERequestContext& ctx); - void QueryEvent(Kernel::HLERequestContext& ctx); - void SetAruid(Kernel::HLERequestContext& ctx); - void SetGraphicsFirmwareMemoryMarginEnabled(Kernel::HLERequestContext& ctx); - void GetStatus(Kernel::HLERequestContext& ctx); - void DumpGraphicsMemoryInfo(Kernel::HLERequestContext& ctx); - - void ServiceError(Kernel::HLERequestContext& ctx, NvResult result); + void Open(HLERequestContext& ctx); + void Ioctl1(HLERequestContext& ctx); + void Ioctl2(HLERequestContext& ctx); + void Ioctl3(HLERequestContext& ctx); + void Close(HLERequestContext& ctx); + void Initialize(HLERequestContext& ctx); + void QueryEvent(HLERequestContext& ctx); + void SetAruid(HLERequestContext& ctx); + void SetGraphicsFirmwareMemoryMarginEnabled(HLERequestContext& ctx); + void GetStatus(HLERequestContext& ctx); + void DumpGraphicsMemoryInfo(HLERequestContext& ctx); + + void ServiceError(HLERequestContext& ctx, NvResult result); std::shared_ptr<Module> nvdrv; diff --git a/src/core/hle/service/nvdrv/nvmemp.cpp b/src/core/hle/service/nvdrv/nvmemp.cpp index e433580b1..fc10f6406 100644 --- a/src/core/hle/service/nvdrv/nvmemp.cpp +++ b/src/core/hle/service/nvdrv/nvmemp.cpp @@ -17,11 +17,11 @@ NVMEMP::NVMEMP(Core::System& system_) : ServiceFramework{system_, "nvmemp"} { NVMEMP::~NVMEMP() = default; -void NVMEMP::Open(Kernel::HLERequestContext& ctx) { +void NVMEMP::Open(HLERequestContext& ctx) { UNIMPLEMENTED(); } -void NVMEMP::GetAruid(Kernel::HLERequestContext& ctx) { +void NVMEMP::GetAruid(HLERequestContext& ctx) { UNIMPLEMENTED(); } diff --git a/src/core/hle/service/nvdrv/nvmemp.h b/src/core/hle/service/nvdrv/nvmemp.h index 3d4276327..85e3053a8 100644 --- a/src/core/hle/service/nvdrv/nvmemp.h +++ b/src/core/hle/service/nvdrv/nvmemp.h @@ -17,8 +17,8 @@ public: ~NVMEMP() override; private: - void Open(Kernel::HLERequestContext& ctx); - void GetAruid(Kernel::HLERequestContext& ctx); + void Open(HLERequestContext& ctx); + void GetAruid(HLERequestContext& ctx); }; } // namespace Service::Nvidia diff --git a/src/core/hle/service/nvflinger/binder.h b/src/core/hle/service/nvnflinger/binder.h index 157333ff8..aef1477e3 100644 --- a/src/core/hle/service/nvflinger/binder.h +++ b/src/core/hle/service/nvnflinger/binder.h @@ -9,10 +9,13 @@ #include "common/common_types.h" namespace Kernel { -class HLERequestContext; class KReadableEvent; } // namespace Kernel +namespace Service { +class HLERequestContext; +} + namespace Service::android { enum class TransactionId { @@ -35,8 +38,7 @@ enum class TransactionId { class IBinder { public: virtual ~IBinder() = default; - virtual void Transact(Kernel::HLERequestContext& ctx, android::TransactionId code, - u32 flags) = 0; + virtual void Transact(HLERequestContext& ctx, android::TransactionId code, u32 flags) = 0; virtual Kernel::KReadableEvent& GetNativeHandle() = 0; }; diff --git a/src/core/hle/service/nvflinger/buffer_item.h b/src/core/hle/service/nvnflinger/buffer_item.h index f73dec4f1..7fd808f54 100644 --- a/src/core/hle/service/nvflinger/buffer_item.h +++ b/src/core/hle/service/nvnflinger/buffer_item.h @@ -10,8 +10,8 @@ #include "common/common_types.h" #include "common/math_util.h" -#include "core/hle/service/nvflinger/ui/fence.h" -#include "core/hle/service/nvflinger/window.h" +#include "core/hle/service/nvnflinger/ui/fence.h" +#include "core/hle/service/nvnflinger/window.h" namespace Service::android { diff --git a/src/core/hle/service/nvflinger/buffer_item_consumer.cpp b/src/core/hle/service/nvnflinger/buffer_item_consumer.cpp index 152bb5bdf..cf151ea3a 100644 --- a/src/core/hle/service/nvflinger/buffer_item_consumer.cpp +++ b/src/core/hle/service/nvnflinger/buffer_item_consumer.cpp @@ -6,9 +6,9 @@ #include "common/assert.h" #include "common/logging/log.h" -#include "core/hle/service/nvflinger/buffer_item.h" -#include "core/hle/service/nvflinger/buffer_item_consumer.h" -#include "core/hle/service/nvflinger/buffer_queue_consumer.h" +#include "core/hle/service/nvnflinger/buffer_item.h" +#include "core/hle/service/nvnflinger/buffer_item_consumer.h" +#include "core/hle/service/nvnflinger/buffer_queue_consumer.h" namespace Service::android { @@ -25,7 +25,7 @@ Status BufferItemConsumer::AcquireBuffer(BufferItem* item, std::chrono::nanoseco if (const auto status = AcquireBufferLocked(item, present_when); status != Status::NoError) { if (status != Status::NoBufferAvailable) { - LOG_ERROR(Service_NVFlinger, "Failed to acquire buffer: {}", status); + LOG_ERROR(Service_Nvnflinger, "Failed to acquire buffer: {}", status); } return status; } @@ -44,12 +44,12 @@ Status BufferItemConsumer::ReleaseBuffer(const BufferItem& item, const Fence& re if (const auto status = AddReleaseFenceLocked(item.buf, item.graphic_buffer, release_fence); status != Status::NoError) { - LOG_ERROR(Service_NVFlinger, "Failed to add fence: {}", status); + LOG_ERROR(Service_Nvnflinger, "Failed to add fence: {}", status); } if (const auto status = ReleaseBufferLocked(item.buf, item.graphic_buffer); status != Status::NoError) { - LOG_WARNING(Service_NVFlinger, "Failed to release buffer: {}", status); + LOG_WARNING(Service_Nvnflinger, "Failed to release buffer: {}", status); return status; } diff --git a/src/core/hle/service/nvflinger/buffer_item_consumer.h b/src/core/hle/service/nvnflinger/buffer_item_consumer.h index a5c655d9e..e0c6b3604 100644 --- a/src/core/hle/service/nvflinger/buffer_item_consumer.h +++ b/src/core/hle/service/nvnflinger/buffer_item_consumer.h @@ -10,8 +10,8 @@ #include <memory> #include "common/common_types.h" -#include "core/hle/service/nvflinger/consumer_base.h" -#include "core/hle/service/nvflinger/status.h" +#include "core/hle/service/nvnflinger/consumer_base.h" +#include "core/hle/service/nvnflinger/status.h" namespace Service::android { diff --git a/src/core/hle/service/nvflinger/buffer_queue_consumer.cpp b/src/core/hle/service/nvnflinger/buffer_queue_consumer.cpp index 0767e548d..51291539d 100644 --- a/src/core/hle/service/nvflinger/buffer_queue_consumer.cpp +++ b/src/core/hle/service/nvnflinger/buffer_queue_consumer.cpp @@ -6,11 +6,11 @@ #include "common/logging/log.h" #include "core/hle/service/nvdrv/core/nvmap.h" -#include "core/hle/service/nvflinger/buffer_item.h" -#include "core/hle/service/nvflinger/buffer_queue_consumer.h" -#include "core/hle/service/nvflinger/buffer_queue_core.h" -#include "core/hle/service/nvflinger/producer_listener.h" -#include "core/hle/service/nvflinger/ui/graphic_buffer.h" +#include "core/hle/service/nvnflinger/buffer_item.h" +#include "core/hle/service/nvnflinger/buffer_queue_consumer.h" +#include "core/hle/service/nvnflinger/buffer_queue_core.h" +#include "core/hle/service/nvnflinger/producer_listener.h" +#include "core/hle/service/nvnflinger/ui/graphic_buffer.h" namespace Service::android { @@ -31,7 +31,7 @@ Status BufferQueueConsumer::AcquireBuffer(BufferItem* out_buffer, }))}; if (num_acquired_buffers >= core->max_acquired_buffer_count + 1) { - LOG_ERROR(Service_NVFlinger, "max acquired buffer count reached: {} (max {})", + LOG_ERROR(Service_Nvnflinger, "max acquired buffer count reached: {} (max {})", num_acquired_buffers, core->max_acquired_buffer_count); return Status::InvalidOperation; } @@ -57,12 +57,12 @@ Status BufferQueueConsumer::AcquireBuffer(BufferItem* out_buffer, if (desired_present < expected_present.count() - MAX_REASONABLE_NSEC || desired_present > expected_present.count()) { // This buffer is set to display in the near future, or desired_present is garbage. - LOG_DEBUG(Service_NVFlinger, "nodrop desire={} expect={}", desired_present, + LOG_DEBUG(Service_Nvnflinger, "nodrop desire={} expect={}", desired_present, expected_present.count()); break; } - LOG_DEBUG(Service_NVFlinger, "drop desire={} expect={} size={}", desired_present, + LOG_DEBUG(Service_Nvnflinger, "drop desire={} expect={} size={}", desired_present, expected_present.count(), core->queue.size()); if (core->StillTracking(*front)) { @@ -78,19 +78,19 @@ Status BufferQueueConsumer::AcquireBuffer(BufferItem* out_buffer, const auto desired_present = front->timestamp; if (desired_present > expected_present.count() && desired_present < expected_present.count() + MAX_REASONABLE_NSEC) { - LOG_DEBUG(Service_NVFlinger, "defer desire={} expect={}", desired_present, + LOG_DEBUG(Service_Nvnflinger, "defer desire={} expect={}", desired_present, expected_present.count()); return Status::PresentLater; } - LOG_DEBUG(Service_NVFlinger, "accept desire={} expect={}", desired_present, + LOG_DEBUG(Service_Nvnflinger, "accept desire={} expect={}", desired_present, expected_present.count()); } const auto slot = front->slot; *out_buffer = *front; - LOG_DEBUG(Service_NVFlinger, "acquiring slot={}", slot); + LOG_DEBUG(Service_Nvnflinger, "acquiring slot={}", slot); // If the buffer has previously been acquired by the consumer, set graphic_buffer to nullptr to // avoid unnecessarily remapping this buffer on the consumer side. @@ -109,7 +109,7 @@ Status BufferQueueConsumer::AcquireBuffer(BufferItem* out_buffer, Status BufferQueueConsumer::ReleaseBuffer(s32 slot, u64 frame_number, const Fence& release_fence) { if (slot < 0 || slot >= BufferQueueDefs::NUM_BUFFER_SLOTS) { - LOG_ERROR(Service_NVFlinger, "slot {} out of range", slot); + LOG_ERROR(Service_Nvnflinger, "slot {} out of range", slot); return Status::BadValue; } @@ -127,7 +127,7 @@ Status BufferQueueConsumer::ReleaseBuffer(s32 slot, u64 frame_number, const Fenc auto current(core->queue.begin()); while (current != core->queue.end()) { if (current->slot == slot) { - LOG_ERROR(Service_NVFlinger, "buffer slot {} pending release is currently queued", + LOG_ERROR(Service_Nvnflinger, "buffer slot {} pending release is currently queued", slot); return Status::BadValue; } @@ -140,7 +140,7 @@ Status BufferQueueConsumer::ReleaseBuffer(s32 slot, u64 frame_number, const Fenc listener = core->connected_producer_listener; - LOG_DEBUG(Service_NVFlinger, "releasing slot {}", slot); + LOG_DEBUG(Service_Nvnflinger, "releasing slot {}", slot); core->SignalDequeueCondition(); } @@ -156,16 +156,16 @@ Status BufferQueueConsumer::ReleaseBuffer(s32 slot, u64 frame_number, const Fenc Status BufferQueueConsumer::Connect(std::shared_ptr<IConsumerListener> consumer_listener, bool controlled_by_app) { if (consumer_listener == nullptr) { - LOG_ERROR(Service_NVFlinger, "consumer_listener may not be nullptr"); + LOG_ERROR(Service_Nvnflinger, "consumer_listener may not be nullptr"); return Status::BadValue; } - LOG_DEBUG(Service_NVFlinger, "controlled_by_app={}", controlled_by_app); + LOG_DEBUG(Service_Nvnflinger, "controlled_by_app={}", controlled_by_app); std::scoped_lock lock{core->mutex}; if (core->is_abandoned) { - LOG_ERROR(Service_NVFlinger, "BufferQueue has been abandoned"); + LOG_ERROR(Service_Nvnflinger, "BufferQueue has been abandoned"); return Status::NoInit; } @@ -177,14 +177,14 @@ Status BufferQueueConsumer::Connect(std::shared_ptr<IConsumerListener> consumer_ Status BufferQueueConsumer::GetReleasedBuffers(u64* out_slot_mask) { if (out_slot_mask == nullptr) { - LOG_ERROR(Service_NVFlinger, "out_slot_mask may not be nullptr"); + LOG_ERROR(Service_Nvnflinger, "out_slot_mask may not be nullptr"); return Status::BadValue; } std::scoped_lock lock{core->mutex}; if (core->is_abandoned) { - LOG_ERROR(Service_NVFlinger, "BufferQueue has been abandoned"); + LOG_ERROR(Service_Nvnflinger, "BufferQueue has been abandoned"); return Status::NoInit; } @@ -205,7 +205,7 @@ Status BufferQueueConsumer::GetReleasedBuffers(u64* out_slot_mask) { ++current; } - LOG_DEBUG(Service_NVFlinger, "returning mask {}", mask); + LOG_DEBUG(Service_Nvnflinger, "returning mask {}", mask); *out_slot_mask = mask; return Status::NoError; } diff --git a/src/core/hle/service/nvflinger/buffer_queue_consumer.h b/src/core/hle/service/nvnflinger/buffer_queue_consumer.h index 4ec06ca13..50ed0bb5f 100644 --- a/src/core/hle/service/nvflinger/buffer_queue_consumer.h +++ b/src/core/hle/service/nvnflinger/buffer_queue_consumer.h @@ -10,8 +10,8 @@ #include <memory> #include "common/common_types.h" -#include "core/hle/service/nvflinger/buffer_queue_defs.h" -#include "core/hle/service/nvflinger/status.h" +#include "core/hle/service/nvnflinger/buffer_queue_defs.h" +#include "core/hle/service/nvnflinger/status.h" namespace Service::Nvidia::NvCore { class NvMap; diff --git a/src/core/hle/service/nvflinger/buffer_queue_core.cpp b/src/core/hle/service/nvnflinger/buffer_queue_core.cpp index 3d1338e66..2dbe29616 100644 --- a/src/core/hle/service/nvflinger/buffer_queue_core.cpp +++ b/src/core/hle/service/nvnflinger/buffer_queue_core.cpp @@ -6,7 +6,7 @@ #include "common/assert.h" -#include "core/hle/service/nvflinger/buffer_queue_core.h" +#include "core/hle/service/nvnflinger/buffer_queue_core.h" namespace Service::android { @@ -82,7 +82,7 @@ s32 BufferQueueCore::GetPreallocatedBufferCountLocked() const { } void BufferQueueCore::FreeBufferLocked(s32 slot) { - LOG_DEBUG(Service_NVFlinger, "slot {}", slot); + LOG_DEBUG(Service_Nvnflinger, "slot {}", slot); slots[slot].graphic_buffer.reset(); diff --git a/src/core/hle/service/nvflinger/buffer_queue_core.h b/src/core/hle/service/nvnflinger/buffer_queue_core.h index 85b3bc4c1..9164f08a0 100644 --- a/src/core/hle/service/nvflinger/buffer_queue_core.h +++ b/src/core/hle/service/nvnflinger/buffer_queue_core.h @@ -13,11 +13,11 @@ #include <set> #include <vector> -#include "core/hle/service/nvflinger/buffer_item.h" -#include "core/hle/service/nvflinger/buffer_queue_defs.h" -#include "core/hle/service/nvflinger/pixel_format.h" -#include "core/hle/service/nvflinger/status.h" -#include "core/hle/service/nvflinger/window.h" +#include "core/hle/service/nvnflinger/buffer_item.h" +#include "core/hle/service/nvnflinger/buffer_queue_defs.h" +#include "core/hle/service/nvnflinger/pixel_format.h" +#include "core/hle/service/nvnflinger/status.h" +#include "core/hle/service/nvnflinger/window.h" namespace Service::android { diff --git a/src/core/hle/service/nvflinger/buffer_queue_defs.h b/src/core/hle/service/nvnflinger/buffer_queue_defs.h index 334445213..6fd3156f4 100644 --- a/src/core/hle/service/nvflinger/buffer_queue_defs.h +++ b/src/core/hle/service/nvnflinger/buffer_queue_defs.h @@ -9,7 +9,7 @@ #include <array> #include "common/common_types.h" -#include "core/hle/service/nvflinger/buffer_slot.h" +#include "core/hle/service/nvnflinger/buffer_slot.h" namespace Service::android::BufferQueueDefs { diff --git a/src/core/hle/service/nvflinger/buffer_queue_producer.cpp b/src/core/hle/service/nvnflinger/buffer_queue_producer.cpp index bcbe05b0d..cd0a13094 100644 --- a/src/core/hle/service/nvflinger/buffer_queue_producer.cpp +++ b/src/core/hle/service/nvnflinger/buffer_queue_producer.cpp @@ -8,18 +8,18 @@ #include "common/logging/log.h" #include "common/settings.h" #include "core/core.h" -#include "core/hle/kernel/hle_ipc.h" #include "core/hle/kernel/k_event.h" #include "core/hle/kernel/k_readable_event.h" #include "core/hle/kernel/kernel.h" +#include "core/hle/service/hle_ipc.h" #include "core/hle/service/kernel_helpers.h" #include "core/hle/service/nvdrv/core/nvmap.h" -#include "core/hle/service/nvflinger/buffer_queue_core.h" -#include "core/hle/service/nvflinger/buffer_queue_producer.h" -#include "core/hle/service/nvflinger/consumer_listener.h" -#include "core/hle/service/nvflinger/parcel.h" -#include "core/hle/service/nvflinger/ui/graphic_buffer.h" -#include "core/hle/service/nvflinger/window.h" +#include "core/hle/service/nvnflinger/buffer_queue_core.h" +#include "core/hle/service/nvnflinger/buffer_queue_producer.h" +#include "core/hle/service/nvnflinger/consumer_listener.h" +#include "core/hle/service/nvnflinger/parcel.h" +#include "core/hle/service/nvnflinger/ui/graphic_buffer.h" +#include "core/hle/service/nvnflinger/window.h" #include "core/hle/service/vi/vi.h" namespace Service::android { @@ -37,20 +37,20 @@ BufferQueueProducer::~BufferQueueProducer() { } Status BufferQueueProducer::RequestBuffer(s32 slot, std::shared_ptr<GraphicBuffer>* buf) { - LOG_DEBUG(Service_NVFlinger, "slot {}", slot); + LOG_DEBUG(Service_Nvnflinger, "slot {}", slot); std::scoped_lock lock{core->mutex}; if (core->is_abandoned) { - LOG_ERROR(Service_NVFlinger, "BufferQueue has been abandoned"); + LOG_ERROR(Service_Nvnflinger, "BufferQueue has been abandoned"); return Status::NoInit; } if (slot < 0 || slot >= BufferQueueDefs::NUM_BUFFER_SLOTS) { - LOG_ERROR(Service_NVFlinger, "slot index {} out of range [0, {})", slot, + LOG_ERROR(Service_Nvnflinger, "slot index {} out of range [0, {})", slot, BufferQueueDefs::NUM_BUFFER_SLOTS); return Status::BadValue; } else if (slots[slot].buffer_state != BufferState::Dequeued) { - LOG_ERROR(Service_NVFlinger, "slot {} is not owned by the producer (state = {})", slot, + LOG_ERROR(Service_Nvnflinger, "slot {} is not owned by the producer (state = {})", slot, slots[slot].buffer_state); return Status::BadValue; } @@ -62,7 +62,7 @@ Status BufferQueueProducer::RequestBuffer(s32 slot, std::shared_ptr<GraphicBuffe } Status BufferQueueProducer::SetBufferCount(s32 buffer_count) { - LOG_DEBUG(Service_NVFlinger, "count = {}", buffer_count); + LOG_DEBUG(Service_Nvnflinger, "count = {}", buffer_count); std::shared_ptr<IConsumerListener> listener; { @@ -70,12 +70,12 @@ Status BufferQueueProducer::SetBufferCount(s32 buffer_count) { core->WaitWhileAllocatingLocked(); if (core->is_abandoned) { - LOG_ERROR(Service_NVFlinger, "BufferQueue has been abandoned"); + LOG_ERROR(Service_Nvnflinger, "BufferQueue has been abandoned"); return Status::NoInit; } if (buffer_count > BufferQueueDefs::NUM_BUFFER_SLOTS) { - LOG_ERROR(Service_NVFlinger, "buffer_count {} too large (max {})", buffer_count, + LOG_ERROR(Service_Nvnflinger, "buffer_count {} too large (max {})", buffer_count, BufferQueueDefs::NUM_BUFFER_SLOTS); return Status::BadValue; } @@ -83,7 +83,7 @@ Status BufferQueueProducer::SetBufferCount(s32 buffer_count) { // There must be no dequeued buffers when changing the buffer count. for (s32 s{}; s < BufferQueueDefs::NUM_BUFFER_SLOTS; ++s) { if (slots[s].buffer_state == BufferState::Dequeued) { - LOG_ERROR(Service_NVFlinger, "buffer owned by producer"); + LOG_ERROR(Service_Nvnflinger, "buffer owned by producer"); return Status::BadValue; } } @@ -96,7 +96,7 @@ Status BufferQueueProducer::SetBufferCount(s32 buffer_count) { const s32 min_buffer_slots = core->GetMinMaxBufferCountLocked(false); if (buffer_count < min_buffer_slots) { - LOG_ERROR(Service_NVFlinger, "requested buffer count {} is less than minimum {}", + LOG_ERROR(Service_Nvnflinger, "requested buffer count {} is less than minimum {}", buffer_count, min_buffer_slots); return Status::BadValue; } @@ -127,14 +127,14 @@ Status BufferQueueProducer::WaitForFreeSlotThenRelock(bool async, s32* found, St while (try_again) { if (core->is_abandoned) { - LOG_ERROR(Service_NVFlinger, "BufferQueue has been abandoned"); + LOG_ERROR(Service_Nvnflinger, "BufferQueue has been abandoned"); return Status::NoInit; } const s32 max_buffer_count = core->GetMaxBufferCountLocked(async); if (async && core->override_max_buffer_count) { if (core->override_max_buffer_count < max_buffer_count) { - LOG_ERROR(Service_NVFlinger, "async mode is invalid with buffer count override"); + LOG_ERROR(Service_Nvnflinger, "async mode is invalid with buffer count override"); return Status::BadValue; } } @@ -176,7 +176,7 @@ Status BufferQueueProducer::WaitForFreeSlotThenRelock(bool async, s32* found, St // Producers are not allowed to dequeue more than one buffer if they did not set a buffer // count if (!core->override_max_buffer_count && dequeued_count) { - LOG_ERROR(Service_NVFlinger, + LOG_ERROR(Service_Nvnflinger, "can't dequeue multiple buffers without setting the buffer count"); return Status::InvalidOperation; } @@ -188,7 +188,7 @@ Status BufferQueueProducer::WaitForFreeSlotThenRelock(bool async, s32* found, St const s32 new_undequeued_count = max_buffer_count - (dequeued_count + 1); const s32 min_undequeued_count = core->GetMinUndequeuedBufferCountLocked(async); if (new_undequeued_count < min_undequeued_count) { - LOG_ERROR(Service_NVFlinger, + LOG_ERROR(Service_Nvnflinger, "min undequeued buffer count({}) exceeded (dequeued={} undequeued={})", min_undequeued_count, dequeued_count, new_undequeued_count); return Status::InvalidOperation; @@ -200,7 +200,7 @@ Status BufferQueueProducer::WaitForFreeSlotThenRelock(bool async, s32* found, St // outrun the consumer. Wait here if it looks like we have too many buffers queued up. const bool too_many_buffers = core->queue.size() > static_cast<size_t>(max_buffer_count); if (too_many_buffers) { - LOG_ERROR(Service_NVFlinger, "queue size is {}, waiting", core->queue.size()); + LOG_ERROR(Service_Nvnflinger, "queue size is {}, waiting", core->queue.size()); } // If no buffer is found, or if the queue has too many buffers outstanding, wait for a @@ -226,11 +226,11 @@ Status BufferQueueProducer::WaitForFreeSlotThenRelock(bool async, s32* found, St Status BufferQueueProducer::DequeueBuffer(s32* out_slot, Fence* out_fence, bool async, u32 width, u32 height, PixelFormat format, u32 usage) { - LOG_DEBUG(Service_NVFlinger, "async={} w={} h={} format={}, usage={}", async ? "true" : "false", - width, height, format, usage); + LOG_DEBUG(Service_Nvnflinger, "async={} w={} h={} format={}, usage={}", + async ? "true" : "false", width, height, format, usage); if ((width != 0 && height == 0) || (width == 0 && height != 0)) { - LOG_ERROR(Service_NVFlinger, "invalid size: w={} h={}", width, height); + LOG_ERROR(Service_Nvnflinger, "invalid size: w={} h={}", width, height); return Status::BadValue; } @@ -255,7 +255,7 @@ Status BufferQueueProducer::DequeueBuffer(s32* out_slot, Fence* out_fence, bool // This should not happen if (found == BufferQueueCore::INVALID_BUFFER_SLOT) { - LOG_ERROR(Service_NVFlinger, "no available buffer slots"); + LOG_ERROR(Service_Nvnflinger, "no available buffer slots"); return Status::Busy; } @@ -287,11 +287,11 @@ Status BufferQueueProducer::DequeueBuffer(s32* out_slot, Fence* out_fence, bool } if ((return_flags & Status::BufferNeedsReallocation) != Status::None) { - LOG_DEBUG(Service_NVFlinger, "allocating a new buffer for slot {}", *out_slot); + LOG_DEBUG(Service_Nvnflinger, "allocating a new buffer for slot {}", *out_slot); auto graphic_buffer = std::make_shared<GraphicBuffer>(width, height, format, usage); if (graphic_buffer == nullptr) { - LOG_ERROR(Service_NVFlinger, "creating GraphicBuffer failed"); + LOG_ERROR(Service_Nvnflinger, "creating GraphicBuffer failed"); return Status::NoMemory; } @@ -299,7 +299,7 @@ Status BufferQueueProducer::DequeueBuffer(s32* out_slot, Fence* out_fence, bool std::scoped_lock lock{core->mutex}; if (core->is_abandoned) { - LOG_ERROR(Service_NVFlinger, "BufferQueue has been abandoned"); + LOG_ERROR(Service_Nvnflinger, "BufferQueue has been abandoned"); return Status::NoInit; } @@ -312,32 +312,32 @@ Status BufferQueueProducer::DequeueBuffer(s32* out_slot, Fence* out_fence, bool return_flags |= Status::BufferNeedsReallocation; } - LOG_DEBUG(Service_NVFlinger, "returning slot={} frame={}, flags={}", *out_slot, + LOG_DEBUG(Service_Nvnflinger, "returning slot={} frame={}, flags={}", *out_slot, slots[*out_slot].frame_number, return_flags); return return_flags; } Status BufferQueueProducer::DetachBuffer(s32 slot) { - LOG_DEBUG(Service_NVFlinger, "slot {}", slot); + LOG_DEBUG(Service_Nvnflinger, "slot {}", slot); std::scoped_lock lock{core->mutex}; if (core->is_abandoned) { - LOG_ERROR(Service_NVFlinger, "BufferQueue has been abandoned"); + LOG_ERROR(Service_Nvnflinger, "BufferQueue has been abandoned"); return Status::NoInit; } if (slot < 0 || slot >= BufferQueueDefs::NUM_BUFFER_SLOTS) { - LOG_ERROR(Service_NVFlinger, "slot {} out of range [0, {})", slot, + LOG_ERROR(Service_Nvnflinger, "slot {} out of range [0, {})", slot, BufferQueueDefs::NUM_BUFFER_SLOTS); return Status::BadValue; } else if (slots[slot].buffer_state != BufferState::Dequeued) { - LOG_ERROR(Service_NVFlinger, "slot {} is not owned by the producer (state = {})", slot, + LOG_ERROR(Service_Nvnflinger, "slot {} is not owned by the producer (state = {})", slot, slots[slot].buffer_state); return Status::BadValue; } else if (!slots[slot].request_buffer_called) { - LOG_ERROR(Service_NVFlinger, "buffer in slot {} has not been requested", slot); + LOG_ERROR(Service_Nvnflinger, "buffer in slot {} has not been requested", slot); return Status::BadValue; } @@ -350,10 +350,10 @@ Status BufferQueueProducer::DetachBuffer(s32 slot) { Status BufferQueueProducer::DetachNextBuffer(std::shared_ptr<GraphicBuffer>* out_buffer, Fence* out_fence) { if (out_buffer == nullptr) { - LOG_ERROR(Service_NVFlinger, "out_buffer must not be nullptr"); + LOG_ERROR(Service_Nvnflinger, "out_buffer must not be nullptr"); return Status::BadValue; } else if (out_fence == nullptr) { - LOG_ERROR(Service_NVFlinger, "out_fence must not be nullptr"); + LOG_ERROR(Service_Nvnflinger, "out_fence must not be nullptr"); return Status::BadValue; } @@ -361,7 +361,7 @@ Status BufferQueueProducer::DetachNextBuffer(std::shared_ptr<GraphicBuffer>* out core->WaitWhileAllocatingLocked(); if (core->is_abandoned) { - LOG_ERROR(Service_NVFlinger, "BufferQueue has been abandoned"); + LOG_ERROR(Service_Nvnflinger, "BufferQueue has been abandoned"); return Status::NoInit; } @@ -380,7 +380,7 @@ Status BufferQueueProducer::DetachNextBuffer(std::shared_ptr<GraphicBuffer>* out return Status::NoMemory; } - LOG_DEBUG(Service_NVFlinger, "Detached slot {}", found); + LOG_DEBUG(Service_Nvnflinger, "Detached slot {}", found); *out_buffer = slots[found].graphic_buffer; *out_fence = slots[found].fence; @@ -393,10 +393,10 @@ Status BufferQueueProducer::DetachNextBuffer(std::shared_ptr<GraphicBuffer>* out Status BufferQueueProducer::AttachBuffer(s32* out_slot, const std::shared_ptr<GraphicBuffer>& buffer) { if (out_slot == nullptr) { - LOG_ERROR(Service_NVFlinger, "out_slot must not be nullptr"); + LOG_ERROR(Service_Nvnflinger, "out_slot must not be nullptr"); return Status::BadValue; } else if (buffer == nullptr) { - LOG_ERROR(Service_NVFlinger, "Cannot attach nullptr buffer"); + LOG_ERROR(Service_Nvnflinger, "Cannot attach nullptr buffer"); return Status::BadValue; } @@ -413,13 +413,13 @@ Status BufferQueueProducer::AttachBuffer(s32* out_slot, // This should not happen if (found == BufferQueueCore::INVALID_BUFFER_SLOT) { - LOG_ERROR(Service_NVFlinger, "No available buffer slots"); + LOG_ERROR(Service_Nvnflinger, "No available buffer slots"); return Status::Busy; } *out_slot = found; - LOG_DEBUG(Service_NVFlinger, "Returning slot {} flags={}", *out_slot, return_flags); + LOG_DEBUG(Service_Nvnflinger, "Returning slot {} flags={}", *out_slot, return_flags); slots[*out_slot].graphic_buffer = buffer; slots[*out_slot].buffer_state = BufferState::Dequeued; @@ -451,7 +451,7 @@ Status BufferQueueProducer::QueueBuffer(s32 slot, const QueueBufferInput& input, case NativeWindowScalingMode::NoScaleCrop: break; default: - LOG_ERROR(Service_NVFlinger, "unknown scaling mode {}", scaling_mode); + LOG_ERROR(Service_Nvnflinger, "unknown scaling mode {}", scaling_mode); return Status::BadValue; } @@ -464,38 +464,38 @@ Status BufferQueueProducer::QueueBuffer(s32 slot, const QueueBufferInput& input, std::scoped_lock lock{core->mutex}; if (core->is_abandoned) { - LOG_ERROR(Service_NVFlinger, "BufferQueue has been abandoned"); + LOG_ERROR(Service_Nvnflinger, "BufferQueue has been abandoned"); return Status::NoInit; } const s32 max_buffer_count = core->GetMaxBufferCountLocked(async); if (async && core->override_max_buffer_count) { if (core->override_max_buffer_count < max_buffer_count) { - LOG_ERROR(Service_NVFlinger, "async mode is invalid with " - "buffer count override"); + LOG_ERROR(Service_Nvnflinger, "async mode is invalid with " + "buffer count override"); return Status::BadValue; } } if (slot < 0 || slot >= max_buffer_count) { - LOG_ERROR(Service_NVFlinger, "slot index {} out of range [0, {})", slot, + LOG_ERROR(Service_Nvnflinger, "slot index {} out of range [0, {})", slot, max_buffer_count); return Status::BadValue; } else if (slots[slot].buffer_state != BufferState::Dequeued) { - LOG_ERROR(Service_NVFlinger, + LOG_ERROR(Service_Nvnflinger, "slot {} is not owned by the producer " "(state = {})", slot, slots[slot].buffer_state); return Status::BadValue; } else if (!slots[slot].request_buffer_called) { - LOG_ERROR(Service_NVFlinger, + LOG_ERROR(Service_Nvnflinger, "slot {} was queued without requesting " "a buffer", slot); return Status::BadValue; } - LOG_DEBUG(Service_NVFlinger, + LOG_DEBUG(Service_Nvnflinger, "slot={} frame={} time={} crop=[{},{},{},{}] transform={} scale={}", slot, core->frame_counter + 1, timestamp, crop.Left(), crop.Top(), crop.Right(), crop.Bottom(), transform, scaling_mode); @@ -506,7 +506,7 @@ Status BufferQueueProducer::QueueBuffer(s32 slot, const QueueBufferInput& input, [[maybe_unused]] const bool unused = crop.Intersect(buffer_rect, &cropped_rect); if (cropped_rect != crop) { - LOG_ERROR(Service_NVFlinger, "crop rect is not contained within the buffer in slot {}", + LOG_ERROR(Service_Nvnflinger, "crop rect is not contained within the buffer in slot {}", slot); return Status::BadValue; } @@ -598,21 +598,21 @@ Status BufferQueueProducer::QueueBuffer(s32 slot, const QueueBufferInput& input, } void BufferQueueProducer::CancelBuffer(s32 slot, const Fence& fence) { - LOG_DEBUG(Service_NVFlinger, "slot {}", slot); + LOG_DEBUG(Service_Nvnflinger, "slot {}", slot); std::scoped_lock lock{core->mutex}; if (core->is_abandoned) { - LOG_ERROR(Service_NVFlinger, "BufferQueue has been abandoned"); + LOG_ERROR(Service_Nvnflinger, "BufferQueue has been abandoned"); return; } if (slot < 0 || slot >= BufferQueueDefs::NUM_BUFFER_SLOTS) { - LOG_ERROR(Service_NVFlinger, "slot index {} out of range [0, {})", slot, + LOG_ERROR(Service_Nvnflinger, "slot index {} out of range [0, {})", slot, BufferQueueDefs::NUM_BUFFER_SLOTS); return; } else if (slots[slot].buffer_state != BufferState::Dequeued) { - LOG_ERROR(Service_NVFlinger, "slot {} is not owned by the producer (state = {})", slot, + LOG_ERROR(Service_Nvnflinger, "slot {} is not owned by the producer (state = {})", slot, slots[slot].buffer_state); return; } @@ -629,12 +629,12 @@ Status BufferQueueProducer::Query(NativeWindow what, s32* out_value) { std::scoped_lock lock{core->mutex}; if (out_value == nullptr) { - LOG_ERROR(Service_NVFlinger, "outValue was nullptr"); + LOG_ERROR(Service_Nvnflinger, "outValue was nullptr"); return Status::BadValue; } if (core->is_abandoned) { - LOG_ERROR(Service_NVFlinger, "BufferQueue has been abandoned"); + LOG_ERROR(Service_Nvnflinger, "BufferQueue has been abandoned"); return Status::NoInit; } @@ -666,7 +666,7 @@ Status BufferQueueProducer::Query(NativeWindow what, s32* out_value) { return Status::BadValue; } - LOG_DEBUG(Service_NVFlinger, "what = {}, value = {}", what, value); + LOG_DEBUG(Service_Nvnflinger, "what = {}, value = {}", what, value); *out_value = static_cast<s32>(value); @@ -678,26 +678,26 @@ Status BufferQueueProducer::Connect(const std::shared_ptr<IProducerListener>& li QueueBufferOutput* output) { std::scoped_lock lock{core->mutex}; - LOG_DEBUG(Service_NVFlinger, "api = {} producer_controlled_by_app = {}", api, + LOG_DEBUG(Service_Nvnflinger, "api = {} producer_controlled_by_app = {}", api, producer_controlled_by_app); if (core->is_abandoned) { - LOG_ERROR(Service_NVFlinger, "BufferQueue has been abandoned"); + LOG_ERROR(Service_Nvnflinger, "BufferQueue has been abandoned"); return Status::NoInit; } if (core->consumer_listener == nullptr) { - LOG_ERROR(Service_NVFlinger, "BufferQueue has no consumer"); + LOG_ERROR(Service_Nvnflinger, "BufferQueue has no consumer"); return Status::NoInit; } if (output == nullptr) { - LOG_ERROR(Service_NVFlinger, "output was nullptr"); + LOG_ERROR(Service_Nvnflinger, "output was nullptr"); return Status::BadValue; } if (core->connected_api != NativeWindowApi::NoConnectedApi) { - LOG_ERROR(Service_NVFlinger, "already connected (cur = {} req = {})", core->connected_api, + LOG_ERROR(Service_Nvnflinger, "already connected (cur = {} req = {})", core->connected_api, api); return Status::BadValue; } @@ -714,7 +714,7 @@ Status BufferQueueProducer::Connect(const std::shared_ptr<IProducerListener>& li core->connected_producer_listener = listener; break; default: - LOG_ERROR(Service_NVFlinger, "unknown api = {}", api); + LOG_ERROR(Service_Nvnflinger, "unknown api = {}", api); status = Status::BadValue; break; } @@ -727,7 +727,7 @@ Status BufferQueueProducer::Connect(const std::shared_ptr<IProducerListener>& li } Status BufferQueueProducer::Disconnect(NativeWindowApi api) { - LOG_DEBUG(Service_NVFlinger, "api = {}", api); + LOG_DEBUG(Service_Nvnflinger, "api = {}", api); Status status = Status::NoError; std::shared_ptr<IConsumerListener> listener; @@ -762,13 +762,13 @@ Status BufferQueueProducer::Disconnect(NativeWindowApi api) { buffer_wait_event->Signal(); listener = core->consumer_listener; } else { - LOG_ERROR(Service_NVFlinger, "still connected to another api (cur = {} req = {})", + LOG_ERROR(Service_Nvnflinger, "still connected to another api (cur = {} req = {})", core->connected_api, api); status = Status::BadValue; } break; default: - LOG_ERROR(Service_NVFlinger, "unknown api = {}", api); + LOG_ERROR(Service_Nvnflinger, "unknown api = {}", api); status = Status::BadValue; break; } @@ -784,7 +784,7 @@ Status BufferQueueProducer::Disconnect(NativeWindowApi api) { Status BufferQueueProducer::SetPreallocatedBuffer(s32 slot, const std::shared_ptr<GraphicBuffer>& buffer) { - LOG_DEBUG(Service_NVFlinger, "slot {}", slot); + LOG_DEBUG(Service_Nvnflinger, "slot {}", slot); if (slot < 0 || slot >= BufferQueueDefs::NUM_BUFFER_SLOTS) { return Status::BadValue; @@ -813,7 +813,7 @@ Status BufferQueueProducer::SetPreallocatedBuffer(s32 slot, return Status::NoError; } -void BufferQueueProducer::Transact(Kernel::HLERequestContext& ctx, TransactionId code, u32 flags) { +void BufferQueueProducer::Transact(HLERequestContext& ctx, TransactionId code, u32 flags) { Status status{Status::NoError}; InputParcel parcel_in{ctx.ReadBuffer()}; OutputParcel parcel_out{}; @@ -914,7 +914,7 @@ void BufferQueueProducer::Transact(Kernel::HLERequestContext& ctx, TransactionId break; } case TransactionId::GetBufferHistory: - LOG_WARNING(Service_NVFlinger, "(STUBBED) called, transaction=GetBufferHistory"); + LOG_WARNING(Service_Nvnflinger, "(STUBBED) called, transaction=GetBufferHistory"); break; default: ASSERT_MSG(false, "Unimplemented TransactionId {}", code); diff --git a/src/core/hle/service/nvflinger/buffer_queue_producer.h b/src/core/hle/service/nvnflinger/buffer_queue_producer.h index 1d380480f..d4201c104 100644 --- a/src/core/hle/service/nvflinger/buffer_queue_producer.h +++ b/src/core/hle/service/nvnflinger/buffer_queue_producer.h @@ -12,13 +12,13 @@ #include "common/common_funcs.h" #include "core/hle/service/nvdrv/nvdata.h" -#include "core/hle/service/nvflinger/binder.h" -#include "core/hle/service/nvflinger/buffer_queue_defs.h" -#include "core/hle/service/nvflinger/buffer_slot.h" -#include "core/hle/service/nvflinger/graphic_buffer_producer.h" -#include "core/hle/service/nvflinger/pixel_format.h" -#include "core/hle/service/nvflinger/status.h" -#include "core/hle/service/nvflinger/window.h" +#include "core/hle/service/nvnflinger/binder.h" +#include "core/hle/service/nvnflinger/buffer_queue_defs.h" +#include "core/hle/service/nvnflinger/buffer_slot.h" +#include "core/hle/service/nvnflinger/graphic_buffer_producer.h" +#include "core/hle/service/nvnflinger/pixel_format.h" +#include "core/hle/service/nvnflinger/status.h" +#include "core/hle/service/nvnflinger/window.h" namespace Kernel { class KernelCore; @@ -46,7 +46,7 @@ public: Service::Nvidia::NvCore::NvMap& nvmap_); ~BufferQueueProducer(); - void Transact(Kernel::HLERequestContext& ctx, android::TransactionId code, u32 flags) override; + void Transact(HLERequestContext& ctx, android::TransactionId code, u32 flags) override; Kernel::KReadableEvent& GetNativeHandle() override; diff --git a/src/core/hle/service/nvflinger/buffer_slot.h b/src/core/hle/service/nvnflinger/buffer_slot.h index 0cd0e9964..d25bca049 100644 --- a/src/core/hle/service/nvflinger/buffer_slot.h +++ b/src/core/hle/service/nvnflinger/buffer_slot.h @@ -9,7 +9,7 @@ #include <memory> #include "common/common_types.h" -#include "core/hle/service/nvflinger/ui/fence.h" +#include "core/hle/service/nvnflinger/ui/fence.h" namespace Service::android { diff --git a/src/core/hle/service/nvflinger/buffer_transform_flags.h b/src/core/hle/service/nvnflinger/buffer_transform_flags.h index 67aa5dad6..67aa5dad6 100644 --- a/src/core/hle/service/nvflinger/buffer_transform_flags.h +++ b/src/core/hle/service/nvnflinger/buffer_transform_flags.h diff --git a/src/core/hle/service/nvflinger/consumer_base.cpp b/src/core/hle/service/nvnflinger/consumer_base.cpp index 982531e2d..4dcda8dac 100644 --- a/src/core/hle/service/nvflinger/consumer_base.cpp +++ b/src/core/hle/service/nvnflinger/consumer_base.cpp @@ -6,11 +6,11 @@ #include "common/assert.h" #include "common/logging/log.h" -#include "core/hle/service/nvflinger/buffer_item.h" -#include "core/hle/service/nvflinger/buffer_queue_consumer.h" -#include "core/hle/service/nvflinger/buffer_queue_core.h" -#include "core/hle/service/nvflinger/consumer_base.h" -#include "core/hle/service/nvflinger/ui/graphic_buffer.h" +#include "core/hle/service/nvnflinger/buffer_item.h" +#include "core/hle/service/nvnflinger/buffer_queue_consumer.h" +#include "core/hle/service/nvnflinger/buffer_queue_core.h" +#include "core/hle/service/nvnflinger/consumer_base.h" +#include "core/hle/service/nvnflinger/ui/graphic_buffer.h" namespace Service::android { @@ -28,7 +28,7 @@ void ConsumerBase::Connect(bool controlled_by_app) { } void ConsumerBase::FreeBufferLocked(s32 slot_index) { - LOG_DEBUG(Service_NVFlinger, "slot_index={}", slot_index); + LOG_DEBUG(Service_Nvnflinger, "slot_index={}", slot_index); slots[slot_index].graphic_buffer = nullptr; slots[slot_index].fence = Fence::NoFence(); @@ -36,17 +36,17 @@ void ConsumerBase::FreeBufferLocked(s32 slot_index) { } void ConsumerBase::OnFrameAvailable(const BufferItem& item) { - LOG_DEBUG(Service_NVFlinger, "called"); + LOG_DEBUG(Service_Nvnflinger, "called"); } void ConsumerBase::OnFrameReplaced(const BufferItem& item) { - LOG_DEBUG(Service_NVFlinger, "called"); + LOG_DEBUG(Service_Nvnflinger, "called"); } void ConsumerBase::OnBuffersReleased() { std::scoped_lock lock{mutex}; - LOG_DEBUG(Service_NVFlinger, "called"); + LOG_DEBUG(Service_Nvnflinger, "called"); if (is_abandoned) { // Nothing to do if we're already abandoned. @@ -77,7 +77,7 @@ Status ConsumerBase::AcquireBufferLocked(BufferItem* item, std::chrono::nanoseco slots[item->slot].frame_number = item->frame_number; slots[item->slot].fence = item->fence; - LOG_DEBUG(Service_NVFlinger, "slot={}", item->slot); + LOG_DEBUG(Service_Nvnflinger, "slot={}", item->slot); return Status::NoError; } @@ -85,7 +85,7 @@ Status ConsumerBase::AcquireBufferLocked(BufferItem* item, std::chrono::nanoseco Status ConsumerBase::AddReleaseFenceLocked(s32 slot, const std::shared_ptr<GraphicBuffer>& graphic_buffer, const Fence& fence) { - LOG_DEBUG(Service_NVFlinger, "slot={}", slot); + LOG_DEBUG(Service_Nvnflinger, "slot={}", slot); // If consumer no longer tracks this graphic_buffer, we can safely // drop this fence, as it will never be received by the producer. @@ -109,7 +109,7 @@ Status ConsumerBase::ReleaseBufferLocked(s32 slot, return Status::NoError; } - LOG_DEBUG(Service_NVFlinger, "slot={}", slot); + LOG_DEBUG(Service_Nvnflinger, "slot={}", slot); Status err = consumer->ReleaseBuffer(slot, slots[slot].frame_number, slots[slot].fence); if (err == Status::StaleBufferSlot) { FreeBufferLocked(slot); diff --git a/src/core/hle/service/nvflinger/consumer_base.h b/src/core/hle/service/nvnflinger/consumer_base.h index 9a8a5f6bb..264829414 100644 --- a/src/core/hle/service/nvflinger/consumer_base.h +++ b/src/core/hle/service/nvnflinger/consumer_base.h @@ -12,9 +12,9 @@ #include <mutex> #include "common/common_types.h" -#include "core/hle/service/nvflinger/buffer_queue_defs.h" -#include "core/hle/service/nvflinger/consumer_listener.h" -#include "core/hle/service/nvflinger/status.h" +#include "core/hle/service/nvnflinger/buffer_queue_defs.h" +#include "core/hle/service/nvnflinger/consumer_listener.h" +#include "core/hle/service/nvnflinger/status.h" namespace Service::android { diff --git a/src/core/hle/service/nvflinger/consumer_listener.h b/src/core/hle/service/nvnflinger/consumer_listener.h index 74a193988..74a193988 100644 --- a/src/core/hle/service/nvflinger/consumer_listener.h +++ b/src/core/hle/service/nvnflinger/consumer_listener.h diff --git a/src/core/hle/service/nvflinger/graphic_buffer_producer.cpp b/src/core/hle/service/nvnflinger/graphic_buffer_producer.cpp index 769e8c0a3..d72b49a8e 100644 --- a/src/core/hle/service/nvflinger/graphic_buffer_producer.cpp +++ b/src/core/hle/service/nvnflinger/graphic_buffer_producer.cpp @@ -4,8 +4,8 @@ // Parts of this implementation were based on: // https://cs.android.com/android/platform/superproject/+/android-5.1.1_r38:frameworks/native/libs/gui/IGraphicBufferProducer.cpp -#include "core/hle/service/nvflinger/graphic_buffer_producer.h" -#include "core/hle/service/nvflinger/parcel.h" +#include "core/hle/service/nvnflinger/graphic_buffer_producer.h" +#include "core/hle/service/nvnflinger/parcel.h" namespace Service::android { diff --git a/src/core/hle/service/nvflinger/graphic_buffer_producer.h b/src/core/hle/service/nvnflinger/graphic_buffer_producer.h index 2969f0fd5..21d7b31f3 100644 --- a/src/core/hle/service/nvflinger/graphic_buffer_producer.h +++ b/src/core/hle/service/nvnflinger/graphic_buffer_producer.h @@ -9,8 +9,8 @@ #include "common/common_funcs.h" #include "common/common_types.h" #include "common/math_util.h" -#include "core/hle/service/nvflinger/ui/fence.h" -#include "core/hle/service/nvflinger/window.h" +#include "core/hle/service/nvnflinger/ui/fence.h" +#include "core/hle/service/nvnflinger/window.h" namespace Service::android { diff --git a/src/core/hle/service/nvflinger/hos_binder_driver_server.cpp b/src/core/hle/service/nvnflinger/hos_binder_driver_server.cpp index dc9b2a9ec..b86a79ec9 100644 --- a/src/core/hle/service/nvflinger/hos_binder_driver_server.cpp +++ b/src/core/hle/service/nvnflinger/hos_binder_driver_server.cpp @@ -4,9 +4,9 @@ #include <mutex> #include "common/common_types.h" -#include "core/hle/service/nvflinger/hos_binder_driver_server.h" +#include "core/hle/service/nvnflinger/hos_binder_driver_server.h" -namespace Service::NVFlinger { +namespace Service::Nvnflinger { HosBinderDriverServer::HosBinderDriverServer(Core::System& system_) : service_context(system_, "HosBinderDriverServer") {} @@ -33,4 +33,4 @@ android::IBinder* HosBinderDriverServer::TryGetProducer(u64 id) { return {}; } -} // namespace Service::NVFlinger +} // namespace Service::Nvnflinger diff --git a/src/core/hle/service/nvflinger/hos_binder_driver_server.h b/src/core/hle/service/nvnflinger/hos_binder_driver_server.h index 8fddc1206..58bb9469a 100644 --- a/src/core/hle/service/nvflinger/hos_binder_driver_server.h +++ b/src/core/hle/service/nvnflinger/hos_binder_driver_server.h @@ -9,13 +9,13 @@ #include "common/common_types.h" #include "core/hle/service/kernel_helpers.h" -#include "core/hle/service/nvflinger/binder.h" +#include "core/hle/service/nvnflinger/binder.h" namespace Core { class System; } -namespace Service::NVFlinger { +namespace Service::Nvnflinger { class HosBinderDriverServer final { public: @@ -34,4 +34,4 @@ private: u64 last_id{}; }; -} // namespace Service::NVFlinger +} // namespace Service::Nvnflinger diff --git a/src/core/hle/service/nvflinger/nvflinger.cpp b/src/core/hle/service/nvnflinger/nvnflinger.cpp index f4416f5b2..4988e6e17 100644 --- a/src/core/hle/service/nvflinger/nvflinger.cpp +++ b/src/core/hle/service/nvnflinger/nvnflinger.cpp @@ -15,11 +15,11 @@ #include "core/hle/kernel/k_readable_event.h" #include "core/hle/service/nvdrv/devices/nvdisp_disp0.h" #include "core/hle/service/nvdrv/nvdrv.h" -#include "core/hle/service/nvflinger/buffer_item_consumer.h" -#include "core/hle/service/nvflinger/buffer_queue_core.h" -#include "core/hle/service/nvflinger/hos_binder_driver_server.h" -#include "core/hle/service/nvflinger/nvflinger.h" -#include "core/hle/service/nvflinger/ui/graphic_buffer.h" +#include "core/hle/service/nvnflinger/buffer_item_consumer.h" +#include "core/hle/service/nvnflinger/buffer_queue_core.h" +#include "core/hle/service/nvnflinger/hos_binder_driver_server.h" +#include "core/hle/service/nvnflinger/nvnflinger.h" +#include "core/hle/service/nvnflinger/ui/graphic_buffer.h" #include "core/hle/service/vi/display/vi_display.h" #include "core/hle/service/vi/layer/vi_layer.h" #include "core/hle/service/vi/vi_results.h" @@ -27,11 +27,11 @@ #include "video_core/host1x/host1x.h" #include "video_core/host1x/syncpoint_manager.h" -namespace Service::NVFlinger { +namespace Service::Nvnflinger { constexpr auto frame_ns = std::chrono::nanoseconds{1000000000 / 60}; -void NVFlinger::SplitVSync(std::stop_token stop_token) { +void Nvnflinger::SplitVSync(std::stop_token stop_token) { system.RegisterHostThread(); std::string name = "VSyncThread"; MicroProfileOnThreadCreate(name.c_str()); @@ -54,8 +54,8 @@ void NVFlinger::SplitVSync(std::stop_token stop_token) { } } -NVFlinger::NVFlinger(Core::System& system_, HosBinderDriverServer& hos_binder_driver_server_) - : system(system_), service_context(system_, "nvflinger"), +Nvnflinger::Nvnflinger(Core::System& system_, HosBinderDriverServer& hos_binder_driver_server_) + : system(system_), service_context(system_, "nvnflinger"), hos_binder_driver_server(hos_binder_driver_server_) { displays.emplace_back(0, "Default", hos_binder_driver_server, service_context, system); displays.emplace_back(1, "External", hos_binder_driver_server, service_context, system); @@ -92,7 +92,7 @@ NVFlinger::NVFlinger(Core::System& system_, HosBinderDriverServer& hos_binder_dr } } -NVFlinger::~NVFlinger() { +Nvnflinger::~Nvnflinger() { if (system.IsMulticore()) { system.CoreTiming().UnscheduleEvent(multi_composition_event, {}); vsync_thread.request_stop(); @@ -109,7 +109,7 @@ NVFlinger::~NVFlinger() { } } -void NVFlinger::ShutdownLayers() { +void Nvnflinger::ShutdownLayers() { for (auto& display : displays) { for (size_t layer = 0; layer < display.GetNumLayers(); ++layer) { display.GetLayer(layer).Core().NotifyShutdown(); @@ -117,15 +117,15 @@ void NVFlinger::ShutdownLayers() { } } -void NVFlinger::SetNVDrvInstance(std::shared_ptr<Nvidia::Module> instance) { +void Nvnflinger::SetNVDrvInstance(std::shared_ptr<Nvidia::Module> instance) { nvdrv = std::move(instance); disp_fd = nvdrv->Open("/dev/nvdisp_disp0"); } -std::optional<u64> NVFlinger::OpenDisplay(std::string_view name) { +std::optional<u64> Nvnflinger::OpenDisplay(std::string_view name) { const auto lock_guard = Lock(); - LOG_DEBUG(Service_NVFlinger, "Opening \"{}\" display", name); + LOG_DEBUG(Service_Nvnflinger, "Opening \"{}\" display", name); const auto itr = std::find_if(displays.begin(), displays.end(), @@ -138,7 +138,7 @@ std::optional<u64> NVFlinger::OpenDisplay(std::string_view name) { return itr->GetID(); } -bool NVFlinger::CloseDisplay(u64 display_id) { +bool Nvnflinger::CloseDisplay(u64 display_id) { const auto lock_guard = Lock(); auto* const display = FindDisplay(display_id); @@ -151,7 +151,7 @@ bool NVFlinger::CloseDisplay(u64 display_id) { return true; } -std::optional<u64> NVFlinger::CreateLayer(u64 display_id) { +std::optional<u64> Nvnflinger::CreateLayer(u64 display_id) { const auto lock_guard = Lock(); auto* const display = FindDisplay(display_id); @@ -164,12 +164,12 @@ std::optional<u64> NVFlinger::CreateLayer(u64 display_id) { return layer_id; } -void NVFlinger::CreateLayerAtId(VI::Display& display, u64 layer_id) { +void Nvnflinger::CreateLayerAtId(VI::Display& display, u64 layer_id) { const auto buffer_id = next_buffer_queue_id++; display.CreateLayer(layer_id, buffer_id, nvdrv->container); } -void NVFlinger::CloseLayer(u64 layer_id) { +void Nvnflinger::CloseLayer(u64 layer_id) { const auto lock_guard = Lock(); for (auto& display : displays) { @@ -177,7 +177,7 @@ void NVFlinger::CloseLayer(u64 layer_id) { } } -std::optional<u32> NVFlinger::FindBufferQueueId(u64 display_id, u64 layer_id) { +std::optional<u32> Nvnflinger::FindBufferQueueId(u64 display_id, u64 layer_id) { const auto lock_guard = Lock(); const auto* const layer = FindOrCreateLayer(display_id, layer_id); @@ -188,7 +188,7 @@ std::optional<u32> NVFlinger::FindBufferQueueId(u64 display_id, u64 layer_id) { return layer->GetBinderId(); } -ResultVal<Kernel::KReadableEvent*> NVFlinger::FindVsyncEvent(u64 display_id) { +ResultVal<Kernel::KReadableEvent*> Nvnflinger::FindVsyncEvent(u64 display_id) { const auto lock_guard = Lock(); auto* const display = FindDisplay(display_id); @@ -199,7 +199,7 @@ ResultVal<Kernel::KReadableEvent*> NVFlinger::FindVsyncEvent(u64 display_id) { return display->GetVSyncEvent(); } -VI::Display* NVFlinger::FindDisplay(u64 display_id) { +VI::Display* Nvnflinger::FindDisplay(u64 display_id) { const auto itr = std::find_if(displays.begin(), displays.end(), [&](const VI::Display& display) { return display.GetID() == display_id; }); @@ -211,7 +211,7 @@ VI::Display* NVFlinger::FindDisplay(u64 display_id) { return &*itr; } -const VI::Display* NVFlinger::FindDisplay(u64 display_id) const { +const VI::Display* Nvnflinger::FindDisplay(u64 display_id) const { const auto itr = std::find_if(displays.begin(), displays.end(), [&](const VI::Display& display) { return display.GetID() == display_id; }); @@ -223,7 +223,7 @@ const VI::Display* NVFlinger::FindDisplay(u64 display_id) const { return &*itr; } -VI::Layer* NVFlinger::FindLayer(u64 display_id, u64 layer_id) { +VI::Layer* Nvnflinger::FindLayer(u64 display_id, u64 layer_id) { auto* const display = FindDisplay(display_id); if (display == nullptr) { @@ -233,7 +233,7 @@ VI::Layer* NVFlinger::FindLayer(u64 display_id, u64 layer_id) { return display->FindLayer(layer_id); } -const VI::Layer* NVFlinger::FindLayer(u64 display_id, u64 layer_id) const { +const VI::Layer* Nvnflinger::FindLayer(u64 display_id, u64 layer_id) const { const auto* const display = FindDisplay(display_id); if (display == nullptr) { @@ -243,7 +243,7 @@ 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) { +VI::Layer* Nvnflinger::FindOrCreateLayer(u64 display_id, u64 layer_id) { auto* const display = FindDisplay(display_id); if (display == nullptr) { @@ -253,7 +253,7 @@ VI::Layer* NVFlinger::FindOrCreateLayer(u64 display_id, u64 layer_id) { auto* layer = display->FindLayer(layer_id); if (layer == nullptr) { - LOG_DEBUG(Service_NVFlinger, "Layer at id {} not found. Trying to create it.", layer_id); + LOG_DEBUG(Service_Nvnflinger, "Layer at id {} not found. Trying to create it.", layer_id); CreateLayerAtId(*display, layer_id); return display->FindLayer(layer_id); } @@ -261,7 +261,7 @@ VI::Layer* NVFlinger::FindOrCreateLayer(u64 display_id, u64 layer_id) { return layer; } -void NVFlinger::Compose() { +void Nvnflinger::Compose() { for (auto& display : displays) { // Trigger vsync for this display at the end of drawing SCOPE_EXIT({ display.SignalVSyncEvent(); }); @@ -311,7 +311,7 @@ void NVFlinger::Compose() { } } -s64 NVFlinger::GetNextTicks() const { +s64 Nvnflinger::GetNextTicks() const { const auto& settings = Settings::values; auto speed_scale = 1.f; if (settings.use_multi_core.GetValue()) { @@ -332,4 +332,4 @@ s64 NVFlinger::GetNextTicks() const { return static_cast<s64>(speed_scale * (1000000000.f / effective_fps)); } -} // namespace Service::NVFlinger +} // namespace Service::Nvnflinger diff --git a/src/core/hle/service/nvflinger/nvflinger.h b/src/core/hle/service/nvnflinger/nvnflinger.h index 3828cf272..a043cceb2 100644 --- a/src/core/hle/service/nvflinger/nvflinger.h +++ b/src/core/hle/service/nvnflinger/nvnflinger.h @@ -42,12 +42,12 @@ class BufferQueueCore; class BufferQueueProducer; } // namespace Service::android -namespace Service::NVFlinger { +namespace Service::Nvnflinger { -class NVFlinger final { +class Nvnflinger final { public: - explicit NVFlinger(Core::System& system_, HosBinderDriverServer& hos_binder_driver_server_); - ~NVFlinger(); + explicit Nvnflinger(Core::System& system_, HosBinderDriverServer& hos_binder_driver_server_); + ~Nvnflinger(); void ShutdownLayers(); @@ -152,4 +152,4 @@ private: HosBinderDriverServer& hos_binder_driver_server; }; -} // namespace Service::NVFlinger +} // namespace Service::Nvnflinger diff --git a/src/core/hle/service/nvflinger/parcel.h b/src/core/hle/service/nvnflinger/parcel.h index d1b6201e0..d1b6201e0 100644 --- a/src/core/hle/service/nvflinger/parcel.h +++ b/src/core/hle/service/nvnflinger/parcel.h diff --git a/src/core/hle/service/nvflinger/pixel_format.h b/src/core/hle/service/nvnflinger/pixel_format.h index f77d0acfb..f77d0acfb 100644 --- a/src/core/hle/service/nvflinger/pixel_format.h +++ b/src/core/hle/service/nvnflinger/pixel_format.h diff --git a/src/core/hle/service/nvflinger/producer_listener.h b/src/core/hle/service/nvnflinger/producer_listener.h index 6bf8aaf1e..6bf8aaf1e 100644 --- a/src/core/hle/service/nvflinger/producer_listener.h +++ b/src/core/hle/service/nvnflinger/producer_listener.h diff --git a/src/core/hle/service/nvflinger/status.h b/src/core/hle/service/nvnflinger/status.h index 7af166c40..7af166c40 100644 --- a/src/core/hle/service/nvflinger/status.h +++ b/src/core/hle/service/nvnflinger/status.h diff --git a/src/core/hle/service/nvflinger/ui/fence.h b/src/core/hle/service/nvnflinger/ui/fence.h index 536e8156d..536e8156d 100644 --- a/src/core/hle/service/nvflinger/ui/fence.h +++ b/src/core/hle/service/nvnflinger/ui/fence.h diff --git a/src/core/hle/service/nvflinger/ui/graphic_buffer.h b/src/core/hle/service/nvnflinger/ui/graphic_buffer.h index 9a27f8f02..75d1705a8 100644 --- a/src/core/hle/service/nvflinger/ui/graphic_buffer.h +++ b/src/core/hle/service/nvnflinger/ui/graphic_buffer.h @@ -8,7 +8,7 @@ #include "common/common_funcs.h" #include "common/common_types.h" -#include "core/hle/service/nvflinger/pixel_format.h" +#include "core/hle/service/nvnflinger/pixel_format.h" namespace Service::android { diff --git a/src/core/hle/service/nvflinger/window.h b/src/core/hle/service/nvnflinger/window.h index 61cca5b01..61cca5b01 100644 --- a/src/core/hle/service/nvflinger/window.h +++ b/src/core/hle/service/nvnflinger/window.h diff --git a/src/core/hle/service/olsc/olsc.cpp b/src/core/hle/service/olsc/olsc.cpp index 3493f8272..14ba67b4c 100644 --- a/src/core/hle/service/olsc/olsc.cpp +++ b/src/core/hle/service/olsc/olsc.cpp @@ -1,7 +1,7 @@ // SPDX-FileCopyrightText: Copyright 2020 yuzu Emulator Project // SPDX-License-Identifier: GPL-2.0-or-later -#include "core/hle/ipc_helpers.h" +#include "core/hle/service/ipc_helpers.h" #include "core/hle/service/olsc/olsc.h" #include "core/hle/service/server_manager.h" #include "core/hle/service/service.h" @@ -42,7 +42,7 @@ public: } private: - void Initialize(Kernel::HLERequestContext& ctx) { + void Initialize(HLERequestContext& ctx) { LOG_WARNING(Service_OLSC, "(STUBBED) called"); initialized = true; @@ -51,7 +51,7 @@ private: rb.Push(ResultSuccess); } - void GetSaveDataBackupSetting(Kernel::HLERequestContext& ctx) { + void GetSaveDataBackupSetting(HLERequestContext& ctx) { LOG_WARNING(Service_OLSC, "(STUBBED) called"); // backup_setting is set to 0 since real value is unknown @@ -62,7 +62,7 @@ private: rb.Push(backup_setting); } - void SetSaveDataBackupSettingEnabled(Kernel::HLERequestContext& ctx) { + void SetSaveDataBackupSettingEnabled(HLERequestContext& ctx) { LOG_WARNING(Service_OLSC, "(STUBBED) called"); IPC::ResponseBuilder rb{ctx, 2}; diff --git a/src/core/hle/service/pctl/pctl_module.cpp b/src/core/hle/service/pctl/pctl_module.cpp index a4a12a78c..f966c5c8b 100644 --- a/src/core/hle/service/pctl/pctl_module.cpp +++ b/src/core/hle/service/pctl/pctl_module.cpp @@ -5,7 +5,7 @@ #include "core/core.h" #include "core/file_sys/control_metadata.h" #include "core/file_sys/patch_manager.h" -#include "core/hle/ipc_helpers.h" +#include "core/hle/service/ipc_helpers.h" #include "core/hle/service/pctl/pctl.h" #include "core/hle/service/pctl/pctl_module.h" #include "core/hle/service/server_manager.h" @@ -177,7 +177,7 @@ private: settings.is_stero_vision_restricted = is_restricted; } - void Initialize(Kernel::HLERequestContext& ctx) { + void Initialize(HLERequestContext& ctx) { LOG_DEBUG(Service_PCTL, "called"); IPC::ResponseBuilder rb{ctx, 2}; @@ -215,7 +215,7 @@ private: rb.Push(ResultSuccess); } - void CheckFreeCommunicationPermission(Kernel::HLERequestContext& ctx) { + void CheckFreeCommunicationPermission(HLERequestContext& ctx) { LOG_DEBUG(Service_PCTL, "called"); IPC::ResponseBuilder rb{ctx, 2}; @@ -228,7 +228,7 @@ private: states.free_communication = true; } - void ConfirmStereoVisionPermission(Kernel::HLERequestContext& ctx) { + void ConfirmStereoVisionPermission(HLERequestContext& ctx) { LOG_DEBUG(Service_PCTL, "called"); states.stereo_vision = true; @@ -236,14 +236,14 @@ private: rb.Push(ResultSuccess); } - void EndFreeCommunication(Kernel::HLERequestContext& ctx) { + void EndFreeCommunication(HLERequestContext& ctx) { LOG_WARNING(Service_PCTL, "(STUBBED) called"); IPC::ResponseBuilder rb{ctx, 2}; rb.Push(ResultSuccess); } - void IsFreeCommunicationAvailable(Kernel::HLERequestContext& ctx) { + void IsFreeCommunicationAvailable(HLERequestContext& ctx) { LOG_WARNING(Service_PCTL, "(STUBBED) called"); IPC::ResponseBuilder rb{ctx, 2}; @@ -254,7 +254,7 @@ private: } } - void IsRestrictionEnabled(Kernel::HLERequestContext& ctx) { + void IsRestrictionEnabled(HLERequestContext& ctx) { LOG_DEBUG(Service_PCTL, "called"); IPC::ResponseBuilder rb{ctx, 3}; @@ -268,7 +268,7 @@ private: rb.Push(pin_code[0] != '\0'); } - void ConfirmStereoVisionRestrictionConfigurable(Kernel::HLERequestContext& ctx) { + void ConfirmStereoVisionRestrictionConfigurable(HLERequestContext& ctx) { LOG_DEBUG(Service_PCTL, "called"); IPC::ResponseBuilder rb{ctx, 2}; @@ -287,7 +287,7 @@ private: rb.Push(ResultSuccess); } - void IsStereoVisionPermitted(Kernel::HLERequestContext& ctx) { + void IsStereoVisionPermitted(HLERequestContext& ctx) { LOG_DEBUG(Service_PCTL, "called"); IPC::ResponseBuilder rb{ctx, 3}; @@ -300,7 +300,7 @@ private: } } - void SetStereoVisionRestriction(Kernel::HLERequestContext& ctx) { + void SetStereoVisionRestriction(HLERequestContext& ctx) { IPC::RequestParser rp{ctx}; const auto can_use = rp.Pop<bool>(); LOG_DEBUG(Service_PCTL, "called, can_use={}", can_use); @@ -316,7 +316,7 @@ private: rb.Push(ResultSuccess); } - void GetStereoVisionRestriction(Kernel::HLERequestContext& ctx) { + void GetStereoVisionRestriction(HLERequestContext& ctx) { LOG_DEBUG(Service_PCTL, "called"); IPC::ResponseBuilder rb{ctx, 3}; @@ -331,7 +331,7 @@ private: rb.Push(settings.is_stero_vision_restricted); } - void ResetConfirmedStereoVisionPermission(Kernel::HLERequestContext& ctx) { + void ResetConfirmedStereoVisionPermission(HLERequestContext& ctx) { LOG_DEBUG(Service_PCTL, "called"); states.stereo_vision = false; @@ -370,7 +370,7 @@ private: Capability capability{}; }; -void Module::Interface::CreateService(Kernel::HLERequestContext& ctx) { +void Module::Interface::CreateService(HLERequestContext& ctx) { LOG_DEBUG(Service_PCTL, "called"); IPC::ResponseBuilder rb{ctx, 2, 0, 1}; @@ -380,7 +380,7 @@ void Module::Interface::CreateService(Kernel::HLERequestContext& ctx) { rb.PushIpcInterface<IParentalControlService>(system, capability); } -void Module::Interface::CreateServiceWithoutInitialize(Kernel::HLERequestContext& ctx) { +void Module::Interface::CreateServiceWithoutInitialize(HLERequestContext& ctx) { LOG_DEBUG(Service_PCTL, "called"); IPC::ResponseBuilder rb{ctx, 2, 0, 1}; diff --git a/src/core/hle/service/pctl/pctl_module.h b/src/core/hle/service/pctl/pctl_module.h index 4ea77ab21..dff0d3f08 100644 --- a/src/core/hle/service/pctl/pctl_module.h +++ b/src/core/hle/service/pctl/pctl_module.h @@ -31,8 +31,8 @@ public: const char* name_, Capability capability_); ~Interface() override; - void CreateService(Kernel::HLERequestContext& ctx); - void CreateServiceWithoutInitialize(Kernel::HLERequestContext& ctx); + void CreateService(HLERequestContext& ctx); + void CreateServiceWithoutInitialize(HLERequestContext& ctx); protected: std::shared_ptr<Module> module; diff --git a/src/core/hle/service/pcv/pcv.cpp b/src/core/hle/service/pcv/pcv.cpp index be64b94ea..c13ffa6f6 100644 --- a/src/core/hle/service/pcv/pcv.cpp +++ b/src/core/hle/service/pcv/pcv.cpp @@ -3,7 +3,7 @@ #include <memory> -#include "core/hle/ipc_helpers.h" +#include "core/hle/service/ipc_helpers.h" #include "core/hle/service/pcv/pcv.h" #include "core/hle/service/server_manager.h" #include "core/hle/service/service.h" @@ -76,7 +76,7 @@ public: } private: - void SetClockRate(Kernel::HLERequestContext& ctx) { + void SetClockRate(HLERequestContext& ctx) { IPC::RequestParser rp{ctx}; clock_rate = rp.Pop<u32>(); LOG_DEBUG(Service_PCV, "(STUBBED) called, clock_rate={}", clock_rate); @@ -85,7 +85,7 @@ private: rb.Push(ResultSuccess); } - void GetClockRate(Kernel::HLERequestContext& ctx) { + void GetClockRate(HLERequestContext& ctx) { LOG_DEBUG(Service_PCV, "(STUBBED) called"); IPC::ResponseBuilder rb{ctx, 3}; @@ -115,7 +115,7 @@ public: } private: - void OpenSession(Kernel::HLERequestContext& ctx) { + void OpenSession(HLERequestContext& ctx) { IPC::RequestParser rp{ctx}; const auto device_code = static_cast<DeviceCode>(rp.Pop<u32>()); const auto unkonwn_input = rp.Pop<u32>(); diff --git a/src/core/hle/service/pm/pm.cpp b/src/core/hle/service/pm/pm.cpp index 02a4ca13b..f9cf2dda3 100644 --- a/src/core/hle/service/pm/pm.cpp +++ b/src/core/hle/service/pm/pm.cpp @@ -2,9 +2,9 @@ // SPDX-License-Identifier: GPL-2.0-or-later #include "core/core.h" -#include "core/hle/ipc_helpers.h" #include "core/hle/kernel/k_process.h" #include "core/hle/kernel/kernel.h" +#include "core/hle/service/ipc_helpers.h" #include "core/hle/service/pm/pm.h" #include "core/hle/service/server_manager.h" #include "core/hle/service/service.h" @@ -34,15 +34,15 @@ std::optional<Kernel::KProcess*> SearchProcessList( return *iter; } -void GetApplicationPidGeneric(Kernel::HLERequestContext& ctx, +void GetApplicationPidGeneric(HLERequestContext& ctx, const std::vector<Kernel::KProcess*>& process_list) { const auto process = SearchProcessList(process_list, [](const auto& proc) { - return proc->GetProcessID() == Kernel::KProcess::ProcessIDMin; + return proc->GetProcessId() == Kernel::KProcess::ProcessIDMin; }); IPC::ResponseBuilder rb{ctx, 4}; rb.Push(ResultSuccess); - rb.Push(process.has_value() ? (*process)->GetProcessID() : NO_PROCESS_FOUND_PID); + rb.Push(process.has_value() ? (*process)->GetProcessId() : NO_PROCESS_FOUND_PID); } } // Anonymous namespace @@ -58,7 +58,7 @@ public: } private: - void GetBootMode(Kernel::HLERequestContext& ctx) { + void GetBootMode(HLERequestContext& ctx) { LOG_DEBUG(Service_PM, "called"); IPC::ResponseBuilder rb{ctx, 3}; @@ -66,7 +66,7 @@ private: rb.PushEnum(boot_mode); } - void SetMaintenanceBoot(Kernel::HLERequestContext& ctx) { + void SetMaintenanceBoot(HLERequestContext& ctx) { LOG_DEBUG(Service_PM, "called"); boot_mode = SystemBootMode::Maintenance; @@ -100,7 +100,7 @@ public: } private: - void GetProcessId(Kernel::HLERequestContext& ctx) { + void GetProcessId(HLERequestContext& ctx) { IPC::RequestParser rp{ctx}; const auto program_id = rp.PopRaw<u64>(); @@ -108,7 +108,7 @@ private: const auto process = SearchProcessList(kernel.GetProcessList(), [program_id](const auto& proc) { - return proc->GetProgramID() == program_id; + return proc->GetProgramId() == program_id; }); if (!process.has_value()) { @@ -119,15 +119,15 @@ private: IPC::ResponseBuilder rb{ctx, 4}; rb.Push(ResultSuccess); - rb.Push((*process)->GetProcessID()); + rb.Push((*process)->GetProcessId()); } - void GetApplicationProcessId(Kernel::HLERequestContext& ctx) { + void GetApplicationProcessId(HLERequestContext& ctx) { LOG_DEBUG(Service_PM, "called"); GetApplicationPidGeneric(ctx, kernel.GetProcessList()); } - void AtmosphereGetProcessInfo(Kernel::HLERequestContext& ctx) { + void AtmosphereGetProcessInfo(HLERequestContext& ctx) { // https://github.com/Atmosphere-NX/Atmosphere/blob/master/stratosphere/pm/source/impl/pm_process_manager.cpp#L614 // This implementation is incomplete; only a handle to the process is returned. IPC::RequestParser rp{ctx}; @@ -136,7 +136,7 @@ private: LOG_WARNING(Service_PM, "(Partial Implementation) called, pid={:016X}", pid); const auto process = SearchProcessList(kernel.GetProcessList(), [pid](const auto& proc) { - return proc->GetProcessID() == pid; + return proc->GetProcessId() == pid; }); if (!process.has_value()) { @@ -159,7 +159,7 @@ private: OverrideStatus override_status{}; ProgramLocation program_location{ - .program_id = (*process)->GetProgramID(), + .program_id = (*process)->GetProgramId(), .storage_id = 0, }; @@ -187,14 +187,14 @@ public: } private: - void GetProgramId(Kernel::HLERequestContext& ctx) { + void GetProgramId(HLERequestContext& ctx) { IPC::RequestParser rp{ctx}; const auto process_id = rp.PopRaw<u64>(); LOG_DEBUG(Service_PM, "called, process_id={:016X}", process_id); const auto process = SearchProcessList(process_list, [process_id](const auto& proc) { - return proc->GetProcessID() == process_id; + return proc->GetProcessId() == process_id; }); if (!process.has_value()) { @@ -205,17 +205,17 @@ private: IPC::ResponseBuilder rb{ctx, 4}; rb.Push(ResultSuccess); - rb.Push((*process)->GetProgramID()); + rb.Push((*process)->GetProgramId()); } - void AtmosphereGetProcessId(Kernel::HLERequestContext& ctx) { + void AtmosphereGetProcessId(HLERequestContext& ctx) { IPC::RequestParser rp{ctx}; const auto program_id = rp.PopRaw<u64>(); LOG_DEBUG(Service_PM, "called, program_id={:016X}", program_id); const auto process = SearchProcessList(process_list, [program_id](const auto& proc) { - return proc->GetProgramID() == program_id; + return proc->GetProgramId() == program_id; }); if (!process.has_value()) { @@ -226,7 +226,7 @@ private: IPC::ResponseBuilder rb{ctx, 4}; rb.Push(ResultSuccess); - rb.Push((*process)->GetProcessID()); + rb.Push((*process)->GetProcessId()); } const std::vector<Kernel::KProcess*>& process_list; @@ -255,7 +255,7 @@ public: } private: - void GetApplicationProcessIdForShell(Kernel::HLERequestContext& ctx) { + void GetApplicationProcessIdForShell(HLERequestContext& ctx) { LOG_DEBUG(Service_PM, "called"); GetApplicationPidGeneric(ctx, kernel.GetProcessList()); } diff --git a/src/core/hle/service/prepo/prepo.cpp b/src/core/hle/service/prepo/prepo.cpp index 02af311e8..ec4a84989 100644 --- a/src/core/hle/service/prepo/prepo.cpp +++ b/src/core/hle/service/prepo/prepo.cpp @@ -4,8 +4,8 @@ #include "common/hex_util.h" #include "common/logging/log.h" #include "core/core.h" -#include "core/hle/ipc_helpers.h" #include "core/hle/service/acc/profile_manager.h" +#include "core/hle/service/ipc_helpers.h" #include "core/hle/service/prepo/prepo.h" #include "core/hle/service/server_manager.h" #include "core/hle/service/service.h" @@ -54,7 +54,7 @@ public: private: template <Core::Reporter::PlayReportType Type> - void SaveReport(Kernel::HLERequestContext& ctx) { + void SaveReport(HLERequestContext& ctx) { IPC::RequestParser rp{ctx}; const auto process_id = rp.PopRaw<u64>(); @@ -80,7 +80,7 @@ private: } template <Core::Reporter::PlayReportType Type> - void SaveReportWithUser(Kernel::HLERequestContext& ctx) { + void SaveReportWithUser(HLERequestContext& ctx) { IPC::RequestParser rp{ctx}; const auto user_id = rp.PopRaw<u128>(); const auto process_id = rp.PopRaw<u64>(); @@ -107,14 +107,14 @@ private: rb.Push(ResultSuccess); } - void RequestImmediateTransmission(Kernel::HLERequestContext& ctx) { + void RequestImmediateTransmission(HLERequestContext& ctx) { LOG_WARNING(Service_PREPO, "(STUBBED) called"); IPC::ResponseBuilder rb{ctx, 2}; rb.Push(ResultSuccess); } - void GetTransmissionStatus(Kernel::HLERequestContext& ctx) { + void GetTransmissionStatus(HLERequestContext& ctx) { LOG_WARNING(Service_PREPO, "(STUBBED) called"); constexpr s32 status = 0; @@ -124,7 +124,7 @@ private: rb.Push(status); } - void GetSystemSessionId(Kernel::HLERequestContext& ctx) { + void GetSystemSessionId(HLERequestContext& ctx) { LOG_WARNING(Service_PREPO, "(STUBBED) called"); constexpr u64 system_session_id = 0; @@ -133,7 +133,7 @@ private: rb.Push(system_session_id); } - void SaveSystemReport(Kernel::HLERequestContext& ctx) { + void SaveSystemReport(HLERequestContext& ctx) { IPC::RequestParser rp{ctx}; const auto title_id = rp.PopRaw<u64>(); @@ -156,7 +156,7 @@ private: rb.Push(ResultSuccess); } - void SaveSystemReportWithUser(Kernel::HLERequestContext& ctx) { + void SaveSystemReportWithUser(HLERequestContext& ctx) { IPC::RequestParser rp{ctx}; const auto user_id = rp.PopRaw<u128>(); const auto title_id = rp.PopRaw<u64>(); diff --git a/src/core/hle/service/psc/psc.cpp b/src/core/hle/service/psc/psc.cpp index 1650d2f39..cd0cc9287 100644 --- a/src/core/hle/service/psc/psc.cpp +++ b/src/core/hle/service/psc/psc.cpp @@ -4,16 +4,16 @@ #include <memory> #include "common/logging/log.h" -#include "core/hle/ipc_helpers.h" +#include "core/hle/service/ipc_helpers.h" #include "core/hle/service/psc/psc.h" #include "core/hle/service/server_manager.h" #include "core/hle/service/service.h" namespace Service::PSC { -class PSC_C final : public ServiceFramework<PSC_C> { +class IPmControl final : public ServiceFramework<IPmControl> { public: - explicit PSC_C(Core::System& system_) : ServiceFramework{system_, "psc:c"} { + explicit IPmControl(Core::System& system_) : ServiceFramework{system_, "psc:c"} { // clang-format off static const FunctionInfo functions[] = { {0, nullptr, "Initialize"}, @@ -23,8 +23,8 @@ public: {4, nullptr, "Cancel"}, {5, nullptr, "PrintModuleInformation"}, {6, nullptr, "GetModuleInformation"}, - {10, nullptr, "Unknown10"}, - {11, nullptr, "Unknown11"}, + {10, nullptr, "AcquireStateLock"}, + {11, nullptr, "HasStateLock"}, }; // clang-format on @@ -49,12 +49,12 @@ public: } }; -class PSC_M final : public ServiceFramework<PSC_M> { +class IPmService final : public ServiceFramework<IPmService> { public: - explicit PSC_M(Core::System& system_) : ServiceFramework{system_, "psc:m"} { + explicit IPmService(Core::System& system_) : ServiceFramework{system_, "psc:m"} { // clang-format off static const FunctionInfo functions[] = { - {0, &PSC_M::GetPmModule, "GetPmModule"}, + {0, &IPmService::GetPmModule, "GetPmModule"}, }; // clang-format on @@ -62,7 +62,7 @@ public: } private: - void GetPmModule(Kernel::HLERequestContext& ctx) { + void GetPmModule(HLERequestContext& ctx) { LOG_DEBUG(Service_PSC, "called"); IPC::ResponseBuilder rb{ctx, 2, 0, 1}; @@ -74,8 +74,8 @@ private: void LoopProcess(Core::System& system) { auto server_manager = std::make_unique<ServerManager>(system); - server_manager->RegisterNamedService("psc:c", std::make_shared<PSC_C>(system)); - server_manager->RegisterNamedService("psc:m", std::make_shared<PSC_M>(system)); + server_manager->RegisterNamedService("psc:c", std::make_shared<IPmControl>(system)); + server_manager->RegisterNamedService("psc:m", std::make_shared<IPmService>(system)); ServerManager::RunServer(std::move(server_manager)); } diff --git a/src/core/hle/service/ptm/psm.cpp b/src/core/hle/service/ptm/psm.cpp index 1ac97fe31..136313d7b 100644 --- a/src/core/hle/service/ptm/psm.cpp +++ b/src/core/hle/service/ptm/psm.cpp @@ -5,8 +5,8 @@ #include "common/logging/log.h" #include "core/core.h" -#include "core/hle/ipc_helpers.h" #include "core/hle/kernel/k_event.h" +#include "core/hle/service/ipc_helpers.h" #include "core/hle/service/kernel_helpers.h" #include "core/hle/service/ptm/psm.h" @@ -54,7 +54,7 @@ public: } private: - void BindStateChangeEvent(Kernel::HLERequestContext& ctx) { + void BindStateChangeEvent(HLERequestContext& ctx) { LOG_DEBUG(Service_PTM, "called"); should_signal = true; @@ -64,7 +64,7 @@ private: rb.PushCopyObjects(state_change_event->GetReadableEvent()); } - void UnbindStateChangeEvent(Kernel::HLERequestContext& ctx) { + void UnbindStateChangeEvent(HLERequestContext& ctx) { LOG_DEBUG(Service_PTM, "called"); should_signal = false; @@ -73,7 +73,7 @@ private: rb.Push(ResultSuccess); } - void SetChargerTypeChangeEventEnabled(Kernel::HLERequestContext& ctx) { + void SetChargerTypeChangeEventEnabled(HLERequestContext& ctx) { IPC::RequestParser rp{ctx}; const auto state = rp.Pop<bool>(); LOG_DEBUG(Service_PTM, "called, state={}", state); @@ -84,7 +84,7 @@ private: rb.Push(ResultSuccess); } - void SetPowerSupplyChangeEventEnabled(Kernel::HLERequestContext& ctx) { + void SetPowerSupplyChangeEventEnabled(HLERequestContext& ctx) { IPC::RequestParser rp{ctx}; const auto state = rp.Pop<bool>(); LOG_DEBUG(Service_PTM, "called, state={}", state); @@ -95,7 +95,7 @@ private: rb.Push(ResultSuccess); } - void SetBatteryVoltageStateChangeEventEnabled(Kernel::HLERequestContext& ctx) { + void SetBatteryVoltageStateChangeEventEnabled(HLERequestContext& ctx) { IPC::RequestParser rp{ctx}; const auto state = rp.Pop<bool>(); LOG_DEBUG(Service_PTM, "called, state={}", state); @@ -145,7 +145,7 @@ PSM::PSM(Core::System& system_) : ServiceFramework{system_, "psm"} { PSM::~PSM() = default; -void PSM::GetBatteryChargePercentage(Kernel::HLERequestContext& ctx) { +void PSM::GetBatteryChargePercentage(HLERequestContext& ctx) { LOG_DEBUG(Service_PTM, "called"); IPC::ResponseBuilder rb{ctx, 3}; @@ -153,7 +153,7 @@ void PSM::GetBatteryChargePercentage(Kernel::HLERequestContext& ctx) { rb.Push<u32>(battery_charge_percentage); } -void PSM::GetChargerType(Kernel::HLERequestContext& ctx) { +void PSM::GetChargerType(HLERequestContext& ctx) { LOG_DEBUG(Service_PTM, "called"); IPC::ResponseBuilder rb{ctx, 3}; @@ -161,7 +161,7 @@ void PSM::GetChargerType(Kernel::HLERequestContext& ctx) { rb.PushEnum(charger_type); } -void PSM::OpenSession(Kernel::HLERequestContext& ctx) { +void PSM::OpenSession(HLERequestContext& ctx) { LOG_DEBUG(Service_PTM, "called"); IPC::ResponseBuilder rb{ctx, 2, 0, 1}; diff --git a/src/core/hle/service/ptm/psm.h b/src/core/hle/service/ptm/psm.h index f674ba8bc..fa47919e5 100644 --- a/src/core/hle/service/ptm/psm.h +++ b/src/core/hle/service/ptm/psm.h @@ -20,9 +20,9 @@ private: Unknown = 3, }; - void GetBatteryChargePercentage(Kernel::HLERequestContext& ctx); - void GetChargerType(Kernel::HLERequestContext& ctx); - void OpenSession(Kernel::HLERequestContext& ctx); + void GetBatteryChargePercentage(HLERequestContext& ctx); + void GetChargerType(HLERequestContext& ctx); + void OpenSession(HLERequestContext& ctx); u32 battery_charge_percentage{100}; ChargerType charger_type{ChargerType::RegularCharger}; diff --git a/src/core/hle/service/ptm/ts.cpp b/src/core/hle/service/ptm/ts.cpp index b1a0a5544..ca064dd90 100644 --- a/src/core/hle/service/ptm/ts.cpp +++ b/src/core/hle/service/ptm/ts.cpp @@ -4,7 +4,7 @@ #include <memory> #include "core/core.h" -#include "core/hle/ipc_helpers.h" +#include "core/hle/service/ipc_helpers.h" #include "core/hle/service/ptm/ts.h" namespace Service::PTM { @@ -25,7 +25,7 @@ TS::TS(Core::System& system_) : ServiceFramework{system_, "ts"} { TS::~TS() = default; -void TS::GetTemperature(Kernel::HLERequestContext& ctx) { +void TS::GetTemperature(HLERequestContext& ctx) { IPC::RequestParser rp{ctx}; const auto location{rp.PopEnum<Location>()}; @@ -36,7 +36,7 @@ void TS::GetTemperature(Kernel::HLERequestContext& ctx) { rb.Push(temperature); } -void TS::GetTemperatureMilliC(Kernel::HLERequestContext& ctx) { +void TS::GetTemperatureMilliC(HLERequestContext& ctx) { IPC::RequestParser rp{ctx}; const auto location{rp.PopEnum<Location>()}; diff --git a/src/core/hle/service/ptm/ts.h b/src/core/hle/service/ptm/ts.h index 39d51847e..c3f43d5a3 100644 --- a/src/core/hle/service/ptm/ts.h +++ b/src/core/hle/service/ptm/ts.h @@ -19,8 +19,8 @@ private: External, }; - void GetTemperature(Kernel::HLERequestContext& ctx); - void GetTemperatureMilliC(Kernel::HLERequestContext& ctx); + void GetTemperature(HLERequestContext& ctx); + void GetTemperatureMilliC(HLERequestContext& ctx); }; } // namespace Service::PTM diff --git a/src/core/hle/service/server_manager.cpp b/src/core/hle/service/server_manager.cpp index 1b3db3caf..6b4a1291e 100644 --- a/src/core/hle/service/server_manager.cpp +++ b/src/core/hle/service/server_manager.cpp @@ -4,8 +4,6 @@ #include "common/scope_exit.h" #include "core/core.h" -#include "core/hle/ipc_helpers.h" -#include "core/hle/kernel/hle_ipc.h" #include "core/hle/kernel/k_client_port.h" #include "core/hle/kernel/k_client_session.h" #include "core/hle/kernel/k_event.h" @@ -15,6 +13,8 @@ #include "core/hle/kernel/k_server_session.h" #include "core/hle/kernel/k_synchronization_object.h" #include "core/hle/kernel/svc_results.h" +#include "core/hle/service/hle_ipc.h" +#include "core/hle/service/ipc_helpers.h" #include "core/hle/service/server_manager.h" #include "core/hle/service/sm/sm.h" @@ -73,7 +73,7 @@ void ServerManager::RunServer(std::unique_ptr<ServerManager>&& server_manager) { } Result ServerManager::RegisterSession(Kernel::KServerSession* session, - std::shared_ptr<Kernel::SessionRequestManager> manager) { + std::shared_ptr<SessionRequestManager> manager) { ASSERT(m_sessions.size() + m_ports.size() < MaximumWaitObjects); // We are taking ownership of the server session, so don't open it. @@ -90,7 +90,7 @@ Result ServerManager::RegisterSession(Kernel::KServerSession* session, } Result ServerManager::RegisterNamedService(const std::string& service_name, - std::shared_ptr<Kernel::SessionRequestHandler>&& handler, + std::shared_ptr<SessionRequestHandler>&& handler, u32 max_sessions) { ASSERT(m_sessions.size() + m_ports.size() < MaximumWaitObjects); @@ -118,13 +118,13 @@ Result ServerManager::RegisterNamedService(const std::string& service_name, } Result ServerManager::ManageNamedPort(const std::string& service_name, - std::shared_ptr<Kernel::SessionRequestHandler>&& handler, + std::shared_ptr<SessionRequestHandler>&& handler, u32 max_sessions) { ASSERT(m_sessions.size() + m_ports.size() < MaximumWaitObjects); // Create a new port. auto* port = Kernel::KPort::Create(m_system.Kernel()); - port->Initialize(max_sessions, false, service_name); + port->Initialize(max_sessions, false, 0); // Register the port. Kernel::KPort::Register(m_system.Kernel(), port); @@ -265,7 +265,7 @@ Result ServerManager::WaitAndProcessImpl() { case HandleType::Port: { // Port signaled. auto* port = wait_obj->DynamicCast<Kernel::KServerPort*>(); - std::shared_ptr<Kernel::SessionRequestHandler> handler; + std::shared_ptr<SessionRequestHandler> handler; // Remove from tracking. { @@ -284,7 +284,7 @@ Result ServerManager::WaitAndProcessImpl() { case HandleType::Session: { // Session signaled. auto* session = wait_obj->DynamicCast<Kernel::KServerSession*>(); - std::shared_ptr<Kernel::SessionRequestManager> manager; + std::shared_ptr<SessionRequestManager> manager; // Remove from tracking. { @@ -329,13 +329,13 @@ Result ServerManager::WaitAndProcessImpl() { } Result ServerManager::OnPortEvent(Kernel::KServerPort* port, - std::shared_ptr<Kernel::SessionRequestHandler>&& handler) { + std::shared_ptr<SessionRequestHandler>&& handler) { // Accept a new server session. Kernel::KServerSession* session = port->AcceptSession(); ASSERT(session != nullptr); // Create the session manager and install the handler. - auto manager = std::make_shared<Kernel::SessionRequestManager>(m_system.Kernel(), *this); + auto manager = std::make_shared<SessionRequestManager>(m_system.Kernel(), *this); manager->SetSessionHandler(std::shared_ptr(handler)); // Track the server session. @@ -353,11 +353,11 @@ Result ServerManager::OnPortEvent(Kernel::KServerPort* port, } Result ServerManager::OnSessionEvent(Kernel::KServerSession* session, - std::shared_ptr<Kernel::SessionRequestManager>&& manager) { + std::shared_ptr<SessionRequestManager>&& manager) { Result rc{ResultSuccess}; // Try to receive a message. - std::shared_ptr<Kernel::HLERequestContext> context; + std::shared_ptr<HLERequestContext> context; rc = session->ReceiveRequest(&context, manager); // If the session has been closed, we're done. @@ -404,7 +404,7 @@ Result ServerManager::CompleteSyncRequest(RequestState&& request) { rc = request.session->SendReplyHLE(); // If the session has been closed, we're done. - if (rc == Kernel::ResultSessionClosed || service_rc == IPC::ERR_REMOTE_PROCESS_DEAD) { + if (rc == Kernel::ResultSessionClosed || service_rc == IPC::ResultSessionClosed) { // Close the session. request.session->Close(); diff --git a/src/core/hle/service/server_manager.h b/src/core/hle/service/server_manager.h index 57b954ae8..fdb8af2ff 100644 --- a/src/core/hle/service/server_manager.h +++ b/src/core/hle/service/server_manager.h @@ -20,30 +20,30 @@ class System; } namespace Kernel { -class HLERequestContext; class KEvent; class KServerPort; class KServerSession; class KSynchronizationObject; -class SessionRequestHandler; -class SessionRequestManager; } // namespace Kernel namespace Service { +class HLERequestContext; +class SessionRequestHandler; +class SessionRequestManager; + class ServerManager { public: explicit ServerManager(Core::System& system); ~ServerManager(); Result RegisterSession(Kernel::KServerSession* session, - std::shared_ptr<Kernel::SessionRequestManager> manager); + std::shared_ptr<SessionRequestManager> manager); Result RegisterNamedService(const std::string& service_name, - std::shared_ptr<Kernel::SessionRequestHandler>&& handler, + std::shared_ptr<SessionRequestHandler>&& handler, u32 max_sessions = 64); Result ManageNamedPort(const std::string& service_name, - std::shared_ptr<Kernel::SessionRequestHandler>&& handler, - u32 max_sessions = 64); + std::shared_ptr<SessionRequestHandler>&& handler, u32 max_sessions = 64); Result ManageDeferral(Kernel::KEvent** out_event); Result LoopProcess(); @@ -56,10 +56,9 @@ private: Result LoopProcessImpl(); Result WaitAndProcessImpl(); - Result OnPortEvent(Kernel::KServerPort* port, - std::shared_ptr<Kernel::SessionRequestHandler>&& handler); + Result OnPortEvent(Kernel::KServerPort* port, std::shared_ptr<SessionRequestHandler>&& handler); Result OnSessionEvent(Kernel::KServerSession* session, - std::shared_ptr<Kernel::SessionRequestManager>&& manager); + std::shared_ptr<SessionRequestManager>&& manager); Result OnDeferralEvent(std::list<RequestState>&& deferrals); Result CompleteSyncRequest(RequestState&& state); @@ -69,16 +68,16 @@ private: std::mutex m_list_mutex; // Guest state tracking - std::map<Kernel::KServerPort*, std::shared_ptr<Kernel::SessionRequestHandler>> m_ports{}; - std::map<Kernel::KServerSession*, std::shared_ptr<Kernel::SessionRequestManager>> m_sessions{}; + std::map<Kernel::KServerPort*, std::shared_ptr<SessionRequestHandler>> m_ports{}; + std::map<Kernel::KServerSession*, std::shared_ptr<SessionRequestManager>> m_sessions{}; Kernel::KEvent* m_event{}; Kernel::KEvent* m_deferral_event{}; // Deferral tracking struct RequestState { Kernel::KServerSession* session; - std::shared_ptr<Kernel::HLERequestContext> context; - std::shared_ptr<Kernel::SessionRequestManager> manager; + std::shared_ptr<HLERequestContext> context; + std::shared_ptr<SessionRequestManager> manager; }; std::list<RequestState> m_deferrals{}; diff --git a/src/core/hle/service/service.cpp b/src/core/hle/service/service.cpp index 31021ea03..69cdb5918 100644 --- a/src/core/hle/service/service.cpp +++ b/src/core/hle/service/service.cpp @@ -7,7 +7,6 @@ #include "common/settings.h" #include "core/core.h" #include "core/hle/ipc.h" -#include "core/hle/ipc_helpers.h" #include "core/hle/kernel/k_process.h" #include "core/hle/kernel/k_server_port.h" #include "core/hle/kernel/kernel.h" @@ -31,6 +30,7 @@ #include "core/hle/service/glue/glue.h" #include "core/hle/service/grc/grc.h" #include "core/hle/service/hid/hid.h" +#include "core/hle/service/ipc_helpers.h" #include "core/hle/service/jit/jit.h" #include "core/hle/service/lbl/lbl.h" #include "core/hle/service/ldn/ldn.h" @@ -49,8 +49,8 @@ #include "core/hle/service/npns/npns.h" #include "core/hle/service/ns/ns.h" #include "core/hle/service/nvdrv/nvdrv.h" -#include "core/hle/service/nvflinger/hos_binder_driver_server.h" -#include "core/hle/service/nvflinger/nvflinger.h" +#include "core/hle/service/nvnflinger/hos_binder_driver_server.h" +#include "core/hle/service/nvnflinger/nvnflinger.h" #include "core/hle/service/olsc/olsc.h" #include "core/hle/service/pcie/pcie.h" #include "core/hle/service/pctl/pctl_module.h" @@ -117,7 +117,7 @@ void ServiceFrameworkBase::RegisterHandlersBaseTipc(const FunctionInfoBase* func } } -void ServiceFrameworkBase::ReportUnimplementedFunction(Kernel::HLERequestContext& ctx, +void ServiceFrameworkBase::ReportUnimplementedFunction(HLERequestContext& ctx, const FunctionInfoBase* info) { auto cmd_buf = ctx.CommandBuffer(); std::string function_name = info == nullptr ? fmt::format("{}", ctx.GetCommand()) : info->name; @@ -140,7 +140,7 @@ void ServiceFrameworkBase::ReportUnimplementedFunction(Kernel::HLERequestContext } } -void ServiceFrameworkBase::InvokeRequest(Kernel::HLERequestContext& ctx) { +void ServiceFrameworkBase::InvokeRequest(HLERequestContext& ctx) { auto itr = handlers.find(ctx.GetCommand()); const FunctionInfoBase* info = itr == handlers.end() ? nullptr : &itr->second; if (info == nullptr || info->handler_callback == nullptr) { @@ -151,7 +151,7 @@ void ServiceFrameworkBase::InvokeRequest(Kernel::HLERequestContext& ctx) { handler_invoker(this, info->handler_callback, ctx); } -void ServiceFrameworkBase::InvokeRequestTipc(Kernel::HLERequestContext& ctx) { +void ServiceFrameworkBase::InvokeRequestTipc(HLERequestContext& ctx) { boost::container::flat_map<u32, FunctionInfoBase>::iterator itr; itr = handlers_tipc.find(ctx.GetCommand()); @@ -166,7 +166,7 @@ void ServiceFrameworkBase::InvokeRequestTipc(Kernel::HLERequestContext& ctx) { } Result ServiceFrameworkBase::HandleSyncRequest(Kernel::KServerSession& session, - Kernel::HLERequestContext& ctx) { + HLERequestContext& ctx) { const auto guard = LockService(); Result result = ResultSuccess; @@ -176,7 +176,7 @@ Result ServiceFrameworkBase::HandleSyncRequest(Kernel::KServerSession& session, case IPC::CommandType::TIPC_Close: { IPC::ResponseBuilder rb{ctx, 2}; rb.Push(ResultSuccess); - result = IPC::ERR_REMOTE_PROCESS_DEAD; + result = IPC::ResultSessionClosed; break; } case IPC::CommandType::ControlWithContext: @@ -210,12 +210,12 @@ Result ServiceFrameworkBase::HandleSyncRequest(Kernel::KServerSession& session, /// Initialize Services Services::Services(std::shared_ptr<SM::ServiceManager>& sm, Core::System& system) - : hos_binder_driver_server{std::make_unique<NVFlinger::HosBinderDriverServer>(system)}, - nv_flinger{std::make_unique<NVFlinger::NVFlinger>(system, *hos_binder_driver_server)} { + : hos_binder_driver_server{std::make_unique<Nvnflinger::HosBinderDriverServer>(system)}, + nv_flinger{std::make_unique<Nvnflinger::Nvnflinger>(system, *hos_binder_driver_server)} { auto& kernel = system.Kernel(); - // NVFlinger needs to be accessed by several services like Vi and AppletOE so we instantiate it + // Nvnflinger needs to be accessed by several services like Vi and AppletOE so we instantiate it // here and pass it into the respective InstallInterfaces functions. system.GetFileSystemController().CreateFactories(*system.GetFilesystem(), false); diff --git a/src/core/hle/service/service.h b/src/core/hle/service/service.h index db3b31378..0f79a1b7e 100644 --- a/src/core/hle/service/service.h +++ b/src/core/hle/service/service.h @@ -8,7 +8,7 @@ #include <string> #include <boost/container/flat_map.hpp> #include "common/common_types.h" -#include "core/hle/kernel/hle_ipc.h" +#include "core/hle/service/hle_ipc.h" //////////////////////////////////////////////////////////////////////////////////////////////////// // Namespace Service @@ -18,7 +18,6 @@ class System; } namespace Kernel { -class HLERequestContext; class KServerSession; class ServiceThread; } // namespace Kernel @@ -29,10 +28,10 @@ namespace FileSystem { class FileSystemController; } -namespace NVFlinger { +namespace Nvnflinger { class HosBinderDriverServer; -class NVFlinger; -} // namespace NVFlinger +class Nvnflinger; +} // namespace Nvnflinger namespace SM { class ServiceManager; @@ -50,7 +49,7 @@ static_assert(ServerSessionCountMax == 0x40, * * @see ServiceFramework */ -class ServiceFrameworkBase : public Kernel::SessionRequestHandler { +class ServiceFrameworkBase : public SessionRequestHandler { public: /// Returns the string identifier used to connect to the service. std::string GetServiceName() const { @@ -66,19 +65,18 @@ public: } /// Invokes a service request routine using the HIPC protocol. - void InvokeRequest(Kernel::HLERequestContext& ctx); + void InvokeRequest(HLERequestContext& ctx); /// Invokes a service request routine using the HIPC protocol. - void InvokeRequestTipc(Kernel::HLERequestContext& ctx); + void InvokeRequestTipc(HLERequestContext& ctx); /// Handles a synchronization request for the service. - Result HandleSyncRequest(Kernel::KServerSession& session, - Kernel::HLERequestContext& context) override; + Result HandleSyncRequest(Kernel::KServerSession& session, HLERequestContext& context) override; protected: /// Member-function pointer type of SyncRequest handlers. template <typename Self> - using HandlerFnP = void (Self::*)(Kernel::HLERequestContext&); + using HandlerFnP = void (Self::*)(HLERequestContext&); /// Used to gain exclusive access to the service members, e.g. from CoreTiming thread. [[nodiscard]] std::scoped_lock<std::mutex> LockService() { @@ -102,7 +100,7 @@ private: }; using InvokerFn = void(ServiceFrameworkBase* object, HandlerFnP<ServiceFrameworkBase> member, - Kernel::HLERequestContext& ctx); + HLERequestContext& ctx); explicit ServiceFrameworkBase(Core::System& system_, const char* service_name_, u32 max_sessions_, InvokerFn* handler_invoker_); @@ -110,7 +108,7 @@ private: 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); + void ReportUnimplementedFunction(HLERequestContext& ctx, const FunctionInfoBase* info); /// Maximum number of concurrent sessions that this service can handle. u32 max_sessions; @@ -212,7 +210,7 @@ private: * of the derived class in order to invoke one of it's functions through a pointer. */ static void Invoker(ServiceFrameworkBase* object, HandlerFnP<ServiceFrameworkBase> member, - Kernel::HLERequestContext& ctx) { + HLERequestContext& ctx) { // Cast back up to our original types and call the member function (static_cast<Self*>(object)->*static_cast<HandlerFnP<Self>>(member))(ctx); } @@ -230,8 +228,8 @@ public: void KillNVNFlinger(); private: - std::unique_ptr<NVFlinger::HosBinderDriverServer> hos_binder_driver_server; - std::unique_ptr<NVFlinger::NVFlinger> nv_flinger; + std::unique_ptr<Nvnflinger::HosBinderDriverServer> hos_binder_driver_server; + std::unique_ptr<Nvnflinger::Nvnflinger> nv_flinger; }; } // namespace Service diff --git a/src/core/hle/service/set/set.cpp b/src/core/hle/service/set/set.cpp index 16c5eaf75..f5788b481 100644 --- a/src/core/hle/service/set/set.cpp +++ b/src/core/hle/service/set/set.cpp @@ -6,7 +6,7 @@ #include <chrono> #include "common/logging/log.h" #include "common/settings.h" -#include "core/hle/ipc_helpers.h" +#include "core/hle/service/ipc_helpers.h" #include "core/hle/service/set/set.h" namespace Service::Set { @@ -74,15 +74,15 @@ constexpr std::array<std::pair<LanguageCode, KeyboardLayout>, 18> language_to_la constexpr std::size_t PRE_4_0_0_MAX_ENTRIES = 0xF; constexpr std::size_t POST_4_0_0_MAX_ENTRIES = 0x40; -constexpr Result ERR_INVALID_LANGUAGE{ErrorModule::Settings, 625}; +constexpr Result ResultInvalidLanguage{ErrorModule::Settings, 625}; -void PushResponseLanguageCode(Kernel::HLERequestContext& ctx, std::size_t num_language_codes) { +void PushResponseLanguageCode(HLERequestContext& ctx, std::size_t num_language_codes) { IPC::ResponseBuilder rb{ctx, 3}; rb.Push(ResultSuccess); rb.Push(static_cast<u32>(num_language_codes)); } -void GetAvailableLanguageCodesImpl(Kernel::HLERequestContext& ctx, std::size_t max_entries) { +void GetAvailableLanguageCodesImpl(HLERequestContext& ctx, std::size_t max_entries) { const std::size_t requested_amount = ctx.GetWriteBufferNumElements<LanguageCode>(); const std::size_t max_amount = std::min(requested_amount, max_entries); const std::size_t copy_amount = std::min(available_language_codes.size(), max_amount); @@ -92,7 +92,7 @@ void GetAvailableLanguageCodesImpl(Kernel::HLERequestContext& ctx, std::size_t m PushResponseLanguageCode(ctx, copy_amount); } -void GetKeyCodeMapImpl(Kernel::HLERequestContext& ctx) { +void GetKeyCodeMapImpl(HLERequestContext& ctx) { const auto language_code = available_language_codes[Settings::values.language_index.GetValue()]; const auto key_code = std::find_if(language_to_layout.cbegin(), language_to_layout.cend(), @@ -117,20 +117,20 @@ LanguageCode GetLanguageCodeFromIndex(std::size_t index) { return available_language_codes.at(index); } -void SET::GetAvailableLanguageCodes(Kernel::HLERequestContext& ctx) { +void SET::GetAvailableLanguageCodes(HLERequestContext& ctx) { LOG_DEBUG(Service_SET, "called"); GetAvailableLanguageCodesImpl(ctx, PRE_4_0_0_MAX_ENTRIES); } -void SET::MakeLanguageCode(Kernel::HLERequestContext& ctx) { +void SET::MakeLanguageCode(HLERequestContext& ctx) { IPC::RequestParser rp{ctx}; const auto index = rp.Pop<u32>(); if (index >= available_language_codes.size()) { LOG_ERROR(Service_SET, "Invalid language code index! index={}", index); IPC::ResponseBuilder rb{ctx, 2}; - rb.Push(ERR_INVALID_LANGUAGE); + rb.Push(Set::ResultInvalidLanguage); return; } @@ -139,25 +139,25 @@ void SET::MakeLanguageCode(Kernel::HLERequestContext& ctx) { rb.PushEnum(available_language_codes[index]); } -void SET::GetAvailableLanguageCodes2(Kernel::HLERequestContext& ctx) { +void SET::GetAvailableLanguageCodes2(HLERequestContext& ctx) { LOG_DEBUG(Service_SET, "called"); GetAvailableLanguageCodesImpl(ctx, POST_4_0_0_MAX_ENTRIES); } -void SET::GetAvailableLanguageCodeCount(Kernel::HLERequestContext& ctx) { +void SET::GetAvailableLanguageCodeCount(HLERequestContext& ctx) { LOG_DEBUG(Service_SET, "called"); PushResponseLanguageCode(ctx, PRE_4_0_0_MAX_ENTRIES); } -void SET::GetAvailableLanguageCodeCount2(Kernel::HLERequestContext& ctx) { +void SET::GetAvailableLanguageCodeCount2(HLERequestContext& ctx) { LOG_DEBUG(Service_SET, "called"); PushResponseLanguageCode(ctx, POST_4_0_0_MAX_ENTRIES); } -void SET::GetQuestFlag(Kernel::HLERequestContext& ctx) { +void SET::GetQuestFlag(HLERequestContext& ctx) { LOG_DEBUG(Service_SET, "called"); IPC::ResponseBuilder rb{ctx, 3}; @@ -165,7 +165,7 @@ void SET::GetQuestFlag(Kernel::HLERequestContext& ctx) { rb.Push(static_cast<u32>(Settings::values.quest_flag.GetValue())); } -void SET::GetLanguageCode(Kernel::HLERequestContext& ctx) { +void SET::GetLanguageCode(HLERequestContext& ctx) { LOG_DEBUG(Service_SET, "called {}", Settings::values.language_index.GetValue()); IPC::ResponseBuilder rb{ctx, 4}; @@ -173,7 +173,7 @@ void SET::GetLanguageCode(Kernel::HLERequestContext& ctx) { rb.PushEnum(available_language_codes[Settings::values.language_index.GetValue()]); } -void SET::GetRegionCode(Kernel::HLERequestContext& ctx) { +void SET::GetRegionCode(HLERequestContext& ctx) { LOG_DEBUG(Service_SET, "called"); IPC::ResponseBuilder rb{ctx, 3}; @@ -181,17 +181,17 @@ void SET::GetRegionCode(Kernel::HLERequestContext& ctx) { rb.Push(Settings::values.region_index.GetValue()); } -void SET::GetKeyCodeMap(Kernel::HLERequestContext& ctx) { +void SET::GetKeyCodeMap(HLERequestContext& ctx) { LOG_DEBUG(Service_SET, "Called {}", ctx.Description()); GetKeyCodeMapImpl(ctx); } -void SET::GetKeyCodeMap2(Kernel::HLERequestContext& ctx) { +void SET::GetKeyCodeMap2(HLERequestContext& ctx) { LOG_DEBUG(Service_SET, "Called {}", ctx.Description()); GetKeyCodeMapImpl(ctx); } -void SET::GetDeviceNickName(Kernel::HLERequestContext& ctx) { +void SET::GetDeviceNickName(HLERequestContext& ctx) { LOG_DEBUG(Service_SET, "called"); IPC::ResponseBuilder rb{ctx, 2}; rb.Push(ResultSuccess); diff --git a/src/core/hle/service/set/set.h b/src/core/hle/service/set/set.h index 375975711..7fd3a7654 100644 --- a/src/core/hle/service/set/set.h +++ b/src/core/hle/service/set/set.h @@ -40,17 +40,17 @@ public: ~SET() override; private: - void GetLanguageCode(Kernel::HLERequestContext& ctx); - void GetAvailableLanguageCodes(Kernel::HLERequestContext& ctx); - void MakeLanguageCode(Kernel::HLERequestContext& ctx); - void GetAvailableLanguageCodes2(Kernel::HLERequestContext& ctx); - void GetAvailableLanguageCodeCount(Kernel::HLERequestContext& ctx); - void GetAvailableLanguageCodeCount2(Kernel::HLERequestContext& ctx); - void GetQuestFlag(Kernel::HLERequestContext& ctx); - void GetRegionCode(Kernel::HLERequestContext& ctx); - void GetKeyCodeMap(Kernel::HLERequestContext& ctx); - void GetKeyCodeMap2(Kernel::HLERequestContext& ctx); - void GetDeviceNickName(Kernel::HLERequestContext& ctx); + void GetLanguageCode(HLERequestContext& ctx); + void GetAvailableLanguageCodes(HLERequestContext& ctx); + void MakeLanguageCode(HLERequestContext& ctx); + void GetAvailableLanguageCodes2(HLERequestContext& ctx); + void GetAvailableLanguageCodeCount(HLERequestContext& ctx); + void GetAvailableLanguageCodeCount2(HLERequestContext& ctx); + void GetQuestFlag(HLERequestContext& ctx); + void GetRegionCode(HLERequestContext& ctx); + void GetKeyCodeMap(HLERequestContext& ctx); + void GetKeyCodeMap2(HLERequestContext& ctx); + void GetDeviceNickName(HLERequestContext& ctx); }; } // namespace Service::Set diff --git a/src/core/hle/service/set/set_sys.cpp b/src/core/hle/service/set/set_sys.cpp index 94c20edda..2e38d1cfc 100644 --- a/src/core/hle/service/set/set_sys.cpp +++ b/src/core/hle/service/set/set_sys.cpp @@ -6,8 +6,8 @@ #include "common/settings.h" #include "core/file_sys/errors.h" #include "core/file_sys/system_archive/system_version.h" -#include "core/hle/ipc_helpers.h" #include "core/hle/service/filesystem/filesystem.h" +#include "core/hle/service/ipc_helpers.h" #include "core/hle/service/set/set_sys.h" namespace Service::Set { @@ -20,7 +20,7 @@ enum class GetFirmwareVersionType { Version2, }; -void GetFirmwareVersionImpl(Kernel::HLERequestContext& ctx, GetFirmwareVersionType type) { +void GetFirmwareVersionImpl(HLERequestContext& ctx, GetFirmwareVersionType type) { LOG_WARNING(Service_SET, "called - Using hardcoded firmware version '{}'", FileSys::SystemArchive::GetLongDisplayVersion()); @@ -73,17 +73,17 @@ void GetFirmwareVersionImpl(Kernel::HLERequestContext& ctx, GetFirmwareVersionTy } } // Anonymous namespace -void SET_SYS::GetFirmwareVersion(Kernel::HLERequestContext& ctx) { +void SET_SYS::GetFirmwareVersion(HLERequestContext& ctx) { LOG_DEBUG(Service_SET, "called"); GetFirmwareVersionImpl(ctx, GetFirmwareVersionType::Version1); } -void SET_SYS::GetFirmwareVersion2(Kernel::HLERequestContext& ctx) { +void SET_SYS::GetFirmwareVersion2(HLERequestContext& ctx) { LOG_DEBUG(Service_SET, "called"); GetFirmwareVersionImpl(ctx, GetFirmwareVersionType::Version2); } -void SET_SYS::GetColorSetId(Kernel::HLERequestContext& ctx) { +void SET_SYS::GetColorSetId(HLERequestContext& ctx) { LOG_DEBUG(Service_SET, "called"); IPC::ResponseBuilder rb{ctx, 3}; @@ -92,7 +92,7 @@ void SET_SYS::GetColorSetId(Kernel::HLERequestContext& ctx) { rb.PushEnum(color_set); } -void SET_SYS::SetColorSetId(Kernel::HLERequestContext& ctx) { +void SET_SYS::SetColorSetId(HLERequestContext& ctx) { LOG_DEBUG(Service_SET, "called"); IPC::RequestParser rp{ctx}; @@ -126,7 +126,7 @@ static Settings GetSettings() { return ret; } -void SET_SYS::GetSettingsItemValueSize(Kernel::HLERequestContext& ctx) { +void SET_SYS::GetSettingsItemValueSize(HLERequestContext& ctx) { LOG_DEBUG(Service_SET, "called"); // The category of the setting. This corresponds to the top-level keys of @@ -151,7 +151,7 @@ void SET_SYS::GetSettingsItemValueSize(Kernel::HLERequestContext& ctx) { rb.Push(response_size); } -void SET_SYS::GetSettingsItemValue(Kernel::HLERequestContext& ctx) { +void SET_SYS::GetSettingsItemValue(HLERequestContext& ctx) { LOG_DEBUG(Service_SET, "called"); // The category of the setting. This corresponds to the top-level keys of @@ -177,7 +177,7 @@ void SET_SYS::GetSettingsItemValue(Kernel::HLERequestContext& ctx) { rb.Push(response); } -void SET_SYS::GetDeviceNickName(Kernel::HLERequestContext& ctx) { +void SET_SYS::GetDeviceNickName(HLERequestContext& ctx) { LOG_DEBUG(Service_SET, "called"); IPC::ResponseBuilder rb{ctx, 2}; rb.Push(ResultSuccess); diff --git a/src/core/hle/service/set/set_sys.h b/src/core/hle/service/set/set_sys.h index 464ac3da1..1efbcc97a 100644 --- a/src/core/hle/service/set/set_sys.h +++ b/src/core/hle/service/set/set_sys.h @@ -23,13 +23,13 @@ private: BasicBlack = 1, }; - void GetSettingsItemValueSize(Kernel::HLERequestContext& ctx); - void GetSettingsItemValue(Kernel::HLERequestContext& ctx); - void GetFirmwareVersion(Kernel::HLERequestContext& ctx); - void GetFirmwareVersion2(Kernel::HLERequestContext& ctx); - void GetColorSetId(Kernel::HLERequestContext& ctx); - void SetColorSetId(Kernel::HLERequestContext& ctx); - void GetDeviceNickName(Kernel::HLERequestContext& ctx); + void GetSettingsItemValueSize(HLERequestContext& ctx); + void GetSettingsItemValue(HLERequestContext& ctx); + void GetFirmwareVersion(HLERequestContext& ctx); + void GetFirmwareVersion2(HLERequestContext& ctx); + void GetColorSetId(HLERequestContext& ctx); + void SetColorSetId(HLERequestContext& ctx); + void GetDeviceNickName(HLERequestContext& ctx); ColorSet color_set = ColorSet::BasicWhite; }; diff --git a/src/core/hle/service/sm/sm.cpp b/src/core/hle/service/sm/sm.cpp index 53c877836..c45be5726 100644 --- a/src/core/hle/service/sm/sm.cpp +++ b/src/core/hle/service/sm/sm.cpp @@ -5,23 +5,23 @@ #include "common/assert.h" #include "common/scope_exit.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/result.h" +#include "core/hle/service/ipc_helpers.h" #include "core/hle/service/server_manager.h" #include "core/hle/service/sm/sm.h" #include "core/hle/service/sm/sm_controller.h" namespace Service::SM { -constexpr Result ERR_NOT_INITIALIZED(ErrorModule::SM, 2); -constexpr Result ERR_ALREADY_REGISTERED(ErrorModule::SM, 4); -constexpr Result ERR_INVALID_NAME(ErrorModule::SM, 6); -constexpr Result ERR_SERVICE_NOT_REGISTERED(ErrorModule::SM, 7); +constexpr Result ResultInvalidClient(ErrorModule::SM, 2); +constexpr Result ResultAlreadyRegistered(ErrorModule::SM, 4); +constexpr Result ResultInvalidServiceName(ErrorModule::SM, 6); +constexpr Result ResultNotRegistered(ErrorModule::SM, 7); ServiceManager::ServiceManager(Kernel::KernelCore& kernel_) : kernel{kernel_} { controller_interface = std::make_unique<Controller>(kernel.System()); @@ -38,31 +38,31 @@ ServiceManager::~ServiceManager() { } } -void ServiceManager::InvokeControlRequest(Kernel::HLERequestContext& context) { +void ServiceManager::InvokeControlRequest(HLERequestContext& context) { controller_interface->InvokeRequest(context); } static Result ValidateServiceName(const std::string& name) { if (name.empty() || name.size() > 8) { LOG_ERROR(Service_SM, "Invalid service name! service={}", name); - return ERR_INVALID_NAME; + return Service::SM::ResultInvalidServiceName; } return ResultSuccess; } Result ServiceManager::RegisterService(std::string name, u32 max_sessions, - Kernel::SessionRequestHandlerPtr handler) { + SessionRequestHandlerPtr handler) { CASCADE_CODE(ValidateServiceName(name)); std::scoped_lock lk{lock}; if (registered_services.find(name) != registered_services.end()) { LOG_ERROR(Service_SM, "Service is already registered! service={}", name); - return ERR_ALREADY_REGISTERED; + return Service::SM::ResultAlreadyRegistered; } auto* port = Kernel::KPort::Create(kernel); - port->Initialize(ServerSessionCountMax, false, name); + port->Initialize(ServerSessionCountMax, false, 0); service_ports.emplace(name, port); registered_services.emplace(name, handler); @@ -80,7 +80,7 @@ Result ServiceManager::UnregisterService(const std::string& name) { const auto iter = registered_services.find(name); if (iter == registered_services.end()) { LOG_ERROR(Service_SM, "Server is not registered! service={}", name); - return ERR_SERVICE_NOT_REGISTERED; + return Service::SM::ResultNotRegistered; } registered_services.erase(iter); @@ -96,7 +96,7 @@ ResultVal<Kernel::KPort*> ServiceManager::GetServicePort(const std::string& name auto it = service_ports.find(name); if (it == service_ports.end()) { LOG_WARNING(Service_SM, "Server is not registered! service={}", name); - return ERR_SERVICE_NOT_REGISTERED; + return Service::SM::ResultNotRegistered; } return it->second; @@ -109,7 +109,7 @@ ResultVal<Kernel::KPort*> ServiceManager::GetServicePort(const std::string& name * Outputs: * 0: Result */ -void SM::Initialize(Kernel::HLERequestContext& ctx) { +void SM::Initialize(HLERequestContext& ctx) { LOG_DEBUG(Service_SM, "called"); ctx.GetManager()->SetIsInitializedForSm(); @@ -118,7 +118,7 @@ void SM::Initialize(Kernel::HLERequestContext& ctx) { rb.Push(ResultSuccess); } -void SM::GetService(Kernel::HLERequestContext& ctx) { +void SM::GetService(HLERequestContext& ctx) { auto result = GetServiceImpl(ctx); if (ctx.GetIsDeferred()) { // Don't overwrite the command buffer. @@ -135,7 +135,7 @@ void SM::GetService(Kernel::HLERequestContext& ctx) { } } -void SM::GetServiceTipc(Kernel::HLERequestContext& ctx) { +void SM::GetServiceTipc(HLERequestContext& ctx) { auto result = GetServiceImpl(ctx); if (ctx.GetIsDeferred()) { // Don't overwrite the command buffer. @@ -158,9 +158,9 @@ static std::string PopServiceName(IPC::RequestParser& rp) { return result; } -ResultVal<Kernel::KClientSession*> SM::GetServiceImpl(Kernel::HLERequestContext& ctx) { +ResultVal<Kernel::KClientSession*> SM::GetServiceImpl(HLERequestContext& ctx) { if (!ctx.GetManager()->GetIsInitializedForSm()) { - return ERR_NOT_INITIALIZED; + return Service::SM::ResultInvalidClient; } IPC::RequestParser rp{ctx}; @@ -168,15 +168,15 @@ ResultVal<Kernel::KClientSession*> SM::GetServiceImpl(Kernel::HLERequestContext& // Find the named port. auto port_result = service_manager.GetServicePort(name); - if (port_result.Code() == ERR_INVALID_NAME) { + if (port_result.Code() == Service::SM::ResultInvalidServiceName) { LOG_ERROR(Service_SM, "Invalid service name '{}'", name); - return ERR_INVALID_NAME; + return Service::SM::ResultInvalidServiceName; } if (port_result.Failed()) { LOG_INFO(Service_SM, "Waiting for service {} to become available", name); ctx.SetIsDeferred(); - return ERR_SERVICE_NOT_REGISTERED; + return Service::SM::ResultNotRegistered; } auto& port = port_result.Unwrap(); @@ -192,7 +192,7 @@ ResultVal<Kernel::KClientSession*> SM::GetServiceImpl(Kernel::HLERequestContext& return session; } -void SM::RegisterService(Kernel::HLERequestContext& ctx) { +void SM::RegisterService(HLERequestContext& ctx) { IPC::RequestParser rp{ctx}; std::string name(PopServiceName(rp)); @@ -211,7 +211,7 @@ void SM::RegisterService(Kernel::HLERequestContext& ctx) { } auto* port = Kernel::KPort::Create(kernel); - port->Initialize(ServerSessionCountMax, is_light, name); + port->Initialize(ServerSessionCountMax, is_light, 0); SCOPE_EXIT({ port->GetClientPort().Close(); }); IPC::ResponseBuilder rb{ctx, 2, 0, 1, IPC::ResponseBuilder::Flags::AlwaysMoveHandles}; @@ -219,7 +219,7 @@ void SM::RegisterService(Kernel::HLERequestContext& ctx) { rb.PushMoveObjects(port->GetServerPort()); } -void SM::UnregisterService(Kernel::HLERequestContext& ctx) { +void SM::UnregisterService(HLERequestContext& ctx) { IPC::RequestParser rp{ctx}; std::string name(PopServiceName(rp)); diff --git a/src/core/hle/service/sm/sm.h b/src/core/hle/service/sm/sm.h index b7eeafdd6..6697f4007 100644 --- a/src/core/hle/service/sm/sm.h +++ b/src/core/hle/service/sm/sm.h @@ -36,16 +36,15 @@ public: ~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); + void Initialize(HLERequestContext& ctx); + void GetService(HLERequestContext& ctx); + void GetServiceTipc(HLERequestContext& ctx); + void RegisterService(HLERequestContext& ctx); + void UnregisterService(HLERequestContext& ctx); - ResultVal<Kernel::KClientSession*> GetServiceImpl(Kernel::HLERequestContext& ctx); + ResultVal<Kernel::KClientSession*> GetServiceImpl(HLERequestContext& ctx); ServiceManager& service_manager; - bool is_initialized{}; Kernel::KernelCore& kernel; }; @@ -54,12 +53,11 @@ public: explicit ServiceManager(Kernel::KernelCore& kernel_); ~ServiceManager(); - Result RegisterService(std::string name, u32 max_sessions, - Kernel::SessionRequestHandlerPtr handler); + Result RegisterService(std::string name, u32 max_sessions, SessionRequestHandlerPtr handler); Result UnregisterService(const std::string& name); ResultVal<Kernel::KPort*> GetServicePort(const std::string& name); - template <Common::DerivedFrom<Kernel::SessionRequestHandler> T> + template <Common::DerivedFrom<SessionRequestHandler> T> std::shared_ptr<T> GetService(const std::string& service_name) const { auto service = registered_services.find(service_name); if (service == registered_services.end()) { @@ -69,7 +67,7 @@ public: return std::static_pointer_cast<T>(service->second); } - void InvokeControlRequest(Kernel::HLERequestContext& context); + void InvokeControlRequest(HLERequestContext& context); void SetDeferralEvent(Kernel::KEvent* deferral_event_) { deferral_event = deferral_event_; @@ -81,7 +79,7 @@ private: /// Map of registered services, retrieved using GetServicePort. std::mutex lock; - std::unordered_map<std::string, Kernel::SessionRequestHandlerPtr> registered_services; + std::unordered_map<std::string, SessionRequestHandlerPtr> registered_services; std::unordered_map<std::string, Kernel::KPort*> service_ports; /// Kernel context diff --git a/src/core/hle/service/sm/sm_controller.cpp b/src/core/hle/service/sm/sm_controller.cpp index f52522d1d..419c1df2b 100644 --- a/src/core/hle/service/sm/sm_controller.cpp +++ b/src/core/hle/service/sm/sm_controller.cpp @@ -4,18 +4,18 @@ #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_port.h" #include "core/hle/kernel/k_scoped_resource_reservation.h" #include "core/hle/kernel/k_server_session.h" #include "core/hle/kernel/k_session.h" +#include "core/hle/service/ipc_helpers.h" #include "core/hle/service/server_manager.h" #include "core/hle/service/sm/sm_controller.h" namespace Service::SM { -void Controller::ConvertCurrentObjectToDomain(Kernel::HLERequestContext& ctx) { +void Controller::ConvertCurrentObjectToDomain(HLERequestContext& ctx) { ASSERT_MSG(!ctx.GetManager()->IsDomain(), "Session is already a domain"); LOG_DEBUG(Service, "called, server_session={}", ctx.Session()->GetId()); ctx.GetManager()->ConvertToDomainOnRequestEnd(); @@ -25,7 +25,7 @@ void Controller::ConvertCurrentObjectToDomain(Kernel::HLERequestContext& ctx) { rb.Push<u32>(1); // Converted sessions start with 1 request handler } -void Controller::CloneCurrentObject(Kernel::HLERequestContext& ctx) { +void Controller::CloneCurrentObject(HLERequestContext& ctx) { LOG_DEBUG(Service, "called"); auto& process = *ctx.GetThread().GetOwnerProcess(); @@ -44,7 +44,7 @@ void Controller::CloneCurrentObject(Kernel::HLERequestContext& ctx) { ASSERT(session != nullptr); // Initialize the session. - session->Initialize(nullptr, ""); + session->Initialize(nullptr, 0); // Commit the session reservation. session_reservation.Commit(); @@ -59,13 +59,13 @@ void Controller::CloneCurrentObject(Kernel::HLERequestContext& ctx) { rb.PushMoveObjects(session->GetClientSession()); } -void Controller::CloneCurrentObjectEx(Kernel::HLERequestContext& ctx) { +void Controller::CloneCurrentObjectEx(HLERequestContext& ctx) { LOG_DEBUG(Service, "called"); CloneCurrentObject(ctx); } -void Controller::QueryPointerBufferSize(Kernel::HLERequestContext& ctx) { +void Controller::QueryPointerBufferSize(HLERequestContext& ctx) { LOG_WARNING(Service, "(STUBBED) called"); IPC::ResponseBuilder rb{ctx, 3}; diff --git a/src/core/hle/service/sm/sm_controller.h b/src/core/hle/service/sm/sm_controller.h index ed386f660..4e748b36d 100644 --- a/src/core/hle/service/sm/sm_controller.h +++ b/src/core/hle/service/sm/sm_controller.h @@ -17,10 +17,10 @@ public: ~Controller() override; private: - void ConvertCurrentObjectToDomain(Kernel::HLERequestContext& ctx); - void CloneCurrentObject(Kernel::HLERequestContext& ctx); - void CloneCurrentObjectEx(Kernel::HLERequestContext& ctx); - void QueryPointerBufferSize(Kernel::HLERequestContext& ctx); + void ConvertCurrentObjectToDomain(HLERequestContext& ctx); + void CloneCurrentObject(HLERequestContext& ctx); + void CloneCurrentObjectEx(HLERequestContext& ctx); + void QueryPointerBufferSize(HLERequestContext& ctx); }; } // namespace Service::SM diff --git a/src/core/hle/service/sockets/bsd.cpp b/src/core/hle/service/sockets/bsd.cpp index 2789fa1ed..bce45d321 100644 --- a/src/core/hle/service/sockets/bsd.cpp +++ b/src/core/hle/service/sockets/bsd.cpp @@ -11,8 +11,8 @@ #include "common/microprofile.h" #include "common/socket_types.h" #include "core/core.h" -#include "core/hle/ipc_helpers.h" #include "core/hle/kernel/k_thread.h" +#include "core/hle/service/ipc_helpers.h" #include "core/hle/service/sockets/bsd.h" #include "core/hle/service/sockets/sockets_translate.h" #include "core/internal_network/network.h" @@ -42,7 +42,7 @@ void BSD::PollWork::Execute(BSD* bsd) { std::tie(ret, bsd_errno) = bsd->PollImpl(write_buffer, read_buffer, nfds, timeout); } -void BSD::PollWork::Response(Kernel::HLERequestContext& ctx) { +void BSD::PollWork::Response(HLERequestContext& ctx) { if (write_buffer.size() > 0) { ctx.WriteBuffer(write_buffer); } @@ -57,7 +57,7 @@ void BSD::AcceptWork::Execute(BSD* bsd) { std::tie(ret, bsd_errno) = bsd->AcceptImpl(fd, write_buffer); } -void BSD::AcceptWork::Response(Kernel::HLERequestContext& ctx) { +void BSD::AcceptWork::Response(HLERequestContext& ctx) { if (write_buffer.size() > 0) { ctx.WriteBuffer(write_buffer); } @@ -73,7 +73,7 @@ void BSD::ConnectWork::Execute(BSD* bsd) { bsd_errno = bsd->ConnectImpl(fd, addr); } -void BSD::ConnectWork::Response(Kernel::HLERequestContext& ctx) { +void BSD::ConnectWork::Response(HLERequestContext& ctx) { IPC::ResponseBuilder rb{ctx, 4}; rb.Push(ResultSuccess); rb.Push<s32>(bsd_errno == Errno::SUCCESS ? 0 : -1); @@ -84,7 +84,7 @@ void BSD::RecvWork::Execute(BSD* bsd) { std::tie(ret, bsd_errno) = bsd->RecvImpl(fd, flags, message); } -void BSD::RecvWork::Response(Kernel::HLERequestContext& ctx) { +void BSD::RecvWork::Response(HLERequestContext& ctx) { ctx.WriteBuffer(message); IPC::ResponseBuilder rb{ctx, 4}; @@ -97,7 +97,7 @@ void BSD::RecvFromWork::Execute(BSD* bsd) { std::tie(ret, bsd_errno) = bsd->RecvFromImpl(fd, flags, message, addr); } -void BSD::RecvFromWork::Response(Kernel::HLERequestContext& ctx) { +void BSD::RecvFromWork::Response(HLERequestContext& ctx) { ctx.WriteBuffer(message, 0); if (!addr.empty()) { ctx.WriteBuffer(addr, 1); @@ -114,7 +114,7 @@ void BSD::SendWork::Execute(BSD* bsd) { std::tie(ret, bsd_errno) = bsd->SendImpl(fd, flags, message); } -void BSD::SendWork::Response(Kernel::HLERequestContext& ctx) { +void BSD::SendWork::Response(HLERequestContext& ctx) { IPC::ResponseBuilder rb{ctx, 4}; rb.Push(ResultSuccess); rb.Push<s32>(ret); @@ -125,14 +125,14 @@ void BSD::SendToWork::Execute(BSD* bsd) { std::tie(ret, bsd_errno) = bsd->SendToImpl(fd, flags, message, addr); } -void BSD::SendToWork::Response(Kernel::HLERequestContext& ctx) { +void BSD::SendToWork::Response(HLERequestContext& ctx) { IPC::ResponseBuilder rb{ctx, 4}; rb.Push(ResultSuccess); rb.Push<s32>(ret); rb.PushEnum(bsd_errno); } -void BSD::RegisterClient(Kernel::HLERequestContext& ctx) { +void BSD::RegisterClient(HLERequestContext& ctx) { LOG_WARNING(Service, "(STUBBED) called"); IPC::ResponseBuilder rb{ctx, 3}; @@ -141,7 +141,7 @@ void BSD::RegisterClient(Kernel::HLERequestContext& ctx) { rb.Push<s32>(0); // bsd errno } -void BSD::StartMonitoring(Kernel::HLERequestContext& ctx) { +void BSD::StartMonitoring(HLERequestContext& ctx) { LOG_WARNING(Service, "(STUBBED) called"); IPC::ResponseBuilder rb{ctx, 2}; @@ -149,7 +149,7 @@ void BSD::StartMonitoring(Kernel::HLERequestContext& ctx) { rb.Push(ResultSuccess); } -void BSD::Socket(Kernel::HLERequestContext& ctx) { +void BSD::Socket(HLERequestContext& ctx) { IPC::RequestParser rp{ctx}; const u32 domain = rp.Pop<u32>(); const u32 type = rp.Pop<u32>(); @@ -166,7 +166,7 @@ void BSD::Socket(Kernel::HLERequestContext& ctx) { rb.PushEnum(bsd_errno); } -void BSD::Select(Kernel::HLERequestContext& ctx) { +void BSD::Select(HLERequestContext& ctx) { LOG_WARNING(Service, "(STUBBED) called"); IPC::ResponseBuilder rb{ctx, 4}; @@ -176,7 +176,7 @@ void BSD::Select(Kernel::HLERequestContext& ctx) { rb.Push<u32>(0); // bsd errno } -void BSD::Poll(Kernel::HLERequestContext& ctx) { +void BSD::Poll(HLERequestContext& ctx) { IPC::RequestParser rp{ctx}; const s32 nfds = rp.Pop<s32>(); const s32 timeout = rp.Pop<s32>(); @@ -191,7 +191,7 @@ void BSD::Poll(Kernel::HLERequestContext& ctx) { }); } -void BSD::Accept(Kernel::HLERequestContext& ctx) { +void BSD::Accept(HLERequestContext& ctx) { IPC::RequestParser rp{ctx}; const s32 fd = rp.Pop<s32>(); @@ -203,7 +203,7 @@ void BSD::Accept(Kernel::HLERequestContext& ctx) { }); } -void BSD::Bind(Kernel::HLERequestContext& ctx) { +void BSD::Bind(HLERequestContext& ctx) { IPC::RequestParser rp{ctx}; const s32 fd = rp.Pop<s32>(); @@ -211,7 +211,7 @@ void BSD::Bind(Kernel::HLERequestContext& ctx) { BuildErrnoResponse(ctx, BindImpl(fd, ctx.ReadBuffer())); } -void BSD::Connect(Kernel::HLERequestContext& ctx) { +void BSD::Connect(HLERequestContext& ctx) { IPC::RequestParser rp{ctx}; const s32 fd = rp.Pop<s32>(); @@ -223,7 +223,7 @@ void BSD::Connect(Kernel::HLERequestContext& ctx) { }); } -void BSD::GetPeerName(Kernel::HLERequestContext& ctx) { +void BSD::GetPeerName(HLERequestContext& ctx) { IPC::RequestParser rp{ctx}; const s32 fd = rp.Pop<s32>(); @@ -241,7 +241,7 @@ void BSD::GetPeerName(Kernel::HLERequestContext& ctx) { rb.Push<u32>(static_cast<u32>(write_buffer.size())); } -void BSD::GetSockName(Kernel::HLERequestContext& ctx) { +void BSD::GetSockName(HLERequestContext& ctx) { IPC::RequestParser rp{ctx}; const s32 fd = rp.Pop<s32>(); @@ -259,7 +259,7 @@ void BSD::GetSockName(Kernel::HLERequestContext& ctx) { rb.Push<u32>(static_cast<u32>(write_buffer.size())); } -void BSD::GetSockOpt(Kernel::HLERequestContext& ctx) { +void BSD::GetSockOpt(HLERequestContext& ctx) { IPC::RequestParser rp{ctx}; const s32 fd = rp.Pop<s32>(); const u32 level = rp.Pop<u32>(); @@ -278,7 +278,7 @@ void BSD::GetSockOpt(Kernel::HLERequestContext& ctx) { rb.Push<u32>(static_cast<u32>(optval.size())); } -void BSD::Listen(Kernel::HLERequestContext& ctx) { +void BSD::Listen(HLERequestContext& ctx) { IPC::RequestParser rp{ctx}; const s32 fd = rp.Pop<s32>(); const s32 backlog = rp.Pop<s32>(); @@ -288,7 +288,7 @@ void BSD::Listen(Kernel::HLERequestContext& ctx) { BuildErrnoResponse(ctx, ListenImpl(fd, backlog)); } -void BSD::Fcntl(Kernel::HLERequestContext& ctx) { +void BSD::Fcntl(HLERequestContext& ctx) { IPC::RequestParser rp{ctx}; const s32 fd = rp.Pop<s32>(); const s32 cmd = rp.Pop<s32>(); @@ -304,7 +304,7 @@ void BSD::Fcntl(Kernel::HLERequestContext& ctx) { rb.PushEnum(bsd_errno); } -void BSD::SetSockOpt(Kernel::HLERequestContext& ctx) { +void BSD::SetSockOpt(HLERequestContext& ctx) { IPC::RequestParser rp{ctx}; const s32 fd = rp.Pop<s32>(); @@ -328,7 +328,7 @@ void BSD::SetSockOpt(Kernel::HLERequestContext& ctx) { BuildErrnoResponse(ctx, SetSockOptImpl(fd, level, optname, optlen, optval)); } -void BSD::Shutdown(Kernel::HLERequestContext& ctx) { +void BSD::Shutdown(HLERequestContext& ctx) { IPC::RequestParser rp{ctx}; const s32 fd = rp.Pop<s32>(); @@ -339,7 +339,7 @@ void BSD::Shutdown(Kernel::HLERequestContext& ctx) { BuildErrnoResponse(ctx, ShutdownImpl(fd, how)); } -void BSD::Recv(Kernel::HLERequestContext& ctx) { +void BSD::Recv(HLERequestContext& ctx) { IPC::RequestParser rp{ctx}; const s32 fd = rp.Pop<s32>(); @@ -354,7 +354,7 @@ void BSD::Recv(Kernel::HLERequestContext& ctx) { }); } -void BSD::RecvFrom(Kernel::HLERequestContext& ctx) { +void BSD::RecvFrom(HLERequestContext& ctx) { IPC::RequestParser rp{ctx}; const s32 fd = rp.Pop<s32>(); @@ -371,7 +371,7 @@ void BSD::RecvFrom(Kernel::HLERequestContext& ctx) { }); } -void BSD::Send(Kernel::HLERequestContext& ctx) { +void BSD::Send(HLERequestContext& ctx) { IPC::RequestParser rp{ctx}; const s32 fd = rp.Pop<s32>(); @@ -386,7 +386,7 @@ void BSD::Send(Kernel::HLERequestContext& ctx) { }); } -void BSD::SendTo(Kernel::HLERequestContext& ctx) { +void BSD::SendTo(HLERequestContext& ctx) { IPC::RequestParser rp{ctx}; const s32 fd = rp.Pop<s32>(); const u32 flags = rp.Pop<u32>(); @@ -402,7 +402,7 @@ void BSD::SendTo(Kernel::HLERequestContext& ctx) { }); } -void BSD::Write(Kernel::HLERequestContext& ctx) { +void BSD::Write(HLERequestContext& ctx) { IPC::RequestParser rp{ctx}; const s32 fd = rp.Pop<s32>(); @@ -415,7 +415,7 @@ void BSD::Write(Kernel::HLERequestContext& ctx) { }); } -void BSD::Read(Kernel::HLERequestContext& ctx) { +void BSD::Read(HLERequestContext& ctx) { IPC::RequestParser rp{ctx}; const s32 fd = rp.Pop<s32>(); @@ -427,7 +427,7 @@ void BSD::Read(Kernel::HLERequestContext& ctx) { rb.Push<u32>(0); // bsd errno } -void BSD::Close(Kernel::HLERequestContext& ctx) { +void BSD::Close(HLERequestContext& ctx) { IPC::RequestParser rp{ctx}; const s32 fd = rp.Pop<s32>(); @@ -436,7 +436,7 @@ void BSD::Close(Kernel::HLERequestContext& ctx) { BuildErrnoResponse(ctx, CloseImpl(fd)); } -void BSD::EventFd(Kernel::HLERequestContext& ctx) { +void BSD::EventFd(HLERequestContext& ctx) { IPC::RequestParser rp{ctx}; const u64 initval = rp.Pop<u64>(); const u32 flags = rp.Pop<u32>(); @@ -447,7 +447,7 @@ void BSD::EventFd(Kernel::HLERequestContext& ctx) { } template <typename Work> -void BSD::ExecuteWork(Kernel::HLERequestContext& ctx, Work work) { +void BSD::ExecuteWork(HLERequestContext& ctx, Work work) { work.Execute(this); work.Response(ctx); } @@ -862,7 +862,7 @@ bool BSD::IsFileDescriptorValid(s32 fd) const noexcept { return true; } -void BSD::BuildErrnoResponse(Kernel::HLERequestContext& ctx, Errno bsd_errno) const noexcept { +void BSD::BuildErrnoResponse(HLERequestContext& ctx, Errno bsd_errno) const noexcept { IPC::ResponseBuilder rb{ctx, 4}; rb.Push(ResultSuccess); diff --git a/src/core/hle/service/sockets/bsd.h b/src/core/hle/service/sockets/bsd.h index 56bb3f8b1..30ae9c140 100644 --- a/src/core/hle/service/sockets/bsd.h +++ b/src/core/hle/service/sockets/bsd.h @@ -41,7 +41,7 @@ private: struct PollWork { void Execute(BSD* bsd); - void Response(Kernel::HLERequestContext& ctx); + void Response(HLERequestContext& ctx); s32 nfds; s32 timeout; @@ -53,7 +53,7 @@ private: struct AcceptWork { void Execute(BSD* bsd); - void Response(Kernel::HLERequestContext& ctx); + void Response(HLERequestContext& ctx); s32 fd; std::vector<u8> write_buffer; @@ -63,7 +63,7 @@ private: struct ConnectWork { void Execute(BSD* bsd); - void Response(Kernel::HLERequestContext& ctx); + void Response(HLERequestContext& ctx); s32 fd; std::span<const u8> addr; @@ -72,7 +72,7 @@ private: struct RecvWork { void Execute(BSD* bsd); - void Response(Kernel::HLERequestContext& ctx); + void Response(HLERequestContext& ctx); s32 fd; u32 flags; @@ -83,7 +83,7 @@ private: struct RecvFromWork { void Execute(BSD* bsd); - void Response(Kernel::HLERequestContext& ctx); + void Response(HLERequestContext& ctx); s32 fd; u32 flags; @@ -95,7 +95,7 @@ private: struct SendWork { void Execute(BSD* bsd); - void Response(Kernel::HLERequestContext& ctx); + void Response(HLERequestContext& ctx); s32 fd; u32 flags; @@ -106,7 +106,7 @@ private: struct SendToWork { void Execute(BSD* bsd); - void Response(Kernel::HLERequestContext& ctx); + void Response(HLERequestContext& ctx); s32 fd; u32 flags; @@ -116,32 +116,32 @@ private: Errno bsd_errno{}; }; - void RegisterClient(Kernel::HLERequestContext& ctx); - void StartMonitoring(Kernel::HLERequestContext& ctx); - void Socket(Kernel::HLERequestContext& ctx); - void Select(Kernel::HLERequestContext& ctx); - void Poll(Kernel::HLERequestContext& ctx); - void Accept(Kernel::HLERequestContext& ctx); - void Bind(Kernel::HLERequestContext& ctx); - void Connect(Kernel::HLERequestContext& ctx); - void GetPeerName(Kernel::HLERequestContext& ctx); - void GetSockName(Kernel::HLERequestContext& ctx); - void GetSockOpt(Kernel::HLERequestContext& ctx); - void Listen(Kernel::HLERequestContext& ctx); - void Fcntl(Kernel::HLERequestContext& ctx); - void SetSockOpt(Kernel::HLERequestContext& ctx); - void Shutdown(Kernel::HLERequestContext& ctx); - void Recv(Kernel::HLERequestContext& ctx); - void RecvFrom(Kernel::HLERequestContext& ctx); - void Send(Kernel::HLERequestContext& ctx); - void SendTo(Kernel::HLERequestContext& ctx); - void Write(Kernel::HLERequestContext& ctx); - void Read(Kernel::HLERequestContext& ctx); - void Close(Kernel::HLERequestContext& ctx); - void EventFd(Kernel::HLERequestContext& ctx); + void RegisterClient(HLERequestContext& ctx); + void StartMonitoring(HLERequestContext& ctx); + void Socket(HLERequestContext& ctx); + void Select(HLERequestContext& ctx); + void Poll(HLERequestContext& ctx); + void Accept(HLERequestContext& ctx); + void Bind(HLERequestContext& ctx); + void Connect(HLERequestContext& ctx); + void GetPeerName(HLERequestContext& ctx); + void GetSockName(HLERequestContext& ctx); + void GetSockOpt(HLERequestContext& ctx); + void Listen(HLERequestContext& ctx); + void Fcntl(HLERequestContext& ctx); + void SetSockOpt(HLERequestContext& ctx); + void Shutdown(HLERequestContext& ctx); + void Recv(HLERequestContext& ctx); + void RecvFrom(HLERequestContext& ctx); + void Send(HLERequestContext& ctx); + void SendTo(HLERequestContext& ctx); + void Write(HLERequestContext& ctx); + void Read(HLERequestContext& ctx); + void Close(HLERequestContext& ctx); + void EventFd(HLERequestContext& ctx); template <typename Work> - void ExecuteWork(Kernel::HLERequestContext& ctx, Work work); + void ExecuteWork(HLERequestContext& ctx, Work work); std::pair<s32, Errno> SocketImpl(Domain domain, Type type, Protocol protocol); std::pair<s32, Errno> PollImpl(std::vector<u8>& write_buffer, std::span<const u8> read_buffer, @@ -166,7 +166,7 @@ private: s32 FindFreeFileDescriptorHandle() noexcept; bool IsFileDescriptorValid(s32 fd) const noexcept; - void BuildErrnoResponse(Kernel::HLERequestContext& ctx, Errno bsd_errno) const noexcept; + void BuildErrnoResponse(HLERequestContext& ctx, Errno bsd_errno) const noexcept; std::array<std::optional<FileDescriptor>, MAX_FD> file_descriptors; diff --git a/src/core/hle/service/sockets/sfdnsres.cpp b/src/core/hle/service/sockets/sfdnsres.cpp index e96eda7f3..132dd5797 100644 --- a/src/core/hle/service/sockets/sfdnsres.cpp +++ b/src/core/hle/service/sockets/sfdnsres.cpp @@ -8,7 +8,7 @@ #include "common/string_util.h" #include "common/swap.h" #include "core/core.h" -#include "core/hle/ipc_helpers.h" +#include "core/hle/service/ipc_helpers.h" #include "core/hle/service/sockets/sfdnsres.h" #include "core/memory.h" @@ -185,7 +185,7 @@ static std::vector<u8> SerializeAddrInfo(const addrinfo* addrinfo, s32 result_co return data; } -static std::pair<u32, s32> GetAddrInfoRequestImpl(Kernel::HLERequestContext& ctx) { +static std::pair<u32, s32> GetAddrInfoRequestImpl(HLERequestContext& ctx) { struct Parameters { u8 use_nsd_resolve; u32 unknown; @@ -221,7 +221,7 @@ static std::pair<u32, s32> GetAddrInfoRequestImpl(Kernel::HLERequestContext& ctx return std::make_pair(data_size, result_code); } -void SFDNSRES::GetAddrInfoRequest(Kernel::HLERequestContext& ctx) { +void SFDNSRES::GetAddrInfoRequest(HLERequestContext& ctx) { auto [data_size, result_code] = GetAddrInfoRequestImpl(ctx); IPC::ResponseBuilder rb{ctx, 4}; @@ -231,7 +231,7 @@ void SFDNSRES::GetAddrInfoRequest(Kernel::HLERequestContext& ctx) { rb.Push(data_size); // serialized size } -void SFDNSRES::GetAddrInfoRequestWithOptions(Kernel::HLERequestContext& ctx) { +void SFDNSRES::GetAddrInfoRequestWithOptions(HLERequestContext& ctx) { // Additional options are ignored auto [data_size, result_code] = GetAddrInfoRequestImpl(ctx); diff --git a/src/core/hle/service/sockets/sfdnsres.h b/src/core/hle/service/sockets/sfdnsres.h index 96018ea77..18e3cd60c 100644 --- a/src/core/hle/service/sockets/sfdnsres.h +++ b/src/core/hle/service/sockets/sfdnsres.h @@ -17,8 +17,8 @@ public: ~SFDNSRES() override; private: - void GetAddrInfoRequest(Kernel::HLERequestContext& ctx); - void GetAddrInfoRequestWithOptions(Kernel::HLERequestContext& ctx); + void GetAddrInfoRequest(HLERequestContext& ctx); + void GetAddrInfoRequestWithOptions(HLERequestContext& ctx); }; } // namespace Service::Sockets diff --git a/src/core/hle/service/spl/spl_module.cpp b/src/core/hle/service/spl/spl_module.cpp index 31679e1bb..0227d4393 100644 --- a/src/core/hle/service/spl/spl_module.cpp +++ b/src/core/hle/service/spl/spl_module.cpp @@ -8,7 +8,7 @@ #include "common/logging/log.h" #include "common/settings.h" #include "core/hle/api_version.h" -#include "core/hle/ipc_helpers.h" +#include "core/hle/service/ipc_helpers.h" #include "core/hle/service/server_manager.h" #include "core/hle/service/spl/csrng.h" #include "core/hle/service/spl/spl.h" @@ -23,7 +23,7 @@ Module::Interface::Interface(Core::System& system_, std::shared_ptr<Module> modu Module::Interface::~Interface() = default; -void Module::Interface::GetConfig(Kernel::HLERequestContext& ctx) { +void Module::Interface::GetConfig(HLERequestContext& ctx) { IPC::RequestParser rp{ctx}; const auto config_item = rp.PopEnum<ConfigItem>(); @@ -48,21 +48,21 @@ void Module::Interface::GetConfig(Kernel::HLERequestContext& ctx) { rb.Push(*smc_result); } -void Module::Interface::ModularExponentiate(Kernel::HLERequestContext& ctx) { +void Module::Interface::ModularExponentiate(HLERequestContext& ctx) { UNIMPLEMENTED_MSG("ModularExponentiate is not implemented!"); IPC::ResponseBuilder rb{ctx, 2}; rb.Push(ResultSecureMonitorNotImplemented); } -void Module::Interface::SetConfig(Kernel::HLERequestContext& ctx) { +void Module::Interface::SetConfig(HLERequestContext& ctx) { UNIMPLEMENTED_MSG("SetConfig is not implemented!"); IPC::ResponseBuilder rb{ctx, 2}; rb.Push(ResultSecureMonitorNotImplemented); } -void Module::Interface::GenerateRandomBytes(Kernel::HLERequestContext& ctx) { +void Module::Interface::GenerateRandomBytes(HLERequestContext& ctx) { LOG_DEBUG(Service_SPL, "called"); const std::size_t size = ctx.GetWriteBufferSize(); @@ -77,21 +77,21 @@ void Module::Interface::GenerateRandomBytes(Kernel::HLERequestContext& ctx) { rb.Push(ResultSuccess); } -void Module::Interface::IsDevelopment(Kernel::HLERequestContext& ctx) { +void Module::Interface::IsDevelopment(HLERequestContext& ctx) { UNIMPLEMENTED_MSG("IsDevelopment is not implemented!"); IPC::ResponseBuilder rb{ctx, 2}; rb.Push(ResultSecureMonitorNotImplemented); } -void Module::Interface::SetBootReason(Kernel::HLERequestContext& ctx) { +void Module::Interface::SetBootReason(HLERequestContext& ctx) { UNIMPLEMENTED_MSG("SetBootReason is not implemented!"); IPC::ResponseBuilder rb{ctx, 2}; rb.Push(ResultSecureMonitorNotImplemented); } -void Module::Interface::GetBootReason(Kernel::HLERequestContext& ctx) { +void Module::Interface::GetBootReason(HLERequestContext& ctx) { UNIMPLEMENTED_MSG("GetBootReason is not implemented!"); IPC::ResponseBuilder rb{ctx, 2}; diff --git a/src/core/hle/service/spl/spl_module.h b/src/core/hle/service/spl/spl_module.h index baed9efd7..e074e115d 100644 --- a/src/core/hle/service/spl/spl_module.h +++ b/src/core/hle/service/spl/spl_module.h @@ -23,13 +23,13 @@ public: ~Interface() override; // General - void GetConfig(Kernel::HLERequestContext& ctx); - void ModularExponentiate(Kernel::HLERequestContext& ctx); - void SetConfig(Kernel::HLERequestContext& ctx); - void GenerateRandomBytes(Kernel::HLERequestContext& ctx); - void IsDevelopment(Kernel::HLERequestContext& ctx); - void SetBootReason(Kernel::HLERequestContext& ctx); - void GetBootReason(Kernel::HLERequestContext& ctx); + void GetConfig(HLERequestContext& ctx); + void ModularExponentiate(HLERequestContext& ctx); + void SetConfig(HLERequestContext& ctx); + void GenerateRandomBytes(HLERequestContext& ctx); + void IsDevelopment(HLERequestContext& ctx); + void SetBootReason(HLERequestContext& ctx); + void GetBootReason(HLERequestContext& ctx); protected: std::shared_ptr<Module> module; diff --git a/src/core/hle/service/ssl/ssl.cpp b/src/core/hle/service/ssl/ssl.cpp index c1fd1a59b..2b99dd7ac 100644 --- a/src/core/hle/service/ssl/ssl.cpp +++ b/src/core/hle/service/ssl/ssl.cpp @@ -1,21 +1,43 @@ // SPDX-FileCopyrightText: Copyright 2018 yuzu Emulator Project // SPDX-License-Identifier: GPL-2.0-or-later -#include "core/hle/ipc_helpers.h" +#include "core/hle/service/ipc_helpers.h" #include "core/hle/service/server_manager.h" #include "core/hle/service/service.h" #include "core/hle/service/ssl/ssl.h" namespace Service::SSL { +// This is nn::ssl::sf::CertificateFormat enum class CertificateFormat : u32 { Pem = 1, Der = 2, }; +// This is nn::ssl::sf::ContextOption +enum class ContextOption : u32 { + None = 0, + CrlImportDateCheckEnable = 1, +}; + +// This is nn::ssl::sf::SslVersion +struct SslVersion { + union { + u32 raw{}; + + BitField<0, 1, u32> tls_auto; + BitField<3, 1, u32> tls_v10; + BitField<4, 1, u32> tls_v11; + BitField<5, 1, u32> tls_v12; + BitField<6, 1, u32> tls_v13; + BitField<24, 7, u32> api_version; + }; +}; + class ISslConnection final : public ServiceFramework<ISslConnection> { public: - explicit ISslConnection(Core::System& system_) : ServiceFramework{system_, "ISslConnection"} { + explicit ISslConnection(Core::System& system_, SslVersion version) + : ServiceFramework{system_, "ISslConnection"}, ssl_version{version} { // clang-format off static const FunctionInfo functions[] = { {0, nullptr, "SetSocketDescriptor"}, @@ -59,11 +81,15 @@ public: RegisterHandlers(functions); } + +private: + SslVersion ssl_version; }; class ISslContext final : public ServiceFramework<ISslContext> { public: - explicit ISslContext(Core::System& system_) : ServiceFramework{system_, "ISslContext"} { + explicit ISslContext(Core::System& system_, SslVersion version) + : ServiceFramework{system_, "ISslContext"}, ssl_version{version} { static const FunctionInfo functions[] = { {0, &ISslContext::SetOption, "SetOption"}, {1, nullptr, "GetOption"}, @@ -84,31 +110,34 @@ public: } private: - void SetOption(Kernel::HLERequestContext& ctx) { + SslVersion ssl_version; + + void SetOption(HLERequestContext& ctx) { struct Parameters { - u8 enable; - u32 option; + ContextOption option; + s32 value; }; + static_assert(sizeof(Parameters) == 0x8, "Parameters is an invalid size"); IPC::RequestParser rp{ctx}; const auto parameters = rp.PopRaw<Parameters>(); - LOG_WARNING(Service_SSL, "(STUBBED) called. enable={}, option={}", parameters.enable, - parameters.option); + LOG_WARNING(Service_SSL, "(STUBBED) called. option={}, value={}", parameters.option, + parameters.value); IPC::ResponseBuilder rb{ctx, 2}; rb.Push(ResultSuccess); } - void CreateConnection(Kernel::HLERequestContext& ctx) { + void CreateConnection(HLERequestContext& ctx) { LOG_WARNING(Service_SSL, "(STUBBED) called"); IPC::ResponseBuilder rb{ctx, 2, 0, 1}; rb.Push(ResultSuccess); - rb.PushIpcInterface<ISslConnection>(system); + rb.PushIpcInterface<ISslConnection>(system, ssl_version); } - void ImportServerPki(Kernel::HLERequestContext& ctx) { + void ImportServerPki(HLERequestContext& ctx) { IPC::RequestParser rp{ctx}; const auto certificate_format = rp.PopEnum<CertificateFormat>(); [[maybe_unused]] const auto pkcs_12_certificates = ctx.ReadBuffer(0); @@ -122,7 +151,7 @@ private: rb.Push(server_id); } - void ImportClientPki(Kernel::HLERequestContext& ctx) { + void ImportClientPki(HLERequestContext& ctx) { [[maybe_unused]] const auto pkcs_12_certificate = ctx.ReadBuffer(0); [[maybe_unused]] const auto ascii_password = [&ctx] { if (ctx.CanReadBuffer(1)) { @@ -142,20 +171,21 @@ private: } }; -class SSL final : public ServiceFramework<SSL> { +class ISslService final : public ServiceFramework<ISslService> { public: - explicit SSL(Core::System& system_) : ServiceFramework{system_, "ssl"} { + explicit ISslService(Core::System& system_) : ServiceFramework{system_, "ssl"} { // clang-format off static const FunctionInfo functions[] = { - {0, &SSL::CreateContext, "CreateContext"}, + {0, &ISslService::CreateContext, "CreateContext"}, {1, nullptr, "GetContextCount"}, {2, nullptr, "GetCertificates"}, {3, nullptr, "GetCertificateBufSize"}, {4, nullptr, "DebugIoctl"}, - {5, &SSL::SetInterfaceVersion, "SetInterfaceVersion"}, + {5, &ISslService::SetInterfaceVersion, "SetInterfaceVersion"}, {6, nullptr, "FlushSessionCache"}, {7, nullptr, "SetDebugOption"}, {8, nullptr, "GetDebugOption"}, + {8, nullptr, "ClearTls12FallbackFlag"}, }; // clang-format on @@ -163,20 +193,30 @@ public: } private: - u32 ssl_version{}; - void CreateContext(Kernel::HLERequestContext& ctx) { - LOG_WARNING(Service_SSL, "(STUBBED) called"); + void CreateContext(HLERequestContext& ctx) { + struct Parameters { + SslVersion ssl_version; + INSERT_PADDING_BYTES(0x4); + u64 pid_placeholder; + }; + static_assert(sizeof(Parameters) == 0x10, "Parameters is an invalid size"); + + IPC::RequestParser rp{ctx}; + const auto parameters = rp.PopRaw<Parameters>(); + + LOG_WARNING(Service_SSL, "(STUBBED) called, api_version={}, pid_placeholder={}", + parameters.ssl_version.api_version, parameters.pid_placeholder); IPC::ResponseBuilder rb{ctx, 2, 0, 1}; rb.Push(ResultSuccess); - rb.PushIpcInterface<ISslContext>(system); + rb.PushIpcInterface<ISslContext>(system, parameters.ssl_version); } - void SetInterfaceVersion(Kernel::HLERequestContext& ctx) { - LOG_DEBUG(Service_SSL, "called"); - + void SetInterfaceVersion(HLERequestContext& ctx) { IPC::RequestParser rp{ctx}; - ssl_version = rp.Pop<u32>(); + u32 ssl_version = rp.Pop<u32>(); + + LOG_DEBUG(Service_SSL, "called, ssl_version={}", ssl_version); IPC::ResponseBuilder rb{ctx, 2}; rb.Push(ResultSuccess); @@ -186,7 +226,7 @@ private: void LoopProcess(Core::System& system) { auto server_manager = std::make_unique<ServerManager>(system); - server_manager->RegisterNamedService("ssl", std::make_shared<SSL>(system)); + server_manager->RegisterNamedService("ssl", std::make_shared<ISslService>(system)); ServerManager::RunServer(std::move(server_manager)); } diff --git a/src/core/hle/service/time/time.cpp b/src/core/hle/service/time/time.cpp index 8020e407c..868be60c5 100644 --- a/src/core/hle/service/time/time.cpp +++ b/src/core/hle/service/time/time.cpp @@ -5,8 +5,8 @@ #include "core/core.h" #include "core/core_timing.h" #include "core/hardware_properties.h" -#include "core/hle/ipc_helpers.h" #include "core/hle/kernel/kernel.h" +#include "core/hle/service/ipc_helpers.h" #include "core/hle/service/server_manager.h" #include "core/hle/service/time/time.h" #include "core/hle/service/time/time_interface.h" @@ -34,7 +34,7 @@ public: } private: - void GetCurrentTime(Kernel::HLERequestContext& ctx) { + void GetCurrentTime(HLERequestContext& ctx) { LOG_DEBUG(Service_Time, "called"); if (!clock_core.IsInitialized()) { @@ -55,7 +55,7 @@ private: rb.Push<s64>(posix_time); } - void GetSystemClockContext(Kernel::HLERequestContext& ctx) { + void GetSystemClockContext(HLERequestContext& ctx) { LOG_DEBUG(Service_Time, "called"); if (!clock_core.IsInitialized()) { @@ -98,7 +98,7 @@ public: } private: - void GetCurrentTimePoint(Kernel::HLERequestContext& ctx) { + void GetCurrentTimePoint(HLERequestContext& ctx) { LOG_DEBUG(Service_Time, "called"); if (!clock_core.IsInitialized()) { @@ -178,7 +178,7 @@ Result Module::Interface::GetClockSnapshotFromSystemClockContextInternal( return ResultSuccess; } -void Module::Interface::GetStandardUserSystemClock(Kernel::HLERequestContext& ctx) { +void Module::Interface::GetStandardUserSystemClock(HLERequestContext& ctx) { LOG_DEBUG(Service_Time, "called"); IPC::ResponseBuilder rb{ctx, 2, 0, 1}; rb.Push(ResultSuccess); @@ -186,7 +186,7 @@ void Module::Interface::GetStandardUserSystemClock(Kernel::HLERequestContext& ct system); } -void Module::Interface::GetStandardNetworkSystemClock(Kernel::HLERequestContext& ctx) { +void Module::Interface::GetStandardNetworkSystemClock(HLERequestContext& ctx) { LOG_DEBUG(Service_Time, "called"); IPC::ResponseBuilder rb{ctx, 2, 0, 1}; rb.Push(ResultSuccess); @@ -194,14 +194,14 @@ void Module::Interface::GetStandardNetworkSystemClock(Kernel::HLERequestContext& system); } -void Module::Interface::GetStandardSteadyClock(Kernel::HLERequestContext& ctx) { +void Module::Interface::GetStandardSteadyClock(HLERequestContext& ctx) { LOG_DEBUG(Service_Time, "called"); IPC::ResponseBuilder rb{ctx, 2, 0, 1}; rb.Push(ResultSuccess); rb.PushIpcInterface<ISteadyClock>(system.GetTimeManager().GetStandardSteadyClockCore(), system); } -void Module::Interface::GetTimeZoneService(Kernel::HLERequestContext& ctx) { +void Module::Interface::GetTimeZoneService(HLERequestContext& ctx) { LOG_DEBUG(Service_Time, "called"); IPC::ResponseBuilder rb{ctx, 2, 0, 1}; rb.Push(ResultSuccess); @@ -209,7 +209,7 @@ void Module::Interface::GetTimeZoneService(Kernel::HLERequestContext& ctx) { system.GetTimeManager().GetTimeZoneContentManager()); } -void Module::Interface::GetStandardLocalSystemClock(Kernel::HLERequestContext& ctx) { +void Module::Interface::GetStandardLocalSystemClock(HLERequestContext& ctx) { LOG_DEBUG(Service_Time, "called"); IPC::ResponseBuilder rb{ctx, 2, 0, 1}; rb.Push(ResultSuccess); @@ -217,8 +217,7 @@ void Module::Interface::GetStandardLocalSystemClock(Kernel::HLERequestContext& c system); } -void Module::Interface::IsStandardNetworkSystemClockAccuracySufficient( - Kernel::HLERequestContext& ctx) { +void Module::Interface::IsStandardNetworkSystemClockAccuracySufficient(HLERequestContext& ctx) { LOG_DEBUG(Service_Time, "called"); auto& clock_core{system.GetTimeManager().GetStandardNetworkSystemClockCore()}; IPC::ResponseBuilder rb{ctx, 3}; @@ -226,7 +225,7 @@ void Module::Interface::IsStandardNetworkSystemClockAccuracySufficient( rb.Push<u32>(clock_core.IsStandardNetworkSystemClockAccuracySufficient(system)); } -void Module::Interface::CalculateMonotonicSystemClockBaseTimePoint(Kernel::HLERequestContext& ctx) { +void Module::Interface::CalculateMonotonicSystemClockBaseTimePoint(HLERequestContext& ctx) { LOG_DEBUG(Service_Time, "called"); auto& steady_clock_core{system.GetTimeManager().GetStandardSteadyClockCore()}; @@ -255,7 +254,7 @@ void Module::Interface::CalculateMonotonicSystemClockBaseTimePoint(Kernel::HLERe rb.Push(ERROR_TIME_MISMATCH); } -void Module::Interface::GetClockSnapshot(Kernel::HLERequestContext& ctx) { +void Module::Interface::GetClockSnapshot(HLERequestContext& ctx) { IPC::RequestParser rp{ctx}; const auto type{rp.PopEnum<Clock::TimeType>()}; @@ -296,7 +295,7 @@ void Module::Interface::GetClockSnapshot(Kernel::HLERequestContext& ctx) { rb.Push(ResultSuccess); } -void Module::Interface::GetClockSnapshotFromSystemClockContext(Kernel::HLERequestContext& ctx) { +void Module::Interface::GetClockSnapshotFromSystemClockContext(HLERequestContext& ctx) { IPC::RequestParser rp{ctx}; const auto type{rp.PopEnum<Clock::TimeType>()}; @@ -322,8 +321,7 @@ void Module::Interface::GetClockSnapshotFromSystemClockContext(Kernel::HLEReques rb.Push(ResultSuccess); } -void Module::Interface::CalculateStandardUserSystemClockDifferenceByUser( - Kernel::HLERequestContext& ctx) { +void Module::Interface::CalculateStandardUserSystemClockDifferenceByUser(HLERequestContext& ctx) { LOG_DEBUG(Service_Time, "called"); Clock::ClockSnapshot snapshot_a; @@ -350,7 +348,7 @@ void Module::Interface::CalculateStandardUserSystemClockDifferenceByUser( rb.PushRaw(time_span_type.nanoseconds); } -void Module::Interface::CalculateSpanBetween(Kernel::HLERequestContext& ctx) { +void Module::Interface::CalculateSpanBetween(HLERequestContext& ctx) { LOG_DEBUG(Service_Time, "called"); Clock::ClockSnapshot snapshot_a; @@ -385,7 +383,7 @@ void Module::Interface::CalculateSpanBetween(Kernel::HLERequestContext& ctx) { rb.PushRaw(time_span_type.nanoseconds); } -void Module::Interface::GetSharedMemoryNativeHandle(Kernel::HLERequestContext& ctx) { +void Module::Interface::GetSharedMemoryNativeHandle(HLERequestContext& ctx) { LOG_DEBUG(Service_Time, "called"); IPC::ResponseBuilder rb{ctx, 2, 1}; rb.Push(ResultSuccess); diff --git a/src/core/hle/service/time/time.h b/src/core/hle/service/time/time.h index c9936c645..b2d754ef3 100644 --- a/src/core/hle/service/time/time.h +++ b/src/core/hle/service/time/time.h @@ -22,18 +22,18 @@ public: const char* name); ~Interface() override; - void GetStandardUserSystemClock(Kernel::HLERequestContext& ctx); - void GetStandardNetworkSystemClock(Kernel::HLERequestContext& ctx); - void GetStandardSteadyClock(Kernel::HLERequestContext& ctx); - void GetTimeZoneService(Kernel::HLERequestContext& ctx); - void GetStandardLocalSystemClock(Kernel::HLERequestContext& ctx); - void IsStandardNetworkSystemClockAccuracySufficient(Kernel::HLERequestContext& ctx); - void CalculateMonotonicSystemClockBaseTimePoint(Kernel::HLERequestContext& ctx); - void GetClockSnapshot(Kernel::HLERequestContext& ctx); - void GetClockSnapshotFromSystemClockContext(Kernel::HLERequestContext& ctx); - void CalculateStandardUserSystemClockDifferenceByUser(Kernel::HLERequestContext& ctx); - void CalculateSpanBetween(Kernel::HLERequestContext& ctx); - void GetSharedMemoryNativeHandle(Kernel::HLERequestContext& ctx); + void GetStandardUserSystemClock(HLERequestContext& ctx); + void GetStandardNetworkSystemClock(HLERequestContext& ctx); + void GetStandardSteadyClock(HLERequestContext& ctx); + void GetTimeZoneService(HLERequestContext& ctx); + void GetStandardLocalSystemClock(HLERequestContext& ctx); + void IsStandardNetworkSystemClockAccuracySufficient(HLERequestContext& ctx); + void CalculateMonotonicSystemClockBaseTimePoint(HLERequestContext& ctx); + void GetClockSnapshot(HLERequestContext& ctx); + void GetClockSnapshotFromSystemClockContext(HLERequestContext& ctx); + void CalculateStandardUserSystemClockDifferenceByUser(HLERequestContext& ctx); + void CalculateSpanBetween(HLERequestContext& ctx); + void GetSharedMemoryNativeHandle(HLERequestContext& ctx); private: Result GetClockSnapshotFromSystemClockContextInternal( diff --git a/src/core/hle/service/time/time_zone_service.cpp b/src/core/hle/service/time/time_zone_service.cpp index 961040bfc..cda8d8343 100644 --- a/src/core/hle/service/time/time_zone_service.cpp +++ b/src/core/hle/service/time/time_zone_service.cpp @@ -2,7 +2,7 @@ // SPDX-License-Identifier: GPL-2.0-or-later #include "common/logging/log.h" -#include "core/hle/ipc_helpers.h" +#include "core/hle/service/ipc_helpers.h" #include "core/hle/service/time/time_zone_content_manager.h" #include "core/hle/service/time/time_zone_service.h" #include "core/hle/service/time/time_zone_types.h" @@ -28,7 +28,7 @@ ITimeZoneService::ITimeZoneService(Core::System& system_, RegisterHandlers(functions); } -void ITimeZoneService::GetDeviceLocationName(Kernel::HLERequestContext& ctx) { +void ITimeZoneService::GetDeviceLocationName(HLERequestContext& ctx) { LOG_DEBUG(Service_Time, "called"); TimeZone::LocationName location_name{}; @@ -45,7 +45,7 @@ void ITimeZoneService::GetDeviceLocationName(Kernel::HLERequestContext& ctx) { rb.PushRaw(location_name); } -void ITimeZoneService::LoadTimeZoneRule(Kernel::HLERequestContext& ctx) { +void ITimeZoneService::LoadTimeZoneRule(HLERequestContext& ctx) { IPC::RequestParser rp{ctx}; const auto raw_location_name{rp.PopRaw<std::array<u8, 0x24>>()}; @@ -77,7 +77,7 @@ void ITimeZoneService::LoadTimeZoneRule(Kernel::HLERequestContext& ctx) { rb.Push(ResultSuccess); } -void ITimeZoneService::ToCalendarTime(Kernel::HLERequestContext& ctx) { +void ITimeZoneService::ToCalendarTime(HLERequestContext& ctx) { IPC::RequestParser rp{ctx}; const auto posix_time{rp.Pop<s64>()}; @@ -101,7 +101,7 @@ void ITimeZoneService::ToCalendarTime(Kernel::HLERequestContext& ctx) { rb.PushRaw(calendar_info); } -void ITimeZoneService::ToCalendarTimeWithMyRule(Kernel::HLERequestContext& ctx) { +void ITimeZoneService::ToCalendarTimeWithMyRule(HLERequestContext& ctx) { IPC::RequestParser rp{ctx}; const auto posix_time{rp.Pop<s64>()}; @@ -122,7 +122,7 @@ void ITimeZoneService::ToCalendarTimeWithMyRule(Kernel::HLERequestContext& ctx) rb.PushRaw(calendar_info); } -void ITimeZoneService::ToPosixTime(Kernel::HLERequestContext& ctx) { +void ITimeZoneService::ToPosixTime(HLERequestContext& ctx) { LOG_DEBUG(Service_Time, "called"); IPC::RequestParser rp{ctx}; @@ -147,7 +147,7 @@ void ITimeZoneService::ToPosixTime(Kernel::HLERequestContext& ctx) { rb.PushRaw<u32>(1); // Number of times we're returning } -void ITimeZoneService::ToPosixTimeWithMyRule(Kernel::HLERequestContext& ctx) { +void ITimeZoneService::ToPosixTimeWithMyRule(HLERequestContext& ctx) { LOG_DEBUG(Service_Time, "called"); IPC::RequestParser rp{ctx}; diff --git a/src/core/hle/service/time/time_zone_service.h b/src/core/hle/service/time/time_zone_service.h index f151f4b56..ea83b5714 100644 --- a/src/core/hle/service/time/time_zone_service.h +++ b/src/core/hle/service/time/time_zone_service.h @@ -21,12 +21,12 @@ public: TimeZone::TimeZoneContentManager& time_zone_manager_); private: - void GetDeviceLocationName(Kernel::HLERequestContext& ctx); - void LoadTimeZoneRule(Kernel::HLERequestContext& ctx); - void ToCalendarTime(Kernel::HLERequestContext& ctx); - void ToCalendarTimeWithMyRule(Kernel::HLERequestContext& ctx); - void ToPosixTime(Kernel::HLERequestContext& ctx); - void ToPosixTimeWithMyRule(Kernel::HLERequestContext& ctx); + void GetDeviceLocationName(HLERequestContext& ctx); + void LoadTimeZoneRule(HLERequestContext& ctx); + void ToCalendarTime(HLERequestContext& ctx); + void ToCalendarTimeWithMyRule(HLERequestContext& ctx); + void ToPosixTime(HLERequestContext& ctx); + void ToPosixTimeWithMyRule(HLERequestContext& ctx); private: TimeZone::TimeZoneContentManager& time_zone_content_manager; diff --git a/src/core/hle/service/usb/usb.cpp b/src/core/hle/service/usb/usb.cpp index ddb73f394..f29fff1dd 100644 --- a/src/core/hle/service/usb/usb.cpp +++ b/src/core/hle/service/usb/usb.cpp @@ -4,7 +4,7 @@ #include <memory> #include "common/logging/log.h" -#include "core/hle/ipc_helpers.h" +#include "core/hle/service/ipc_helpers.h" #include "core/hle/service/server_manager.h" #include "core/hle/service/service.h" #include "core/hle/service/usb/usb.h" @@ -16,19 +16,19 @@ public: explicit IDsInterface(Core::System& system_) : ServiceFramework{system_, "IDsInterface"} { // clang-format off static const FunctionInfo functions[] = { - {0, nullptr, "BindDevice"}, - {1, nullptr, "BindClientProcess"}, - {2, nullptr, "AddInterface"}, - {3, nullptr, "GetStateChangeEvent"}, - {4, nullptr, "GetState"}, - {5, nullptr, "ClearDeviceData"}, - {6, nullptr, "AddUsbStringDescriptor"}, - {7, nullptr, "DeleteUsbStringDescriptor"}, - {8, nullptr, "SetUsbDeviceDescriptor"}, - {9, nullptr, "SetBinaryObjectStore"}, - {10, nullptr, "Enable"}, - {11, nullptr, "Disable"}, - {12, nullptr, "Unknown12"}, + {0, nullptr, "AddEndpoint"}, + {1, nullptr, "GetSetupEvent"}, + {2, nullptr, "GetSetupPacket"}, + {3, nullptr, "Enable"}, + {4, nullptr, "Disable"}, + {5, nullptr, "CtrlIn"}, + {6, nullptr, "CtrlOut"}, + {7, nullptr, "GetCtrlInCompletionEvent"}, + {8, nullptr, "GetCtrlInUrbReport"}, + {9, nullptr, "GetCtrlOutCompletionEvent"}, + {10, nullptr, "GetCtrlOutUrbReport"}, + {11, nullptr, "CtrlStall"}, + {12, nullptr, "AppendConfigurationData"}, }; // clang-format on @@ -36,9 +36,9 @@ public: } }; -class USB_DS final : public ServiceFramework<USB_DS> { +class IDsRootSession final : public ServiceFramework<IDsRootSession> { public: - explicit USB_DS(Core::System& system_) : ServiceFramework{system_, "usb:ds"} { + explicit IDsRootSession(Core::System& system_) : ServiceFramework{system_, "usb:ds"} { // clang-format off static const FunctionInfo functions[] = { {0, nullptr, "OpenDsService"}, @@ -94,9 +94,9 @@ public: } }; -class USB_HS final : public ServiceFramework<USB_HS> { +class IClientRootSession final : public ServiceFramework<IClientRootSession> { public: - explicit USB_HS(Core::System& system_) : ServiceFramework{system_, "usb:hs"} { + explicit IClientRootSession(Core::System& system_) : ServiceFramework{system_, "usb:hs"} { // clang-format off static const FunctionInfo functions[] = { {0, nullptr, "BindClientProcess"}, @@ -107,7 +107,7 @@ public: {5, nullptr, "DestroyInterfaceAvailableEvent"}, {6, nullptr, "GetInterfaceStateChangeEvent"}, {7, nullptr, "AcquireUsbIf"}, - {8, nullptr, "ResetDevice"}, + {8, nullptr, "SetTestMode"}, }; // clang-format on @@ -134,12 +134,12 @@ public: } }; -class USB_PD final : public ServiceFramework<USB_PD> { +class IPdManager final : public ServiceFramework<IPdManager> { public: - explicit USB_PD(Core::System& system_) : ServiceFramework{system_, "usb:pd"} { + explicit IPdManager(Core::System& system_) : ServiceFramework{system_, "usb:pd"} { // clang-format off static const FunctionInfo functions[] = { - {0, &USB_PD::GetPdSession, "GetPdSession"}, + {0, &IPdManager::OpenSession, "OpenSession"}, }; // clang-format on @@ -147,7 +147,7 @@ public: } private: - void GetPdSession(Kernel::HLERequestContext& ctx) { + void OpenSession(HLERequestContext& ctx) { LOG_DEBUG(Service_USB, "called"); IPC::ResponseBuilder rb{ctx, 2, 0, 1}; @@ -178,12 +178,12 @@ public: } }; -class USB_PD_C final : public ServiceFramework<USB_PD_C> { +class IPdCradleManager final : public ServiceFramework<IPdCradleManager> { public: - explicit USB_PD_C(Core::System& system_) : ServiceFramework{system_, "usb:pd:c"} { + explicit IPdCradleManager(Core::System& system_) : ServiceFramework{system_, "usb:pd:c"} { // clang-format off static const FunctionInfo functions[] = { - {0, &USB_PD_C::GetPdCradleSession, "GetPdCradleSession"}, + {0, &IPdCradleManager::OpenCradleSession, "OpenCradleSession"}, }; // clang-format on @@ -191,18 +191,18 @@ public: } private: - void GetPdCradleSession(Kernel::HLERequestContext& ctx) { + void OpenCradleSession(HLERequestContext& ctx) { + LOG_DEBUG(Service_USB, "called"); + IPC::ResponseBuilder rb{ctx, 2, 0, 1}; rb.Push(ResultSuccess); rb.PushIpcInterface<IPdCradleSession>(system); - - LOG_DEBUG(Service_USB, "called"); } }; -class USB_PM final : public ServiceFramework<USB_PM> { +class IPmMainService final : public ServiceFramework<IPmMainService> { public: - explicit USB_PM(Core::System& system_) : ServiceFramework{system_, "usb:pm"} { + explicit IPmMainService(Core::System& system_) : ServiceFramework{system_, "usb:pm"} { // clang-format off static const FunctionInfo functions[] = { {0, nullptr, "GetPowerEvent"}, @@ -221,11 +221,11 @@ public: void LoopProcess(Core::System& system) { auto server_manager = std::make_unique<ServerManager>(system); - server_manager->RegisterNamedService("usb:ds", std::make_shared<USB_DS>(system)); - server_manager->RegisterNamedService("usb:hs", std::make_shared<USB_HS>(system)); - server_manager->RegisterNamedService("usb:pd", std::make_shared<USB_PD>(system)); - server_manager->RegisterNamedService("usb:pd:c", std::make_shared<USB_PD_C>(system)); - server_manager->RegisterNamedService("usb:pm", std::make_shared<USB_PM>(system)); + server_manager->RegisterNamedService("usb:ds", std::make_shared<IDsRootSession>(system)); + server_manager->RegisterNamedService("usb:hs", std::make_shared<IClientRootSession>(system)); + server_manager->RegisterNamedService("usb:pd", std::make_shared<IPdManager>(system)); + server_manager->RegisterNamedService("usb:pd:c", std::make_shared<IPdCradleManager>(system)); + server_manager->RegisterNamedService("usb:pm", std::make_shared<IPmMainService>(system)); ServerManager::RunServer(std::move(server_manager)); } diff --git a/src/core/hle/service/vi/display/vi_display.cpp b/src/core/hle/service/vi/display/vi_display.cpp index 8ef74f1f0..69af2868a 100644 --- a/src/core/hle/service/vi/display/vi_display.cpp +++ b/src/core/hle/service/vi/display/vi_display.cpp @@ -12,11 +12,11 @@ #include "core/hle/kernel/k_readable_event.h" #include "core/hle/service/kernel_helpers.h" #include "core/hle/service/nvdrv/core/container.h" -#include "core/hle/service/nvflinger/buffer_item_consumer.h" -#include "core/hle/service/nvflinger/buffer_queue_consumer.h" -#include "core/hle/service/nvflinger/buffer_queue_core.h" -#include "core/hle/service/nvflinger/buffer_queue_producer.h" -#include "core/hle/service/nvflinger/hos_binder_driver_server.h" +#include "core/hle/service/nvnflinger/buffer_item_consumer.h" +#include "core/hle/service/nvnflinger/buffer_queue_consumer.h" +#include "core/hle/service/nvnflinger/buffer_queue_core.h" +#include "core/hle/service/nvnflinger/buffer_queue_producer.h" +#include "core/hle/service/nvnflinger/hos_binder_driver_server.h" #include "core/hle/service/vi/display/vi_display.h" #include "core/hle/service/vi/layer/vi_layer.h" #include "core/hle/service/vi/vi_results.h" @@ -39,7 +39,7 @@ static BufferQueue CreateBufferQueue(KernelHelpers::ServiceContext& service_cont } Display::Display(u64 id, std::string name_, - NVFlinger::HosBinderDriverServer& hos_binder_driver_server_, + Nvnflinger::HosBinderDriverServer& hos_binder_driver_server_, KernelHelpers::ServiceContext& service_context_, Core::System& system_) : display_id{id}, name{std::move(name_)}, hos_binder_driver_server{hos_binder_driver_server_}, service_context{service_context_} { diff --git a/src/core/hle/service/vi/display/vi_display.h b/src/core/hle/service/vi/display/vi_display.h index 0b65a65da..3f31d1f32 100644 --- a/src/core/hle/service/vi/display/vi_display.h +++ b/src/core/hle/service/vi/display/vi_display.h @@ -23,7 +23,7 @@ namespace Service::KernelHelpers { class ServiceContext; } -namespace Service::NVFlinger { +namespace Service::Nvnflinger { class HosBinderDriverServer; } @@ -45,12 +45,12 @@ public: /// Constructs a display with a given unique ID and name. /// /// @param id The unique ID for this display. - /// @param hos_binder_driver_server_ NVFlinger HOSBinderDriver server instance. + /// @param hos_binder_driver_server_ Nvnflinger HOSBinderDriver server instance. /// @param service_context_ The ServiceContext for the owning service. /// @param name_ The name for this display. /// @param system_ The global system instance. /// - Display(u64 id, std::string name_, NVFlinger::HosBinderDriverServer& hos_binder_driver_server_, + Display(u64 id, std::string name_, Nvnflinger::HosBinderDriverServer& hos_binder_driver_server_, KernelHelpers::ServiceContext& service_context_, Core::System& system_); ~Display(); @@ -133,7 +133,7 @@ public: private: u64 display_id; std::string name; - NVFlinger::HosBinderDriverServer& hos_binder_driver_server; + Nvnflinger::HosBinderDriverServer& hos_binder_driver_server; KernelHelpers::ServiceContext& service_context; std::vector<std::unique_ptr<Layer>> layers; diff --git a/src/core/hle/service/vi/vi.cpp b/src/core/hle/service/vi/vi.cpp index d9cfebd70..68eab5133 100644 --- a/src/core/hle/service/vi/vi.cpp +++ b/src/core/hle/service/vi/vi.cpp @@ -17,15 +17,15 @@ #include "common/settings.h" #include "common/swap.h" #include "core/core_timing.h" -#include "core/hle/ipc_helpers.h" #include "core/hle/kernel/k_readable_event.h" #include "core/hle/kernel/k_thread.h" +#include "core/hle/service/ipc_helpers.h" #include "core/hle/service/nvdrv/nvdata.h" -#include "core/hle/service/nvflinger/binder.h" -#include "core/hle/service/nvflinger/buffer_queue_producer.h" -#include "core/hle/service/nvflinger/hos_binder_driver_server.h" -#include "core/hle/service/nvflinger/nvflinger.h" -#include "core/hle/service/nvflinger/parcel.h" +#include "core/hle/service/nvnflinger/binder.h" +#include "core/hle/service/nvnflinger/buffer_queue_producer.h" +#include "core/hle/service/nvnflinger/hos_binder_driver_server.h" +#include "core/hle/service/nvnflinger/nvnflinger.h" +#include "core/hle/service/nvnflinger/parcel.h" #include "core/hle/service/server_manager.h" #include "core/hle/service/service.h" #include "core/hle/service/vi/vi.h" @@ -73,7 +73,7 @@ static_assert(sizeof(NativeWindow) == 0x28, "NativeWindow has wrong size"); class IHOSBinderDriver final : public ServiceFramework<IHOSBinderDriver> { public: - explicit IHOSBinderDriver(Core::System& system_, NVFlinger::HosBinderDriverServer& server_) + explicit IHOSBinderDriver(Core::System& system_, Nvnflinger::HosBinderDriverServer& server_) : ServiceFramework{system_, "IHOSBinderDriver"}, server(server_) { static const FunctionInfo functions[] = { {0, &IHOSBinderDriver::TransactParcel, "TransactParcel"}, @@ -85,7 +85,7 @@ public: } private: - void TransactParcel(Kernel::HLERequestContext& ctx) { + void TransactParcel(HLERequestContext& ctx) { IPC::RequestParser rp{ctx}; const u32 id = rp.Pop<u32>(); const auto transaction = static_cast<android::TransactionId>(rp.Pop<u32>()); @@ -100,7 +100,7 @@ private: rb.Push(ResultSuccess); } - void AdjustRefcount(Kernel::HLERequestContext& ctx) { + void AdjustRefcount(HLERequestContext& ctx) { IPC::RequestParser rp{ctx}; const u32 id = rp.Pop<u32>(); const s32 addval = rp.PopRaw<s32>(); @@ -113,7 +113,7 @@ private: rb.Push(ResultSuccess); } - void GetNativeHandle(Kernel::HLERequestContext& ctx) { + void GetNativeHandle(HLERequestContext& ctx) { IPC::RequestParser rp{ctx}; const u32 id = rp.Pop<u32>(); const u32 unknown = rp.Pop<u32>(); @@ -126,7 +126,7 @@ private: } private: - NVFlinger::HosBinderDriverServer& server; + Nvnflinger::HosBinderDriverServer& server; }; class ISystemDisplayService final : public ServiceFramework<ISystemDisplayService> { @@ -186,7 +186,7 @@ public: } private: - void SetLayerZ(Kernel::HLERequestContext& ctx) { + void SetLayerZ(HLERequestContext& ctx) { IPC::RequestParser rp{ctx}; const u64 layer_id = rp.Pop<u64>(); const u64 z_value = rp.Pop<u64>(); @@ -200,7 +200,7 @@ private: // This function currently does nothing but return a success error code in // the vi library itself, so do the same thing, but log out the passed in values. - void SetLayerVisibility(Kernel::HLERequestContext& ctx) { + void SetLayerVisibility(HLERequestContext& ctx) { IPC::RequestParser rp{ctx}; const u64 layer_id = rp.Pop<u64>(); const bool visibility = rp.Pop<bool>(); @@ -211,7 +211,7 @@ private: rb.Push(ResultSuccess); } - void GetDisplayMode(Kernel::HLERequestContext& ctx) { + void GetDisplayMode(HLERequestContext& ctx) { LOG_WARNING(Service_VI, "(STUBBED) called"); IPC::ResponseBuilder rb{ctx, 6}; @@ -232,7 +232,7 @@ private: class IManagerDisplayService final : public ServiceFramework<IManagerDisplayService> { public: - explicit IManagerDisplayService(Core::System& system_, NVFlinger::NVFlinger& nv_flinger_) + explicit IManagerDisplayService(Core::System& system_, Nvnflinger::Nvnflinger& nv_flinger_) : ServiceFramework{system_, "IManagerDisplayService"}, nv_flinger{nv_flinger_} { // clang-format off static const FunctionInfo functions[] = { @@ -325,7 +325,7 @@ public: } private: - void CloseDisplay(Kernel::HLERequestContext& ctx) { + void CloseDisplay(HLERequestContext& ctx) { IPC::RequestParser rp{ctx}; const u64 display = rp.Pop<u64>(); @@ -335,7 +335,7 @@ private: rb.Push(rc); } - void CreateManagedLayer(Kernel::HLERequestContext& ctx) { + void CreateManagedLayer(HLERequestContext& ctx) { IPC::RequestParser rp{ctx}; const u32 unknown = rp.Pop<u32>(); rp.Skip(1, false); @@ -359,7 +359,7 @@ private: rb.Push(*layer_id); } - void AddToLayerStack(Kernel::HLERequestContext& ctx) { + void AddToLayerStack(HLERequestContext& ctx) { IPC::RequestParser rp{ctx}; const u32 stack = rp.Pop<u32>(); const u64 layer_id = rp.Pop<u64>(); @@ -371,7 +371,7 @@ private: rb.Push(ResultSuccess); } - void SetLayerVisibility(Kernel::HLERequestContext& ctx) { + void SetLayerVisibility(HLERequestContext& ctx) { IPC::RequestParser rp{ctx}; const u64 layer_id = rp.Pop<u64>(); const bool visibility = rp.Pop<bool>(); @@ -383,13 +383,13 @@ private: rb.Push(ResultSuccess); } - NVFlinger::NVFlinger& nv_flinger; + Nvnflinger::Nvnflinger& nv_flinger; }; class IApplicationDisplayService final : public ServiceFramework<IApplicationDisplayService> { public: - IApplicationDisplayService(Core::System& system_, NVFlinger::NVFlinger& nv_flinger_, - NVFlinger::HosBinderDriverServer& hos_binder_driver_server_) + IApplicationDisplayService(Core::System& system_, Nvnflinger::Nvnflinger& nv_flinger_, + Nvnflinger::HosBinderDriverServer& hos_binder_driver_server_) : ServiceFramework{system_, "IApplicationDisplayService"}, nv_flinger{nv_flinger_}, hos_binder_driver_server{hos_binder_driver_server_} { @@ -440,7 +440,7 @@ private: PreserveAspectRatio = 4, }; - void GetRelayService(Kernel::HLERequestContext& ctx) { + void GetRelayService(HLERequestContext& ctx) { LOG_WARNING(Service_VI, "(STUBBED) called"); IPC::ResponseBuilder rb{ctx, 2, 0, 1}; @@ -448,7 +448,7 @@ private: rb.PushIpcInterface<IHOSBinderDriver>(system, hos_binder_driver_server); } - void GetSystemDisplayService(Kernel::HLERequestContext& ctx) { + void GetSystemDisplayService(HLERequestContext& ctx) { LOG_WARNING(Service_VI, "(STUBBED) called"); IPC::ResponseBuilder rb{ctx, 2, 0, 1}; @@ -456,7 +456,7 @@ private: rb.PushIpcInterface<ISystemDisplayService>(system); } - void GetManagerDisplayService(Kernel::HLERequestContext& ctx) { + void GetManagerDisplayService(HLERequestContext& ctx) { LOG_WARNING(Service_VI, "(STUBBED) called"); IPC::ResponseBuilder rb{ctx, 2, 0, 1}; @@ -464,7 +464,7 @@ private: rb.PushIpcInterface<IManagerDisplayService>(system, nv_flinger); } - void GetIndirectDisplayTransactionService(Kernel::HLERequestContext& ctx) { + void GetIndirectDisplayTransactionService(HLERequestContext& ctx) { LOG_WARNING(Service_VI, "(STUBBED) called"); IPC::ResponseBuilder rb{ctx, 2, 0, 1}; @@ -472,7 +472,7 @@ private: rb.PushIpcInterface<IHOSBinderDriver>(system, hos_binder_driver_server); } - void OpenDisplay(Kernel::HLERequestContext& ctx) { + void OpenDisplay(HLERequestContext& ctx) { LOG_WARNING(Service_VI, "(STUBBED) called"); IPC::RequestParser rp{ctx}; @@ -481,13 +481,13 @@ private: OpenDisplayImpl(ctx, std::string_view{name_buf.data(), name_buf.size()}); } - void OpenDefaultDisplay(Kernel::HLERequestContext& ctx) { + void OpenDefaultDisplay(HLERequestContext& ctx) { LOG_DEBUG(Service_VI, "called"); OpenDisplayImpl(ctx, "Default"); } - void OpenDisplayImpl(Kernel::HLERequestContext& ctx, std::string_view name) { + void OpenDisplayImpl(HLERequestContext& ctx, std::string_view name) { const auto trim_pos = name.find('\0'); if (trim_pos != std::string_view::npos) { @@ -509,7 +509,7 @@ private: rb.Push<u64>(*display_id); } - void CloseDisplay(Kernel::HLERequestContext& ctx) { + void CloseDisplay(HLERequestContext& ctx) { IPC::RequestParser rp{ctx}; const u64 display_id = rp.Pop<u64>(); @@ -521,14 +521,14 @@ private: // This literally does nothing internally in the actual service itself, // and just returns a successful result code regardless of the input. - void SetDisplayEnabled(Kernel::HLERequestContext& ctx) { + void SetDisplayEnabled(HLERequestContext& ctx) { LOG_DEBUG(Service_VI, "called."); IPC::ResponseBuilder rb{ctx, 2}; rb.Push(ResultSuccess); } - void GetDisplayResolution(Kernel::HLERequestContext& ctx) { + void GetDisplayResolution(HLERequestContext& ctx) { IPC::RequestParser rp{ctx}; const u64 display_id = rp.Pop<u64>(); @@ -544,7 +544,7 @@ private: rb.Push(static_cast<u64>(DisplayResolution::UndockedHeight)); } - void SetLayerScalingMode(Kernel::HLERequestContext& ctx) { + void SetLayerScalingMode(HLERequestContext& ctx) { IPC::RequestParser rp{ctx}; const auto scaling_mode = rp.PopEnum<NintendoScaleMode>(); const u64 unknown = rp.Pop<u64>(); @@ -570,7 +570,7 @@ private: rb.Push(ResultSuccess); } - void ListDisplays(Kernel::HLERequestContext& ctx) { + void ListDisplays(HLERequestContext& ctx) { LOG_WARNING(Service_VI, "(STUBBED) called"); const DisplayInfo display_info; @@ -580,7 +580,7 @@ private: rb.Push<u64>(1); } - void OpenLayer(Kernel::HLERequestContext& ctx) { + void OpenLayer(HLERequestContext& ctx) { IPC::RequestParser rp{ctx}; const auto name_buf = rp.PopRaw<std::array<u8, 0x40>>(); const auto end = std::find(name_buf.begin(), name_buf.end(), '\0'); @@ -616,7 +616,7 @@ private: rb.Push<u64>(buffer_size); } - void CloseLayer(Kernel::HLERequestContext& ctx) { + void CloseLayer(HLERequestContext& ctx) { IPC::RequestParser rp{ctx}; const auto layer_id{rp.Pop<u64>()}; @@ -628,7 +628,7 @@ private: rb.Push(ResultSuccess); } - void CreateStrayLayer(Kernel::HLERequestContext& ctx) { + void CreateStrayLayer(HLERequestContext& ctx) { IPC::RequestParser rp{ctx}; const u32 flags = rp.Pop<u32>(); rp.Pop<u32>(); // padding @@ -663,7 +663,7 @@ private: rb.Push<u64>(buffer_size); } - void DestroyStrayLayer(Kernel::HLERequestContext& ctx) { + void DestroyStrayLayer(HLERequestContext& ctx) { IPC::RequestParser rp{ctx}; const u64 layer_id = rp.Pop<u64>(); @@ -673,7 +673,7 @@ private: rb.Push(ResultSuccess); } - void GetDisplayVsyncEvent(Kernel::HLERequestContext& ctx) { + void GetDisplayVsyncEvent(HLERequestContext& ctx) { IPC::RequestParser rp{ctx}; const u64 display_id = rp.Pop<u64>(); @@ -696,7 +696,7 @@ private: rb.PushCopyObjects(*vsync_event); } - void ConvertScalingMode(Kernel::HLERequestContext& ctx) { + void ConvertScalingMode(HLERequestContext& ctx) { IPC::RequestParser rp{ctx}; const auto mode = rp.PopEnum<NintendoScaleMode>(); LOG_DEBUG(Service_VI, "called mode={}", mode); @@ -713,7 +713,7 @@ private: } } - void GetIndirectLayerImageMap(Kernel::HLERequestContext& ctx) { + void GetIndirectLayerImageMap(HLERequestContext& ctx) { IPC::RequestParser rp{ctx}; const auto width = rp.Pop<s64>(); const auto height = rp.Pop<s64>(); @@ -739,7 +739,7 @@ private: rb.Push(ResultSuccess); } - void GetIndirectLayerImageRequiredMemoryInfo(Kernel::HLERequestContext& ctx) { + void GetIndirectLayerImageRequiredMemoryInfo(HLERequestContext& ctx) { IPC::RequestParser rp{ctx}; const auto width = rp.Pop<u64>(); const auto height = rp.Pop<u64>(); @@ -774,8 +774,8 @@ private: } } - NVFlinger::NVFlinger& nv_flinger; - NVFlinger::HosBinderDriverServer& hos_binder_driver_server; + Nvnflinger::Nvnflinger& nv_flinger; + Nvnflinger::HosBinderDriverServer& hos_binder_driver_server; }; static bool IsValidServiceAccess(Permission permission, Policy policy) { @@ -790,9 +790,9 @@ static bool IsValidServiceAccess(Permission permission, Policy policy) { return false; } -void detail::GetDisplayServiceImpl(Kernel::HLERequestContext& ctx, Core::System& system, - NVFlinger::NVFlinger& nv_flinger, - NVFlinger::HosBinderDriverServer& hos_binder_driver_server, +void detail::GetDisplayServiceImpl(HLERequestContext& ctx, Core::System& system, + Nvnflinger::Nvnflinger& nv_flinger, + Nvnflinger::HosBinderDriverServer& hos_binder_driver_server, Permission permission) { IPC::RequestParser rp{ctx}; const auto policy = rp.PopEnum<Policy>(); @@ -809,8 +809,8 @@ void detail::GetDisplayServiceImpl(Kernel::HLERequestContext& ctx, Core::System& rb.PushIpcInterface<IApplicationDisplayService>(system, nv_flinger, hos_binder_driver_server); } -void LoopProcess(Core::System& system, NVFlinger::NVFlinger& nv_flinger, - NVFlinger::HosBinderDriverServer& hos_binder_driver_server) { +void LoopProcess(Core::System& system, Nvnflinger::Nvnflinger& nv_flinger, + Nvnflinger::HosBinderDriverServer& hos_binder_driver_server) { auto server_manager = std::make_unique<ServerManager>(system); server_manager->RegisterNamedService( diff --git a/src/core/hle/service/vi/vi.h b/src/core/hle/service/vi/vi.h index 4ed7aaf2b..a35b62f97 100644 --- a/src/core/hle/service/vi/vi.h +++ b/src/core/hle/service/vi/vi.h @@ -9,14 +9,14 @@ namespace Core { class System; } -namespace Kernel { +namespace Service { class HLERequestContext; } -namespace Service::NVFlinger { +namespace Service::Nvnflinger { class HosBinderDriverServer; -class NVFlinger; -} // namespace Service::NVFlinger +class Nvnflinger; +} // namespace Service::Nvnflinger namespace Service::VI { @@ -42,13 +42,13 @@ enum class Policy { }; namespace detail { -void GetDisplayServiceImpl(Kernel::HLERequestContext& ctx, Core::System& system, - NVFlinger::NVFlinger& nv_flinger, - NVFlinger::HosBinderDriverServer& hos_binder_driver_server, +void GetDisplayServiceImpl(HLERequestContext& ctx, Core::System& system, + Nvnflinger::Nvnflinger& nv_flinger, + Nvnflinger::HosBinderDriverServer& hos_binder_driver_server, Permission permission); } // namespace detail -void LoopProcess(Core::System& system, NVFlinger::NVFlinger& nv_flinger, - NVFlinger::HosBinderDriverServer& hos_binder_driver_server); +void LoopProcess(Core::System& system, Nvnflinger::Nvnflinger& nv_flinger, + Nvnflinger::HosBinderDriverServer& hos_binder_driver_server); } // namespace Service::VI diff --git a/src/core/hle/service/vi/vi_m.cpp b/src/core/hle/service/vi/vi_m.cpp index 7ca44354b..0f06dc2f3 100644 --- a/src/core/hle/service/vi/vi_m.cpp +++ b/src/core/hle/service/vi/vi_m.cpp @@ -7,8 +7,8 @@ namespace Service::VI { -VI_M::VI_M(Core::System& system_, NVFlinger::NVFlinger& nv_flinger_, - NVFlinger::HosBinderDriverServer& hos_binder_driver_server_) +VI_M::VI_M(Core::System& system_, Nvnflinger::Nvnflinger& nv_flinger_, + Nvnflinger::HosBinderDriverServer& hos_binder_driver_server_) : ServiceFramework{system_, "vi:m"}, nv_flinger{nv_flinger_}, hos_binder_driver_server{ hos_binder_driver_server_} { static const FunctionInfo functions[] = { @@ -24,7 +24,7 @@ VI_M::VI_M(Core::System& system_, NVFlinger::NVFlinger& nv_flinger_, VI_M::~VI_M() = default; -void VI_M::GetDisplayService(Kernel::HLERequestContext& ctx) { +void VI_M::GetDisplayService(HLERequestContext& ctx) { LOG_DEBUG(Service_VI, "called"); detail::GetDisplayServiceImpl(ctx, system, nv_flinger, hos_binder_driver_server, diff --git a/src/core/hle/service/vi/vi_m.h b/src/core/hle/service/vi/vi_m.h index 3bf76d439..9ca6f3905 100644 --- a/src/core/hle/service/vi/vi_m.h +++ b/src/core/hle/service/vi/vi_m.h @@ -9,28 +9,24 @@ namespace Core { class System; } -namespace Kernel { -class HLERequestContext; -} - -namespace Service::NVFlinger { +namespace Service::Nvnflinger { class HosBinderDriverServer; -class NVFlinger; -} // namespace Service::NVFlinger +class Nvnflinger; +} // namespace Service::Nvnflinger namespace Service::VI { class VI_M final : public ServiceFramework<VI_M> { public: - explicit VI_M(Core::System& system_, NVFlinger::NVFlinger& nv_flinger_, - NVFlinger::HosBinderDriverServer& hos_binder_driver_server_); + explicit VI_M(Core::System& system_, Nvnflinger::Nvnflinger& nv_flinger_, + Nvnflinger::HosBinderDriverServer& hos_binder_driver_server_); ~VI_M() override; private: - void GetDisplayService(Kernel::HLERequestContext& ctx); + void GetDisplayService(HLERequestContext& ctx); - NVFlinger::NVFlinger& nv_flinger; - NVFlinger::HosBinderDriverServer& hos_binder_driver_server; + Nvnflinger::Nvnflinger& nv_flinger; + Nvnflinger::HosBinderDriverServer& hos_binder_driver_server; }; } // namespace Service::VI diff --git a/src/core/hle/service/vi/vi_s.cpp b/src/core/hle/service/vi/vi_s.cpp index fd799dac1..77f7a88ff 100644 --- a/src/core/hle/service/vi/vi_s.cpp +++ b/src/core/hle/service/vi/vi_s.cpp @@ -7,8 +7,8 @@ namespace Service::VI { -VI_S::VI_S(Core::System& system_, NVFlinger::NVFlinger& nv_flinger_, - NVFlinger::HosBinderDriverServer& hos_binder_driver_server_) +VI_S::VI_S(Core::System& system_, Nvnflinger::Nvnflinger& nv_flinger_, + Nvnflinger::HosBinderDriverServer& hos_binder_driver_server_) : ServiceFramework{system_, "vi:s"}, nv_flinger{nv_flinger_}, hos_binder_driver_server{ hos_binder_driver_server_} { static const FunctionInfo functions[] = { @@ -20,7 +20,7 @@ VI_S::VI_S(Core::System& system_, NVFlinger::NVFlinger& nv_flinger_, VI_S::~VI_S() = default; -void VI_S::GetDisplayService(Kernel::HLERequestContext& ctx) { +void VI_S::GetDisplayService(HLERequestContext& ctx) { LOG_DEBUG(Service_VI, "called"); detail::GetDisplayServiceImpl(ctx, system, nv_flinger, hos_binder_driver_server, diff --git a/src/core/hle/service/vi/vi_s.h b/src/core/hle/service/vi/vi_s.h index 97503ac7f..157839c91 100644 --- a/src/core/hle/service/vi/vi_s.h +++ b/src/core/hle/service/vi/vi_s.h @@ -9,28 +9,24 @@ namespace Core { class System; } -namespace Kernel { -class HLERequestContext; -} - -namespace Service::NVFlinger { +namespace Service::Nvnflinger { class HosBinderDriverServer; -class NVFlinger; -} // namespace Service::NVFlinger +class Nvnflinger; +} // namespace Service::Nvnflinger namespace Service::VI { class VI_S final : public ServiceFramework<VI_S> { public: - explicit VI_S(Core::System& system_, NVFlinger::NVFlinger& nv_flinger_, - NVFlinger::HosBinderDriverServer& hos_binder_driver_server_); + explicit VI_S(Core::System& system_, Nvnflinger::Nvnflinger& nv_flinger_, + Nvnflinger::HosBinderDriverServer& hos_binder_driver_server_); ~VI_S() override; private: - void GetDisplayService(Kernel::HLERequestContext& ctx); + void GetDisplayService(HLERequestContext& ctx); - NVFlinger::NVFlinger& nv_flinger; - NVFlinger::HosBinderDriverServer& hos_binder_driver_server; + Nvnflinger::Nvnflinger& nv_flinger; + Nvnflinger::HosBinderDriverServer& hos_binder_driver_server; }; } // namespace Service::VI diff --git a/src/core/hle/service/vi/vi_u.cpp b/src/core/hle/service/vi/vi_u.cpp index 6cc54bd13..59e13c86b 100644 --- a/src/core/hle/service/vi/vi_u.cpp +++ b/src/core/hle/service/vi/vi_u.cpp @@ -7,8 +7,8 @@ namespace Service::VI { -VI_U::VI_U(Core::System& system_, NVFlinger::NVFlinger& nv_flinger_, - NVFlinger::HosBinderDriverServer& hos_binder_driver_server_) +VI_U::VI_U(Core::System& system_, Nvnflinger::Nvnflinger& nv_flinger_, + Nvnflinger::HosBinderDriverServer& hos_binder_driver_server_) : ServiceFramework{system_, "vi:u"}, nv_flinger{nv_flinger_}, hos_binder_driver_server{ hos_binder_driver_server_} { static const FunctionInfo functions[] = { @@ -20,7 +20,7 @@ VI_U::VI_U(Core::System& system_, NVFlinger::NVFlinger& nv_flinger_, VI_U::~VI_U() = default; -void VI_U::GetDisplayService(Kernel::HLERequestContext& ctx) { +void VI_U::GetDisplayService(HLERequestContext& ctx) { LOG_DEBUG(Service_VI, "called"); detail::GetDisplayServiceImpl(ctx, system, nv_flinger, hos_binder_driver_server, diff --git a/src/core/hle/service/vi/vi_u.h b/src/core/hle/service/vi/vi_u.h index 797941bd7..5d9ca54c6 100644 --- a/src/core/hle/service/vi/vi_u.h +++ b/src/core/hle/service/vi/vi_u.h @@ -9,28 +9,24 @@ namespace Core { class System; } -namespace Kernel { -class HLERequestContext; -} - -namespace Service::NVFlinger { +namespace Service::Nvnflinger { class HosBinderDriverServer; -class NVFlinger; -} // namespace Service::NVFlinger +class Nvnflinger; +} // namespace Service::Nvnflinger namespace Service::VI { class VI_U final : public ServiceFramework<VI_U> { public: - explicit VI_U(Core::System& system_, NVFlinger::NVFlinger& nv_flinger_, - NVFlinger::HosBinderDriverServer& hos_binder_driver_server_); + explicit VI_U(Core::System& system_, Nvnflinger::Nvnflinger& nv_flinger_, + Nvnflinger::HosBinderDriverServer& hos_binder_driver_server_); ~VI_U() override; private: - void GetDisplayService(Kernel::HLERequestContext& ctx); + void GetDisplayService(HLERequestContext& ctx); - NVFlinger::NVFlinger& nv_flinger; - NVFlinger::HosBinderDriverServer& hos_binder_driver_server; + Nvnflinger::Nvnflinger& nv_flinger; + Nvnflinger::HosBinderDriverServer& hos_binder_driver_server; }; } // namespace Service::VI diff --git a/src/core/internal_network/network.cpp b/src/core/internal_network/network.cpp index f85c73ca6..bf97b0ebc 100644 --- a/src/core/internal_network/network.cpp +++ b/src/core/internal_network/network.cpp @@ -572,7 +572,7 @@ std::pair<s32, Errno> Socket::SendTo(u32 flags, std::span<const u8> message, ASSERT(flags == 0); const sockaddr* to = nullptr; - const int tolen = addr ? sizeof(sockaddr) : 0; + const int to_len = addr ? sizeof(sockaddr) : 0; sockaddr host_addr_in; if (addr) { @@ -581,7 +581,7 @@ std::pair<s32, Errno> Socket::SendTo(u32 flags, std::span<const u8> message, } const auto result = sendto(fd, reinterpret_cast<const char*>(message.data()), - static_cast<int>(message.size()), 0, to, tolen); + static_cast<int>(message.size()), 0, to, to_len); if (result != SOCKET_ERROR) { return {static_cast<s32>(result), Errno::SUCCESS}; } diff --git a/src/core/memory/cheat_engine.cpp b/src/core/memory/cheat_engine.cpp index c2d96bbec..de729955f 100644 --- a/src/core/memory/cheat_engine.cpp +++ b/src/core/memory/cheat_engine.cpp @@ -196,7 +196,7 @@ void CheatEngine::Initialize() { }); core_timing.ScheduleLoopingEvent(CHEAT_ENGINE_NS, CHEAT_ENGINE_NS, event); - metadata.process_id = system.ApplicationProcess()->GetProcessID(); + metadata.process_id = system.ApplicationProcess()->GetProcessId(); metadata.title_id = system.GetApplicationProcessProgramID(); const auto& page_table = system.ApplicationProcess()->PageTable(); diff --git a/src/core/perf_stats.cpp b/src/core/perf_stats.cpp index f09c176f8..1231c0dc8 100644 --- a/src/core/perf_stats.cpp +++ b/src/core/perf_stats.cpp @@ -126,8 +126,8 @@ double PerfStats::GetLastFrameTimeScale() const { } void SpeedLimiter::DoSpeedLimiting(microseconds current_system_time_us) { - if (!Settings::values.use_speed_limit.GetValue() || - Settings::values.use_multi_core.GetValue()) { + if (Settings::values.use_multi_core.GetValue() || + !Settings::values.use_speed_limit.GetValue()) { return; } diff --git a/src/core/reporter.cpp b/src/core/reporter.cpp index 708ae17aa..004f2e57a 100644 --- a/src/core/reporter.cpp +++ b/src/core/reporter.cpp @@ -17,10 +17,10 @@ #include "common/settings.h" #include "core/arm/arm_interface.h" #include "core/core.h" -#include "core/hle/kernel/hle_ipc.h" #include "core/hle/kernel/k_page_table.h" #include "core/hle/kernel/k_process.h" #include "core/hle/result.h" +#include "core/hle/service/hle_ipc.h" #include "core/memory.h" #include "core/reporter.h" @@ -170,7 +170,7 @@ json GetHLEBufferDescriptorData(const std::vector<DescriptorType>& buffer, return buffer_out; } -json GetHLERequestContextData(Kernel::HLERequestContext& ctx, Core::Memory::Memory& memory) { +json GetHLERequestContextData(Service::HLERequestContext& ctx, Core::Memory::Memory& memory) { json out; auto cmd_buf = json::array(); @@ -253,7 +253,7 @@ void Reporter::SaveSvcBreakReport(u32 type, bool signal_debugger, u64 info1, u64 SaveToFile(out, GetPath("svc_break_report", title_id, timestamp)); } -void Reporter::SaveUnimplementedFunctionReport(Kernel::HLERequestContext& ctx, u32 command_id, +void Reporter::SaveUnimplementedFunctionReport(Service::HLERequestContext& ctx, u32 command_id, const std::string& name, const std::string& service_name) const { if (!IsReportingEnabled()) { diff --git a/src/core/reporter.h b/src/core/reporter.h index bb11f8e7c..db1ca3ba0 100644 --- a/src/core/reporter.h +++ b/src/core/reporter.h @@ -12,9 +12,9 @@ union Result; -namespace Kernel { +namespace Service { class HLERequestContext; -} // namespace Kernel +} // namespace Service namespace Service::LM { struct LogMessage; @@ -40,7 +40,7 @@ public: const std::optional<std::vector<u8>>& resolved_buffer = {}) const; // Used by HLE service handler - void SaveUnimplementedFunctionReport(Kernel::HLERequestContext& ctx, u32 command_id, + void SaveUnimplementedFunctionReport(Service::HLERequestContext& ctx, u32 command_id, const std::string& name, const std::string& service_name) const; diff --git a/src/input_common/drivers/gc_adapter.cpp b/src/input_common/drivers/gc_adapter.cpp index d09ff178b..3ad34884d 100644 --- a/src/input_common/drivers/gc_adapter.cpp +++ b/src/input_common/drivers/gc_adapter.cpp @@ -344,7 +344,7 @@ bool GCAdapter::IsVibrationEnabled([[maybe_unused]] const PadIdentifier& identif void GCAdapter::UpdateVibrations() { // Use 8 states to keep the switching between on/off fast enough for - // a human to feel different vibration strenght + // a human to feel different vibration strength // More states == more rumble strengths == slower update time constexpr u8 vibration_states = 8; diff --git a/src/input_common/drivers/joycon.cpp b/src/input_common/drivers/joycon.cpp index b4cd39a20..8b57ebe07 100644 --- a/src/input_common/drivers/joycon.cpp +++ b/src/input_common/drivers/joycon.cpp @@ -307,8 +307,8 @@ Common::Input::DriverResult Joycons::SetPollingMode(const PadIdentifier& identif switch (polling_mode) { case Common::Input::PollingMode::Active: return static_cast<Common::Input::DriverResult>(handle->SetActiveMode()); - case Common::Input::PollingMode::Pasive: - return static_cast<Common::Input::DriverResult>(handle->SetPasiveMode()); + case Common::Input::PollingMode::Passive: + return static_cast<Common::Input::DriverResult>(handle->SetPassiveMode()); case Common::Input::PollingMode::IR: return static_cast<Common::Input::DriverResult>(handle->SetIrMode()); case Common::Input::PollingMode::NFC: diff --git a/src/input_common/drivers/joycon.h b/src/input_common/drivers/joycon.h index 473ba1b9e..5b40817e2 100644 --- a/src/input_common/drivers/joycon.h +++ b/src/input_common/drivers/joycon.h @@ -62,7 +62,7 @@ private: /// Registers controllers, clears all data and starts the scan thread void Setup(); - /// Actively searchs for new devices + /// Actively searches for new devices void ScanThread(std::stop_token stop_token); /// Returns true if device is valid and not registered diff --git a/src/input_common/drivers/keyboard.cpp b/src/input_common/drivers/keyboard.cpp index 71e612fbf..2567df9af 100644 --- a/src/input_common/drivers/keyboard.cpp +++ b/src/input_common/drivers/keyboard.cpp @@ -24,7 +24,7 @@ constexpr PadIdentifier keyboard_modifier_identifier = { }; Keyboard::Keyboard(std::string input_engine_) : InputEngine(std::move(input_engine_)) { - // Keyboard is broken into 3 diferent sets: + // Keyboard is broken into 3 different sets: // key: Unfiltered intended for controllers. // keyboard_key: Allows only Settings::NativeKeyboard::Keys intended for keyboard emulation. // keyboard_modifier: Allows only Settings::NativeKeyboard::Modifiers intended for keyboard diff --git a/src/input_common/drivers/mouse.cpp b/src/input_common/drivers/mouse.cpp index 8b7f9aee9..4fb2a6cfa 100644 --- a/src/input_common/drivers/mouse.cpp +++ b/src/input_common/drivers/mouse.cpp @@ -3,6 +3,7 @@ #include <thread> #include <fmt/format.h> +#include <math.h> #include "common/param_package.h" #include "common/settings.h" @@ -11,8 +12,9 @@ namespace InputCommon { constexpr int update_time = 10; -constexpr float default_stick_sensitivity = 0.022f; -constexpr float default_motion_sensitivity = 0.008f; +constexpr float default_stick_sensitivity = 0.0044f; +constexpr float default_motion_sensitivity = 0.0003f; +constexpr float maximum_rotation_speed = 2.0f; constexpr int mouse_axis_x = 0; constexpr int mouse_axis_y = 1; constexpr int wheel_axis_x = 2; @@ -99,11 +101,13 @@ void Mouse::UpdateMotionInput() { const float sensitivity = Settings::values.mouse_panning_sensitivity.GetValue() * default_motion_sensitivity; - // Slow movement by 7% - if (Settings::values.mouse_panning) { - last_motion_change *= 0.93f; - } else { - last_motion_change.z *= 0.93f; + const float rotation_velocity = std::sqrt(last_motion_change.x * last_motion_change.x + + last_motion_change.y * last_motion_change.y); + + if (rotation_velocity > maximum_rotation_speed / sensitivity) { + const float multiplier = maximum_rotation_speed / rotation_velocity / sensitivity; + last_motion_change.x = last_motion_change.x * multiplier; + last_motion_change.y = last_motion_change.y * multiplier; } const BasicMotion motion_data{ @@ -116,6 +120,12 @@ void Mouse::UpdateMotionInput() { .delta_timestamp = update_time * 1000, }; + if (Settings::values.mouse_panning) { + last_motion_change.x = 0; + last_motion_change.y = 0; + } + last_motion_change.z = 0; + SetMotion(motion_identifier, 0, motion_data); } @@ -125,14 +135,14 @@ void Mouse::Move(int x, int y, int center_x, int center_y) { auto mouse_change = (Common::MakeVec(x, y) - Common::MakeVec(center_x, center_y)).Cast<float>(); - Common::Vec3<float> motion_change{-mouse_change.y, -mouse_change.x, last_motion_change.z}; + last_motion_change += {-mouse_change.y, -mouse_change.x, last_motion_change.z}; const auto move_distance = mouse_change.Length(); if (move_distance == 0) { return; } - // Make slow movements at least 3 units on lenght + // Make slow movements at least 3 units on length if (move_distance < 3.0f) { // Normalize value mouse_change /= move_distance; @@ -141,11 +151,10 @@ void Mouse::Move(int x, int y, int center_x, int center_y) { // Average mouse movements last_mouse_change = (last_mouse_change * 0.91f) + (mouse_change * 0.09f); - last_motion_change = (last_motion_change * 0.69f) + (motion_change * 0.31f); const auto last_move_distance = last_mouse_change.Length(); - // Make fast movements clamp to 8 units on lenght + // Make fast movements clamp to 8 units on length if (last_move_distance > 8.0f) { // Normalize value last_mouse_change /= last_move_distance; diff --git a/src/input_common/drivers/sdl_driver.cpp b/src/input_common/drivers/sdl_driver.cpp index 5c20b3426..7f9e8dbb9 100644 --- a/src/input_common/drivers/sdl_driver.cpp +++ b/src/input_common/drivers/sdl_driver.cpp @@ -652,12 +652,27 @@ bool SDLDriver::IsVibrationEnabled(const PadIdentifier& identifier) { } void SDLDriver::SendVibrations() { + std::vector<VibrationRequest> filtered_vibrations{}; while (!vibration_queue.Empty()) { VibrationRequest request; vibration_queue.Pop(request); const auto joystick = GetSDLJoystickByGUID(request.identifier.guid.RawString(), static_cast<int>(request.identifier.port)); - joystick->RumblePlay(request.vibration); + const auto it = std::find_if(filtered_vibrations.begin(), filtered_vibrations.end(), + [request](VibrationRequest vibration) { + return vibration.identifier == request.identifier; + }); + if (it == filtered_vibrations.end()) { + filtered_vibrations.push_back(std::move(request)); + continue; + } + *it = request; + } + + for (const auto& vibration : filtered_vibrations) { + const auto joystick = GetSDLJoystickByGUID(vibration.identifier.guid.RawString(), + static_cast<int>(vibration.identifier.port)); + joystick->RumblePlay(vibration.vibration); } } @@ -748,7 +763,7 @@ ButtonMapping SDLDriver::GetButtonMappingForDevice(const Common::ParamPackage& p // This list is missing ZL/ZR since those are not considered buttons in SDL GameController. // We will add those afterwards - // This list also excludes Screenshot since theres not really a mapping for that + // This list also excludes Screenshot since there's not really a mapping for that ButtonBindings switch_to_sdl_button; if (SDL_GameControllerGetType(controller) == SDL_CONTROLLER_TYPE_NINTENDO_SWITCH_PRO) { @@ -1007,7 +1022,7 @@ MotionMapping SDLDriver::GetMotionMappingForDevice(const Common::ParamPackage& p Common::Input::ButtonNames SDLDriver::GetUIName(const Common::ParamPackage& params) const { if (params.Has("button")) { - // TODO(German77): Find how to substitue the values for real button names + // TODO(German77): Find how to substitute the values for real button names return Common::Input::ButtonNames::Value; } if (params.Has("hat")) { diff --git a/src/input_common/drivers/virtual_amiibo.cpp b/src/input_common/drivers/virtual_amiibo.cpp index 4a0268a4d..304f4c70b 100644 --- a/src/input_common/drivers/virtual_amiibo.cpp +++ b/src/input_common/drivers/virtual_amiibo.cpp @@ -57,7 +57,7 @@ Common::Input::NfcState VirtualAmiibo::WriteNfcData( } if (!nfc_file.Write(data)) { - LOG_ERROR(Service_NFP, "Error writting to file"); + LOG_ERROR(Service_NFP, "Error writing to file"); return Common::Input::NfcState::WriteFailed; } diff --git a/src/input_common/drivers/virtual_amiibo.h b/src/input_common/drivers/virtual_amiibo.h index 13cacfc0a..488d00b31 100644 --- a/src/input_common/drivers/virtual_amiibo.h +++ b/src/input_common/drivers/virtual_amiibo.h @@ -60,6 +60,6 @@ private: std::string file_path{}; State state{State::Initialized}; std::vector<u8> nfc_data; - Common::Input::PollingMode polling_mode{Common::Input::PollingMode::Pasive}; + Common::Input::PollingMode polling_mode{Common::Input::PollingMode::Passive}; }; } // namespace InputCommon diff --git a/src/input_common/helpers/joycon_driver.cpp b/src/input_common/helpers/joycon_driver.cpp index e65b6b845..83429a336 100644 --- a/src/input_common/helpers/joycon_driver.cpp +++ b/src/input_common/helpers/joycon_driver.cpp @@ -164,8 +164,8 @@ void JoyconDriver::InputThread(std::stop_token stop_token) { void JoyconDriver::OnNewData(std::span<u8> buffer) { const auto report_mode = static_cast<ReportMode>(buffer[0]); - // Packages can be a litte bit inconsistent. Average the delta time to provide a smoother motion - // experience + // Packages can be a little bit inconsistent. Average the delta time to provide a smoother + // motion experience switch (report_mode) { case ReportMode::STANDARD_FULL_60HZ: case ReportMode::NFC_IR_MODE_60HZ: @@ -410,7 +410,7 @@ DriverResult JoyconDriver::SetIrsConfig(IrsMode mode_, IrsResolution format_) { return result; } -DriverResult JoyconDriver::SetPasiveMode() { +DriverResult JoyconDriver::SetPassiveMode() { std::scoped_lock lock{mutex}; motion_enabled = false; hidbus_enabled = false; diff --git a/src/input_common/helpers/joycon_driver.h b/src/input_common/helpers/joycon_driver.h index c1e189fa5..72a9e71dc 100644 --- a/src/input_common/helpers/joycon_driver.h +++ b/src/input_common/helpers/joycon_driver.h @@ -44,7 +44,7 @@ public: DriverResult SetVibration(const VibrationValue& vibration); DriverResult SetLedConfig(u8 led_pattern); DriverResult SetIrsConfig(IrsMode mode_, IrsResolution format_); - DriverResult SetPasiveMode(); + DriverResult SetPassiveMode(); DriverResult SetActiveMode(); DriverResult SetIrMode(); DriverResult SetNfcMode(); @@ -73,7 +73,7 @@ private: /// Main thread, actively request new data from the handle void InputThread(std::stop_token stop_token); - /// Called everytime a valid package arrives + /// Called every time a valid package arrives void OnNewData(std::span<u8> buffer); /// Updates device configuration to enable or disable features @@ -110,7 +110,7 @@ private: bool amiibo_detected{}; bool is_ring_disabled_by_irs{}; - // Harware configuration + // Hardware configuration u8 leds{}; ReportMode mode{}; bool passive_enabled{}; // Low power mode, Ideal for multiple controllers at the same time diff --git a/src/input_common/helpers/joycon_protocol/common_protocol.h b/src/input_common/helpers/joycon_protocol/common_protocol.h index f44f73ba4..62cae739a 100644 --- a/src/input_common/helpers/joycon_protocol/common_protocol.h +++ b/src/input_common/helpers/joycon_protocol/common_protocol.h @@ -68,7 +68,7 @@ public: } /** - * Waits for incoming data of the joycon device that matchs the subcommand + * Waits for incoming data of the joycon device that matches the subcommand * @param sub_command type of data to be returned * @returns a buffer containing the response */ @@ -137,7 +137,7 @@ public: DriverResult EnableMCU(bool enable); /** - * Configures the MCU to the correspoinding mode + * Configures the MCU to the corresponding mode * @param MCUConfig configuration */ DriverResult ConfigureMCU(const MCUConfig& config); diff --git a/src/input_common/helpers/joycon_protocol/joycon_types.h b/src/input_common/helpers/joycon_protocol/joycon_types.h index b91934990..dcac0e422 100644 --- a/src/input_common/helpers/joycon_protocol/joycon_types.h +++ b/src/input_common/helpers/joycon_protocol/joycon_types.h @@ -78,7 +78,7 @@ enum class PadButton : u32 { Capture = 0x200000, }; -enum class PasivePadButton : u32 { +enum class PassivePadButton : u32 { Down_A = 0x0001, Right_X = 0x0002, Left_B = 0x0004, @@ -95,6 +95,18 @@ enum class PasivePadButton : u32 { ZL_ZR = 0x8000, }; +enum class PassivePadStick : u8 { + Right = 0x00, + RightDown = 0x01, + Down = 0x02, + DownLeft = 0x03, + Left = 0x04, + LeftUp = 0x05, + Up = 0x06, + UpRight = 0x07, + Neutral = 0x08, +}; + enum class OutputReport : u8 { RUMBLE_AND_SUBCMD = 0x01, FW_UPDATE_PKT = 0x03, diff --git a/src/input_common/helpers/joycon_protocol/poller.cpp b/src/input_common/helpers/joycon_protocol/poller.cpp index 9bb15e935..dca797f7a 100644 --- a/src/input_common/helpers/joycon_protocol/poller.cpp +++ b/src/input_common/helpers/joycon_protocol/poller.cpp @@ -12,7 +12,7 @@ JoyconPoller::JoyconPoller(ControllerType device_type_, JoyStickCalibration left : device_type{device_type_}, left_stick_calibration{left_stick_calibration_}, right_stick_calibration{right_stick_calibration_}, motion_calibration{motion_calibration_} {} -void JoyconPoller::SetCallbacks(const Joycon::JoyconCallbacks& callbacks_) { +void JoyconPoller::SetCallbacks(const JoyconCallbacks& callbacks_) { callbacks = std::move(callbacks_); } @@ -22,13 +22,13 @@ void JoyconPoller::ReadActiveMode(std::span<u8> buffer, const MotionStatus& moti memcpy(&data, buffer.data(), sizeof(InputReportActive)); switch (device_type) { - case Joycon::ControllerType::Left: + case ControllerType::Left: UpdateActiveLeftPadInput(data, motion_status); break; - case Joycon::ControllerType::Right: + case ControllerType::Right: UpdateActiveRightPadInput(data, motion_status); break; - case Joycon::ControllerType::Pro: + case ControllerType::Pro: UpdateActiveProPadInput(data, motion_status); break; default: @@ -47,14 +47,14 @@ void JoyconPoller::ReadPassiveMode(std::span<u8> buffer) { memcpy(&data, buffer.data(), sizeof(InputReportPassive)); switch (device_type) { - case Joycon::ControllerType::Left: - UpdatePasiveLeftPadInput(data); + case ControllerType::Left: + UpdatePassiveLeftPadInput(data); break; - case Joycon::ControllerType::Right: - UpdatePasiveRightPadInput(data); + case ControllerType::Right: + UpdatePassiveRightPadInput(data); break; - case Joycon::ControllerType::Pro: - UpdatePasiveProPadInput(data); + case ControllerType::Pro: + UpdatePassiveProPadInput(data); break; default: break; @@ -210,14 +210,12 @@ void JoyconPoller::UpdateActiveProPadInput(const InputReportActive& input, } } -void JoyconPoller::UpdatePasiveLeftPadInput(const InputReportPassive& input) { - static constexpr std::array<Joycon::PasivePadButton, 11> left_buttons{ - Joycon::PasivePadButton::Down_A, Joycon::PasivePadButton::Right_X, - Joycon::PasivePadButton::Left_B, Joycon::PasivePadButton::Up_Y, - Joycon::PasivePadButton::SL, Joycon::PasivePadButton::SR, - Joycon::PasivePadButton::L_R, Joycon::PasivePadButton::ZL_ZR, - Joycon::PasivePadButton::Minus, Joycon::PasivePadButton::Capture, - Joycon::PasivePadButton::StickL, +void JoyconPoller::UpdatePassiveLeftPadInput(const InputReportPassive& input) { + static constexpr std::array<PassivePadButton, 11> left_buttons{ + PassivePadButton::Down_A, PassivePadButton::Right_X, PassivePadButton::Left_B, + PassivePadButton::Up_Y, PassivePadButton::SL, PassivePadButton::SR, + PassivePadButton::L_R, PassivePadButton::ZL_ZR, PassivePadButton::Minus, + PassivePadButton::Capture, PassivePadButton::StickL, }; for (auto left_button : left_buttons) { @@ -225,16 +223,19 @@ void JoyconPoller::UpdatePasiveLeftPadInput(const InputReportPassive& input) { const int button = static_cast<int>(left_button); callbacks.on_button_data(button, button_status); } + + const auto [left_axis_x, left_axis_y] = + GetPassiveAxisValue(static_cast<PassivePadStick>(input.stick_state)); + callbacks.on_stick_data(static_cast<int>(PadAxes::LeftStickX), left_axis_x); + callbacks.on_stick_data(static_cast<int>(PadAxes::LeftStickY), left_axis_y); } -void JoyconPoller::UpdatePasiveRightPadInput(const InputReportPassive& input) { - static constexpr std::array<Joycon::PasivePadButton, 11> right_buttons{ - Joycon::PasivePadButton::Down_A, Joycon::PasivePadButton::Right_X, - Joycon::PasivePadButton::Left_B, Joycon::PasivePadButton::Up_Y, - Joycon::PasivePadButton::SL, Joycon::PasivePadButton::SR, - Joycon::PasivePadButton::L_R, Joycon::PasivePadButton::ZL_ZR, - Joycon::PasivePadButton::Plus, Joycon::PasivePadButton::Home, - Joycon::PasivePadButton::StickR, +void JoyconPoller::UpdatePassiveRightPadInput(const InputReportPassive& input) { + static constexpr std::array<PassivePadButton, 11> right_buttons{ + PassivePadButton::Down_A, PassivePadButton::Right_X, PassivePadButton::Left_B, + PassivePadButton::Up_Y, PassivePadButton::SL, PassivePadButton::SR, + PassivePadButton::L_R, PassivePadButton::ZL_ZR, PassivePadButton::Plus, + PassivePadButton::Home, PassivePadButton::StickR, }; for (auto right_button : right_buttons) { @@ -242,17 +243,20 @@ void JoyconPoller::UpdatePasiveRightPadInput(const InputReportPassive& input) { const int button = static_cast<int>(right_button); callbacks.on_button_data(button, button_status); } + + const auto [right_axis_x, right_axis_y] = + GetPassiveAxisValue(static_cast<PassivePadStick>(input.stick_state)); + callbacks.on_stick_data(static_cast<int>(PadAxes::RightStickX), right_axis_x); + callbacks.on_stick_data(static_cast<int>(PadAxes::RightStickY), right_axis_y); } -void JoyconPoller::UpdatePasiveProPadInput(const InputReportPassive& input) { - static constexpr std::array<Joycon::PasivePadButton, 14> pro_buttons{ - Joycon::PasivePadButton::Down_A, Joycon::PasivePadButton::Right_X, - Joycon::PasivePadButton::Left_B, Joycon::PasivePadButton::Up_Y, - Joycon::PasivePadButton::SL, Joycon::PasivePadButton::SR, - Joycon::PasivePadButton::L_R, Joycon::PasivePadButton::ZL_ZR, - Joycon::PasivePadButton::Minus, Joycon::PasivePadButton::Plus, - Joycon::PasivePadButton::Capture, Joycon::PasivePadButton::Home, - Joycon::PasivePadButton::StickL, Joycon::PasivePadButton::StickR, +void JoyconPoller::UpdatePassiveProPadInput(const InputReportPassive& input) { + static constexpr std::array<PassivePadButton, 14> pro_buttons{ + PassivePadButton::Down_A, PassivePadButton::Right_X, PassivePadButton::Left_B, + PassivePadButton::Up_Y, PassivePadButton::SL, PassivePadButton::SR, + PassivePadButton::L_R, PassivePadButton::ZL_ZR, PassivePadButton::Minus, + PassivePadButton::Plus, PassivePadButton::Capture, PassivePadButton::Home, + PassivePadButton::StickL, PassivePadButton::StickR, }; for (auto pro_button : pro_buttons) { @@ -260,6 +264,15 @@ void JoyconPoller::UpdatePasiveProPadInput(const InputReportPassive& input) { const int button = static_cast<int>(pro_button); callbacks.on_button_data(button, button_status); } + + const auto [left_axis_x, left_axis_y] = + GetPassiveAxisValue(static_cast<PassivePadStick>(input.stick_state & 0xf)); + const auto [right_axis_x, right_axis_y] = + GetPassiveAxisValue(static_cast<PassivePadStick>(input.stick_state >> 4)); + callbacks.on_stick_data(static_cast<int>(PadAxes::LeftStickX), left_axis_x); + callbacks.on_stick_data(static_cast<int>(PadAxes::LeftStickY), left_axis_y); + callbacks.on_stick_data(static_cast<int>(PadAxes::RightStickX), right_axis_x); + callbacks.on_stick_data(static_cast<int>(PadAxes::RightStickY), right_axis_y); } f32 JoyconPoller::GetAxisValue(u16 raw_value, Joycon::JoyStickAxisCalibration calibration) const { @@ -270,6 +283,30 @@ f32 JoyconPoller::GetAxisValue(u16 raw_value, Joycon::JoyStickAxisCalibration ca return value / calibration.min; } +std::pair<f32, f32> JoyconPoller::GetPassiveAxisValue(PassivePadStick raw_value) const { + switch (raw_value) { + case PassivePadStick::Right: + return {1.0f, 0.0f}; + case PassivePadStick::RightDown: + return {1.0f, -1.0f}; + case PassivePadStick::Down: + return {0.0f, -1.0f}; + case PassivePadStick::DownLeft: + return {-1.0f, -1.0f}; + case PassivePadStick::Left: + return {-1.0f, 0.0f}; + case PassivePadStick::LeftUp: + return {-1.0f, 1.0f}; + case PassivePadStick::Up: + return {0.0f, 1.0f}; + case PassivePadStick::UpRight: + return {1.0f, 1.0f}; + case PassivePadStick::Neutral: + default: + return {0.0f, 0.0f}; + } +} + f32 JoyconPoller::GetAccelerometerValue(s16 raw, const MotionSensorCalibration& cal, AccelerometerSensitivity sensitivity) const { const f32 value = raw * (1.0f / (cal.scale - cal.offset)) * 4; diff --git a/src/input_common/helpers/joycon_protocol/poller.h b/src/input_common/helpers/joycon_protocol/poller.h index 354d41dad..0fa72c6db 100644 --- a/src/input_common/helpers/joycon_protocol/poller.h +++ b/src/input_common/helpers/joycon_protocol/poller.h @@ -22,7 +22,7 @@ public: JoyStickCalibration right_stick_calibration_, MotionCalibration motion_calibration_); - void SetCallbacks(const Joycon::JoyconCallbacks& callbacks_); + void SetCallbacks(const JoyconCallbacks& callbacks_); /// Handles data from passive packages void ReadPassiveMode(std::span<u8> buffer); @@ -46,12 +46,15 @@ private: const MotionStatus& motion_status); void UpdateActiveProPadInput(const InputReportActive& input, const MotionStatus& motion_status); - void UpdatePasiveLeftPadInput(const InputReportPassive& buffer); - void UpdatePasiveRightPadInput(const InputReportPassive& buffer); - void UpdatePasiveProPadInput(const InputReportPassive& buffer); + void UpdatePassiveLeftPadInput(const InputReportPassive& buffer); + void UpdatePassiveRightPadInput(const InputReportPassive& buffer); + void UpdatePassiveProPadInput(const InputReportPassive& buffer); /// Returns a calibrated joystick axis from raw axis data - f32 GetAxisValue(u16 raw_value, Joycon::JoyStickAxisCalibration calibration) const; + f32 GetAxisValue(u16 raw_value, JoyStickAxisCalibration calibration) const; + + /// Returns a digital joystick axis from passive axis data + std::pair<f32, f32> GetPassiveAxisValue(PassivePadStick raw_value) const; /// Returns a calibrated accelerometer axis from raw motion data f32 GetAccelerometerValue(s16 raw, const MotionSensorCalibration& cal, @@ -75,7 +78,7 @@ private: JoyStickCalibration right_stick_calibration{}; MotionCalibration motion_calibration{}; - Joycon::JoyconCallbacks callbacks{}; + JoyconCallbacks callbacks{}; }; } // namespace InputCommon::Joycon diff --git a/src/input_common/helpers/udp_protocol.cpp b/src/input_common/helpers/udp_protocol.cpp index 994380d21..e54a8fce1 100644 --- a/src/input_common/helpers/udp_protocol.cpp +++ b/src/input_common/helpers/udp_protocol.cpp @@ -25,7 +25,7 @@ namespace Response { /** * Returns Type if the packet is valid, else none * - * Note: Modifies the buffer to zero out the crc (since thats the easiest way to check without + * Note: Modifies the buffer to zero out the crc (since that's the easiest way to check without * copying the buffer) */ std::optional<Type> Validate(u8* data, std::size_t size) { diff --git a/src/input_common/input_mapping.cpp b/src/input_common/input_mapping.cpp index 2ff480ff9..9361b00c5 100644 --- a/src/input_common/input_mapping.cpp +++ b/src/input_common/input_mapping.cpp @@ -146,6 +146,7 @@ void MappingFactory::RegisterMotion(const MappingData& data) { if (data.engine == "mouse") { new_input.Set("motion", 0); new_input.Set("pad", 1); + new_input.Set("threshold", 0.001f); input_queue.Push(new_input); return; } diff --git a/src/input_common/main.h b/src/input_common/main.h index 1207d786c..d64a6cb4c 100644 --- a/src/input_common/main.h +++ b/src/input_common/main.h @@ -132,7 +132,7 @@ public: /// Retrieves the motion mappings for the given device. [[nodiscard]] MotionMapping GetMotionMappingForDevice(const Common::ParamPackage& device) const; - /// Returns an enum contaning the name to be displayed from the input engine. + /// Returns an enum containing the name to be displayed from the input engine. [[nodiscard]] Common::Input::ButtonNames GetButtonName( const Common::ParamPackage& params) const; diff --git a/src/network/packet.h b/src/network/packet.h index e69217488..9aa2a2c9c 100644 --- a/src/network/packet.h +++ b/src/network/packet.h @@ -9,7 +9,7 @@ namespace Network { -/// A class that serializes data for network transfer. It also handles endianess +/// A class that serializes data for network transfer. It also handles endianness class Packet { public: Packet() = default; diff --git a/src/network/room.cpp b/src/network/room.cpp index dc5dbce7f..e456ea09c 100644 --- a/src/network/room.cpp +++ b/src/network/room.cpp @@ -27,7 +27,7 @@ public: std::atomic<State> state{State::Closed}; ///< Current state of the room. RoomInformation room_information; ///< Information about this room. - std::string verify_uid; ///< A GUID which may be used for verfication. + std::string verify_uid; ///< A GUID which may be used for verification. mutable std::mutex verify_uid_mutex; ///< Mutex for verify_uid std::string password; ///< The password required to connect to this room. diff --git a/src/network/room_member.h b/src/network/room_member.h index 0d6417294..33ac18e72 100644 --- a/src/network/room_member.h +++ b/src/network/room_member.h @@ -71,7 +71,7 @@ public: Idle, ///< Default state (i.e. not connected) Joining, ///< The client is attempting to join a room. Joined, ///< The client is connected to the room and is ready to send/receive packets. - Moderator, ///< The client is connnected to the room and is granted mod permissions. + Moderator, ///< The client is connected to the room and is granted mod permissions. }; enum class Error : u8 { @@ -201,7 +201,7 @@ public: /** * Binds a function to an event that will be triggered every time the State of the member - * changed. The function wil be called every time the event is triggered. The callback function + * changed. The function will be called every time the event is triggered. The callback function * must not bind or unbind a function. Doing so will cause a deadlock * @param callback The function to call * @return A handle used for removing the function from the registered list @@ -210,8 +210,8 @@ public: /** * Binds a function to an event that will be triggered every time an error happened. The - * function wil be called every time the event is triggered. The callback function must not bind - * or unbind a function. Doing so will cause a deadlock + * function will be called every time the event is triggered. The callback function must not + * bind or unbind a function. Doing so will cause a deadlock * @param callback The function to call * @return A handle used for removing the function from the registered list */ @@ -219,7 +219,7 @@ public: /** * Binds a function to an event that will be triggered every time a ProxyPacket is received. - * The function wil be called everytime the event is triggered. + * The function will be called every time the event is triggered. * The callback function must not bind or unbind a function. Doing so will cause a deadlock * @param callback The function to call * @return A handle used for removing the function from the registered list @@ -229,7 +229,7 @@ public: /** * Binds a function to an event that will be triggered every time an LDNPacket is received. - * The function wil be called everytime the event is triggered. + * The function will be called every time the event is triggered. * The callback function must not bind or unbind a function. Doing so will cause a deadlock * @param callback The function to call * @return A handle used for removing the function from the registered list @@ -239,7 +239,7 @@ public: /** * Binds a function to an event that will be triggered every time the RoomInformation changes. - * The function wil be called every time the event is triggered. + * The function will be called every time the event is triggered. * The callback function must not bind or unbind a function. Doing so will cause a deadlock * @param callback The function to call * @return A handle used for removing the function from the registered list @@ -249,7 +249,7 @@ public: /** * Binds a function to an event that will be triggered every time a ChatMessage is received. - * The function wil be called every time the event is triggered. + * The function will be called every time the event is triggered. * The callback function must not bind or unbind a function. Doing so will cause a deadlock * @param callback The function to call * @return A handle used for removing the function from the registered list diff --git a/src/shader_recompiler/backend/glsl/emit_glsl_atomic.cpp b/src/shader_recompiler/backend/glsl/emit_glsl_atomic.cpp index 911181c43..376a05827 100644 --- a/src/shader_recompiler/backend/glsl/emit_glsl_atomic.cpp +++ b/src/shader_recompiler/backend/glsl/emit_glsl_atomic.cpp @@ -398,162 +398,162 @@ void EmitStorageAtomicMaxF32x2(EmitContext& ctx, IR::Inst& inst, const IR::Value } void EmitGlobalAtomicIAdd32(EmitContext&) { - throw NotImplementedException("GLSL Instrucion"); + throw NotImplementedException("GLSL Instruction"); } void EmitGlobalAtomicSMin32(EmitContext&) { - throw NotImplementedException("GLSL Instrucion"); + throw NotImplementedException("GLSL Instruction"); } void EmitGlobalAtomicUMin32(EmitContext&) { - throw NotImplementedException("GLSL Instrucion"); + throw NotImplementedException("GLSL Instruction"); } void EmitGlobalAtomicSMax32(EmitContext&) { - throw NotImplementedException("GLSL Instrucion"); + throw NotImplementedException("GLSL Instruction"); } void EmitGlobalAtomicUMax32(EmitContext&) { - throw NotImplementedException("GLSL Instrucion"); + throw NotImplementedException("GLSL Instruction"); } void EmitGlobalAtomicInc32(EmitContext&) { - throw NotImplementedException("GLSL Instrucion"); + throw NotImplementedException("GLSL Instruction"); } void EmitGlobalAtomicDec32(EmitContext&) { - throw NotImplementedException("GLSL Instrucion"); + throw NotImplementedException("GLSL Instruction"); } void EmitGlobalAtomicAnd32(EmitContext&) { - throw NotImplementedException("GLSL Instrucion"); + throw NotImplementedException("GLSL Instruction"); } void EmitGlobalAtomicOr32(EmitContext&) { - throw NotImplementedException("GLSL Instrucion"); + throw NotImplementedException("GLSL Instruction"); } void EmitGlobalAtomicXor32(EmitContext&) { - throw NotImplementedException("GLSL Instrucion"); + throw NotImplementedException("GLSL Instruction"); } void EmitGlobalAtomicExchange32(EmitContext&) { - throw NotImplementedException("GLSL Instrucion"); + throw NotImplementedException("GLSL Instruction"); } void EmitGlobalAtomicIAdd64(EmitContext&) { - throw NotImplementedException("GLSL Instrucion"); + throw NotImplementedException("GLSL Instruction"); } void EmitGlobalAtomicSMin64(EmitContext&) { - throw NotImplementedException("GLSL Instrucion"); + throw NotImplementedException("GLSL Instruction"); } void EmitGlobalAtomicUMin64(EmitContext&) { - throw NotImplementedException("GLSL Instrucion"); + throw NotImplementedException("GLSL Instruction"); } void EmitGlobalAtomicSMax64(EmitContext&) { - throw NotImplementedException("GLSL Instrucion"); + throw NotImplementedException("GLSL Instruction"); } void EmitGlobalAtomicUMax64(EmitContext&) { - throw NotImplementedException("GLSL Instrucion"); + throw NotImplementedException("GLSL Instruction"); } void EmitGlobalAtomicInc64(EmitContext&) { - throw NotImplementedException("GLSL Instrucion"); + throw NotImplementedException("GLSL Instruction"); } void EmitGlobalAtomicDec64(EmitContext&) { - throw NotImplementedException("GLSL Instrucion"); + throw NotImplementedException("GLSL Instruction"); } void EmitGlobalAtomicAnd64(EmitContext&) { - throw NotImplementedException("GLSL Instrucion"); + throw NotImplementedException("GLSL Instruction"); } void EmitGlobalAtomicOr64(EmitContext&) { - throw NotImplementedException("GLSL Instrucion"); + throw NotImplementedException("GLSL Instruction"); } void EmitGlobalAtomicXor64(EmitContext&) { - throw NotImplementedException("GLSL Instrucion"); + throw NotImplementedException("GLSL Instruction"); } void EmitGlobalAtomicExchange64(EmitContext&) { - throw NotImplementedException("GLSL Instrucion"); + throw NotImplementedException("GLSL Instruction"); } void EmitGlobalAtomicIAdd32x2(EmitContext&) { - throw NotImplementedException("GLSL Instrucion"); + throw NotImplementedException("GLSL Instruction"); } void EmitGlobalAtomicSMin32x2(EmitContext&) { - throw NotImplementedException("GLSL Instrucion"); + throw NotImplementedException("GLSL Instruction"); } void EmitGlobalAtomicUMin32x2(EmitContext&) { - throw NotImplementedException("GLSL Instrucion"); + throw NotImplementedException("GLSL Instruction"); } void EmitGlobalAtomicSMax32x2(EmitContext&) { - throw NotImplementedException("GLSL Instrucion"); + throw NotImplementedException("GLSL Instruction"); } void EmitGlobalAtomicUMax32x2(EmitContext&) { - throw NotImplementedException("GLSL Instrucion"); + throw NotImplementedException("GLSL Instruction"); } void EmitGlobalAtomicInc32x2(EmitContext&) { - throw NotImplementedException("GLSL Instrucion"); + throw NotImplementedException("GLSL Instruction"); } void EmitGlobalAtomicDec32x2(EmitContext&) { - throw NotImplementedException("GLSL Instrucion"); + throw NotImplementedException("GLSL Instruction"); } void EmitGlobalAtomicAnd32x2(EmitContext&) { - throw NotImplementedException("GLSL Instrucion"); + throw NotImplementedException("GLSL Instruction"); } void EmitGlobalAtomicOr32x2(EmitContext&) { - throw NotImplementedException("GLSL Instrucion"); + throw NotImplementedException("GLSL Instruction"); } void EmitGlobalAtomicXor32x2(EmitContext&) { - throw NotImplementedException("GLSL Instrucion"); + throw NotImplementedException("GLSL Instruction"); } void EmitGlobalAtomicExchange32x2(EmitContext&) { - throw NotImplementedException("GLSL Instrucion"); + throw NotImplementedException("GLSL Instruction"); } void EmitGlobalAtomicAddF32(EmitContext&) { - throw NotImplementedException("GLSL Instrucion"); + throw NotImplementedException("GLSL Instruction"); } void EmitGlobalAtomicAddF16x2(EmitContext&) { - throw NotImplementedException("GLSL Instrucion"); + throw NotImplementedException("GLSL Instruction"); } void EmitGlobalAtomicAddF32x2(EmitContext&) { - throw NotImplementedException("GLSL Instrucion"); + throw NotImplementedException("GLSL Instruction"); } void EmitGlobalAtomicMinF16x2(EmitContext&) { - throw NotImplementedException("GLSL Instrucion"); + throw NotImplementedException("GLSL Instruction"); } void EmitGlobalAtomicMinF32x2(EmitContext&) { - throw NotImplementedException("GLSL Instrucion"); + throw NotImplementedException("GLSL Instruction"); } void EmitGlobalAtomicMaxF16x2(EmitContext&) { - throw NotImplementedException("GLSL Instrucion"); + throw NotImplementedException("GLSL Instruction"); } void EmitGlobalAtomicMaxF32x2(EmitContext&) { - throw NotImplementedException("GLSL Instrucion"); + throw NotImplementedException("GLSL Instruction"); } } // namespace Shader::Backend::GLSL diff --git a/src/shader_recompiler/backend/glsl/glsl_emit_context.h b/src/shader_recompiler/backend/glsl/glsl_emit_context.h index dfd10ac28..7587f7bab 100644 --- a/src/shader_recompiler/backend/glsl/glsl_emit_context.h +++ b/src/shader_recompiler/backend/glsl/glsl_emit_context.h @@ -49,7 +49,7 @@ public: void Add(const char* format_str, IR::Inst& inst, Args&&... args) { const auto var_def{var_alloc.AddDefine(inst, type)}; if (var_def.empty()) { - // skip assigment. + // skip assignment. code += fmt::format(fmt::runtime(format_str + 3), std::forward<Args>(args)...); } else { code += fmt::format(fmt::runtime(format_str), var_def, std::forward<Args>(args)...); diff --git a/src/shader_recompiler/ir_opt/global_memory_to_storage_buffer_pass.cpp b/src/shader_recompiler/ir_opt/global_memory_to_storage_buffer_pass.cpp index 336338e62..d1e59f22e 100644 --- a/src/shader_recompiler/ir_opt/global_memory_to_storage_buffer_pass.cpp +++ b/src/shader_recompiler/ir_opt/global_memory_to_storage_buffer_pass.cpp @@ -35,6 +35,7 @@ struct Bias { u32 index; u32 offset_begin; u32 offset_end; + u32 alignment; }; using boost::container::flat_set; @@ -349,7 +350,8 @@ std::optional<StorageBufferAddr> Track(const IR::Value& value, const Bias* bias) .index = index.U32(), .offset = offset.U32(), }; - if (!Common::IsAligned(storage_buffer.offset, 16)) { + const u32 alignment{bias ? bias->alignment : 8U}; + if (!Common::IsAligned(storage_buffer.offset, alignment)) { // The SSBO pointer has to be aligned return std::nullopt; } @@ -371,6 +373,7 @@ void CollectStorageBuffers(IR::Block& block, IR::Inst& inst, StorageInfo& info) .index = 0, .offset_begin = 0x110, .offset_end = 0x610, + .alignment = 16, }; // Track the low address of the instruction const std::optional<LowAddrInfo> low_addr_info{TrackLowAddress(&inst)}; @@ -386,8 +389,11 @@ void CollectStorageBuffers(IR::Block& block, IR::Inst& inst, StorageInfo& info) storage_buffer = Track(low_addr, nullptr); if (!storage_buffer) { // If that also fails, use NVN fallbacks + LOG_WARNING(Shader, "Storage buffer failed to track, using global memory fallbacks"); return; } + LOG_WARNING(Shader, "Storage buffer tracked without bias, index {} offset {}", + storage_buffer->index, storage_buffer->offset); } // Collect storage buffer and the instruction if (IsGlobalMemoryWrite(inst)) { diff --git a/src/tests/common/ring_buffer.cpp b/src/tests/common/ring_buffer.cpp index 7dee988c8..e85f9977b 100644 --- a/src/tests/common/ring_buffer.cpp +++ b/src/tests/common/ring_buffer.cpp @@ -52,7 +52,7 @@ TEST_CASE("RingBuffer: Basic Tests", "[common]") { REQUIRE(buf.Size() == 1U); - // Pushing more values than space available should partially suceed. + // Pushing more values than space available should partially succeed. { std::vector<char> to_push(6); std::iota(to_push.begin(), to_push.end(), 88); diff --git a/src/tests/common/scratch_buffer.cpp b/src/tests/common/scratch_buffer.cpp index 132f139fa..26e401760 100644 --- a/src/tests/common/scratch_buffer.cpp +++ b/src/tests/common/scratch_buffer.cpp @@ -191,7 +191,7 @@ TEST_CASE("ScratchBuffer: Span Writes", "[common]") { for (size_t i = 0; i < buf_span.size(); ++i) { const auto new_value = static_cast<u8>(i + 1U); - // Writes to a span of the scratch buffer will propogate to the buffer itself + // Writes to a span of the scratch buffer will propagate to the buffer itself buf_span[i] = new_value; REQUIRE(buf[i] == new_value); } diff --git a/src/video_core/buffer_cache/buffer_cache.h b/src/video_core/buffer_cache/buffer_cache.h index 06fd40851..1f656ffa8 100644 --- a/src/video_core/buffer_cache/buffer_cache.h +++ b/src/video_core/buffer_cache/buffer_cache.h @@ -55,6 +55,19 @@ constexpr u32 NUM_STORAGE_BUFFERS = 16; constexpr u32 NUM_TEXTURE_BUFFERS = 16; constexpr u32 NUM_STAGES = 5; +enum class ObtainBufferSynchronize : u32 { + NoSynchronize = 0, + FullSynchronize = 1, + SynchronizeNoDirty = 2, +}; + +enum class ObtainBufferOperation : u32 { + DoNothing = 0, + MarkAsWritten = 1, + DiscardWrite = 2, + MarkQuery = 3, +}; + using UniformBufferSizes = std::array<std::array<u32, NUM_GRAPHICS_UNIFORM_BUFFERS>, NUM_STAGES>; using ComputeUniformBufferSizes = std::array<u32, NUM_COMPUTE_UNIFORM_BUFFERS>; @@ -191,6 +204,10 @@ public: bool DMAClear(GPUVAddr src_address, u64 amount, u32 value); + [[nodiscard]] std::pair<Buffer*, u32> ObtainBuffer(GPUVAddr gpu_addr, u32 size, + ObtainBufferSynchronize sync_info, + ObtainBufferOperation post_op); + /// Return true when a CPU region is modified from the GPU [[nodiscard]] bool IsRegionGpuModified(VAddr addr, size_t size); @@ -366,7 +383,8 @@ private: void NotifyBufferDeletion(); - [[nodiscard]] Binding StorageBufferBinding(GPUVAddr ssbo_addr, bool is_written = false) const; + [[nodiscard]] Binding StorageBufferBinding(GPUVAddr ssbo_addr, u32 cbuf_index, + bool is_written = false) const; [[nodiscard]] TextureBufferBinding GetTextureBufferBinding(GPUVAddr gpu_addr, u32 size, PixelFormat format); @@ -642,6 +660,42 @@ bool BufferCache<P>::DMAClear(GPUVAddr dst_address, u64 amount, u32 value) { } template <class P> +std::pair<typename P::Buffer*, u32> BufferCache<P>::ObtainBuffer(GPUVAddr gpu_addr, u32 size, + ObtainBufferSynchronize sync_info, + ObtainBufferOperation post_op) { + const std::optional<VAddr> cpu_addr = gpu_memory->GpuToCpuAddress(gpu_addr); + if (!cpu_addr) { + return {&slot_buffers[NULL_BUFFER_ID], 0}; + } + const BufferId buffer_id = FindBuffer(*cpu_addr, size); + Buffer& buffer = slot_buffers[buffer_id]; + + // synchronize op + switch (sync_info) { + case ObtainBufferSynchronize::FullSynchronize: + SynchronizeBuffer(buffer, *cpu_addr, size); + break; + default: + break; + } + + switch (post_op) { + case ObtainBufferOperation::MarkAsWritten: + MarkWrittenBuffer(buffer_id, *cpu_addr, size); + break; + case ObtainBufferOperation::DiscardWrite: { + IntervalType interval{*cpu_addr, size}; + ClearDownload(interval); + break; + } + default: + break; + } + + return {&buffer, buffer.Offset(*cpu_addr)}; +} + +template <class P> void BufferCache<P>::BindGraphicsUniformBuffer(size_t stage, u32 index, GPUVAddr gpu_addr, u32 size) { const std::optional<VAddr> cpu_addr = gpu_memory->GpuToCpuAddress(gpu_addr); @@ -749,7 +803,7 @@ void BufferCache<P>::BindGraphicsStorageBuffer(size_t stage, size_t ssbo_index, const auto& cbufs = maxwell3d->state.shader_stages[stage]; const GPUVAddr ssbo_addr = cbufs.const_buffers[cbuf_index].address + cbuf_offset; - storage_buffers[stage][ssbo_index] = StorageBufferBinding(ssbo_addr, is_written); + storage_buffers[stage][ssbo_index] = StorageBufferBinding(ssbo_addr, cbuf_index, is_written); } template <class P> @@ -789,7 +843,7 @@ void BufferCache<P>::BindComputeStorageBuffer(size_t ssbo_index, u32 cbuf_index, const auto& cbufs = launch_desc.const_buffer_config; const GPUVAddr ssbo_addr = cbufs[cbuf_index].Address() + cbuf_offset; - compute_storage_buffers[ssbo_index] = StorageBufferBinding(ssbo_addr, is_written); + compute_storage_buffers[ssbo_index] = StorageBufferBinding(ssbo_addr, cbuf_index, is_written); } template <class P> @@ -1935,11 +1989,26 @@ void BufferCache<P>::NotifyBufferDeletion() { template <class P> typename BufferCache<P>::Binding BufferCache<P>::StorageBufferBinding(GPUVAddr ssbo_addr, + u32 cbuf_index, bool is_written) const { const GPUVAddr gpu_addr = gpu_memory->Read<u64>(ssbo_addr); - const u32 size = gpu_memory->Read<u32>(ssbo_addr + 8); + const auto size = [&]() { + const bool is_nvn_cbuf = cbuf_index == 0; + // The NVN driver buffer (index 0) is known to pack the SSBO address followed by its size. + if (is_nvn_cbuf) { + return gpu_memory->Read<u32>(ssbo_addr + 8); + } + // Other titles (notably Doom Eternal) may use STG/LDG on buffer addresses in custom defined + // cbufs, which do not store the sizes adjacent to the addresses, so use the fully + // mapped buffer size for now. + const u32 memory_layout_size = static_cast<u32>(gpu_memory->GetMemoryLayoutSize(gpu_addr)); + LOG_INFO(HW_GPU, "Binding storage buffer for cbuf index {}, MemoryLayoutSize 0x{:X}", + cbuf_index, memory_layout_size); + return memory_layout_size; + }(); const std::optional<VAddr> cpu_addr = gpu_memory->GpuToCpuAddress(gpu_addr); if (!cpu_addr || size == 0) { + LOG_WARNING(HW_GPU, "Failed to find storage buffer for cbuf index {}", cbuf_index); return NULL_BINDING; } const VAddr cpu_end = Common::AlignUp(*cpu_addr + size, Core::Memory::YUZU_PAGESIZE); diff --git a/src/video_core/control/channel_state_cache.h b/src/video_core/control/channel_state_cache.h index cdaf4f8d5..46bc9e322 100644 --- a/src/video_core/control/channel_state_cache.h +++ b/src/video_core/control/channel_state_cache.h @@ -44,7 +44,7 @@ public: template <class P> class ChannelSetupCaches { public: - /// Operations for seting the channel of execution. + /// Operations for setting the channel of execution. virtual ~ChannelSetupCaches(); /// Create channel state. diff --git a/src/video_core/engines/draw_manager.cpp b/src/video_core/engines/draw_manager.cpp index 1d22d25f1..0e94c521a 100644 --- a/src/video_core/engines/draw_manager.cpp +++ b/src/video_core/engines/draw_manager.cpp @@ -164,6 +164,7 @@ void DrawManager::DrawEnd(u32 instance_count, bool force_draw) { draw_state.index_buffer.count = static_cast<u32>(draw_state.inline_index_draw_indexes.size() / 4); draw_state.index_buffer.format = Maxwell3D::Regs::IndexFormat::UnsignedInt; + maxwell3d->dirty.flags[VideoCommon::Dirty::IndexBuffer] = true; ProcessDraw(true, instance_count); draw_state.inline_index_draw_indexes.clear(); break; diff --git a/src/video_core/engines/maxwell_dma.cpp b/src/video_core/engines/maxwell_dma.cpp index 7762c7d96..e68850dc5 100644 --- a/src/video_core/engines/maxwell_dma.cpp +++ b/src/video_core/engines/maxwell_dma.cpp @@ -14,7 +14,13 @@ #include "video_core/textures/decoders.h" MICROPROFILE_DECLARE(GPU_DMAEngine); +MICROPROFILE_DECLARE(GPU_DMAEngineBL); +MICROPROFILE_DECLARE(GPU_DMAEngineLB); +MICROPROFILE_DECLARE(GPU_DMAEngineBB); MICROPROFILE_DEFINE(GPU_DMAEngine, "GPU", "DMA Engine", MP_RGB(224, 224, 128)); +MICROPROFILE_DEFINE(GPU_DMAEngineBL, "GPU", "DMA Engine Block - Linear", MP_RGB(224, 224, 128)); +MICROPROFILE_DEFINE(GPU_DMAEngineLB, "GPU", "DMA Engine Linear - Block", MP_RGB(224, 224, 128)); +MICROPROFILE_DEFINE(GPU_DMAEngineBB, "GPU", "DMA Engine Block - Block", MP_RGB(224, 224, 128)); namespace Tegra::Engines { @@ -72,6 +78,7 @@ void MaxwellDMA::Launch() { memory_manager.FlushCaching(); if (!is_src_pitch && !is_dst_pitch) { // If both the source and the destination are in block layout, assert. + MICROPROFILE_SCOPE(GPU_DMAEngineBB); CopyBlockLinearToBlockLinear(); ReleaseSemaphore(); return; @@ -87,8 +94,10 @@ void MaxwellDMA::Launch() { } } else { if (!is_src_pitch && is_dst_pitch) { + MICROPROFILE_SCOPE(GPU_DMAEngineBL); CopyBlockLinearToPitch(); } else { + MICROPROFILE_SCOPE(GPU_DMAEngineLB); CopyPitchToBlockLinear(); } } @@ -153,21 +162,35 @@ void MaxwellDMA::Launch() { } void MaxwellDMA::CopyBlockLinearToPitch() { - UNIMPLEMENTED_IF(regs.src_params.block_size.width != 0); - UNIMPLEMENTED_IF(regs.src_params.layer != 0); - - const bool is_remapping = regs.launch_dma.remap_enable != 0; - - // Optimized path for micro copies. - const size_t dst_size = static_cast<size_t>(regs.pitch_out) * regs.line_count; - if (!is_remapping && dst_size < GOB_SIZE && regs.pitch_out <= GOB_SIZE_X && - regs.src_params.height > GOB_SIZE_Y) { - FastCopyBlockLinearToPitch(); + UNIMPLEMENTED_IF(regs.launch_dma.remap_enable != 0); + + u32 bytes_per_pixel = 1; + DMA::ImageOperand src_operand; + src_operand.bytes_per_pixel = bytes_per_pixel; + src_operand.params = regs.src_params; + src_operand.address = regs.offset_in; + + DMA::BufferOperand dst_operand; + dst_operand.pitch = regs.pitch_out; + dst_operand.width = regs.line_length_in; + dst_operand.height = regs.line_count; + dst_operand.address = regs.offset_out; + DMA::ImageCopy copy_info{}; + copy_info.length_x = regs.line_length_in; + copy_info.length_y = regs.line_count; + auto& accelerate = rasterizer->AccessAccelerateDMA(); + if (accelerate.ImageToBuffer(copy_info, src_operand, dst_operand)) { return; } + UNIMPLEMENTED_IF(regs.src_params.block_size.width != 0); + UNIMPLEMENTED_IF(regs.src_params.block_size.depth != 0); + UNIMPLEMENTED_IF(regs.src_params.block_size.depth == 0 && regs.src_params.depth != 1); + // Deswizzle the input and copy it over. - const Parameters& src_params = regs.src_params; + const DMA::Parameters& src_params = regs.src_params; + + const bool is_remapping = regs.launch_dma.remap_enable != 0; const u32 num_remap_components = regs.remap_const.num_dst_components_minus_one + 1; const u32 remap_components_size = regs.remap_const.component_size_minus_one + 1; @@ -187,7 +210,7 @@ void MaxwellDMA::CopyBlockLinearToPitch() { x_offset >>= bpp_shift; } - const u32 bytes_per_pixel = base_bpp << bpp_shift; + bytes_per_pixel = base_bpp << bpp_shift; const u32 height = src_params.height; const u32 depth = src_params.depth; const u32 block_height = src_params.block_size.height; @@ -195,11 +218,12 @@ void MaxwellDMA::CopyBlockLinearToPitch() { const size_t src_size = CalculateSize(true, bytes_per_pixel, width, height, depth, block_height, block_depth); + const size_t dst_size = static_cast<size_t>(regs.pitch_out) * regs.line_count; read_buffer.resize_destructive(src_size); write_buffer.resize_destructive(dst_size); - memory_manager.ReadBlock(regs.offset_in, read_buffer.data(), src_size); - memory_manager.ReadBlock(regs.offset_out, write_buffer.data(), dst_size); + memory_manager.ReadBlock(src_operand.address, read_buffer.data(), src_size); + memory_manager.ReadBlockUnsafe(dst_operand.address, write_buffer.data(), dst_size); UnswizzleSubrect(write_buffer, read_buffer, bytes_per_pixel, width, height, depth, x_offset, src_params.origin.y, x_elements, regs.line_count, block_height, block_depth, @@ -216,6 +240,24 @@ void MaxwellDMA::CopyPitchToBlockLinear() { const u32 num_remap_components = regs.remap_const.num_dst_components_minus_one + 1; const u32 remap_components_size = regs.remap_const.component_size_minus_one + 1; + u32 bytes_per_pixel = 1; + DMA::ImageOperand dst_operand; + dst_operand.bytes_per_pixel = bytes_per_pixel; + dst_operand.params = regs.dst_params; + dst_operand.address = regs.offset_out; + DMA::BufferOperand src_operand; + src_operand.pitch = regs.pitch_in; + src_operand.width = regs.line_length_in; + src_operand.height = regs.line_count; + src_operand.address = regs.offset_in; + DMA::ImageCopy copy_info{}; + copy_info.length_x = regs.line_length_in; + copy_info.length_y = regs.line_count; + auto& accelerate = rasterizer->AccessAccelerateDMA(); + if (accelerate.BufferToImage(copy_info, src_operand, dst_operand)) { + return; + } + const auto& dst_params = regs.dst_params; const u32 base_bpp = !is_remapping ? 1U : num_remap_components * remap_components_size; @@ -233,7 +275,7 @@ void MaxwellDMA::CopyPitchToBlockLinear() { x_offset >>= bpp_shift; } - const u32 bytes_per_pixel = base_bpp << bpp_shift; + bytes_per_pixel = base_bpp << bpp_shift; const u32 height = dst_params.height; const u32 depth = dst_params.depth; const u32 block_height = dst_params.block_size.height; @@ -260,45 +302,14 @@ void MaxwellDMA::CopyPitchToBlockLinear() { memory_manager.WriteBlockCached(regs.offset_out, write_buffer.data(), dst_size); } -void MaxwellDMA::FastCopyBlockLinearToPitch() { - const u32 bytes_per_pixel = 1U; - const size_t src_size = GOB_SIZE; - const size_t dst_size = static_cast<size_t>(regs.pitch_out) * regs.line_count; - u32 pos_x = regs.src_params.origin.x; - u32 pos_y = regs.src_params.origin.y; - const u64 offset = GetGOBOffset(regs.src_params.width, regs.src_params.height, pos_x, pos_y, - regs.src_params.block_size.height, bytes_per_pixel); - const u32 x_in_gob = 64 / bytes_per_pixel; - pos_x = pos_x % x_in_gob; - pos_y = pos_y % 8; - - read_buffer.resize_destructive(src_size); - write_buffer.resize_destructive(dst_size); - - if (Settings::IsGPULevelExtreme()) { - memory_manager.ReadBlock(regs.offset_in + offset, read_buffer.data(), src_size); - memory_manager.ReadBlock(regs.offset_out, write_buffer.data(), dst_size); - } else { - memory_manager.ReadBlockUnsafe(regs.offset_in + offset, read_buffer.data(), src_size); - memory_manager.ReadBlockUnsafe(regs.offset_out, write_buffer.data(), dst_size); - } - - UnswizzleSubrect(write_buffer, read_buffer, bytes_per_pixel, regs.src_params.width, - regs.src_params.height, 1, pos_x, pos_y, regs.line_length_in, regs.line_count, - regs.src_params.block_size.height, regs.src_params.block_size.depth, - regs.pitch_out); - - memory_manager.WriteBlockCached(regs.offset_out, write_buffer.data(), dst_size); -} - void MaxwellDMA::CopyBlockLinearToBlockLinear() { UNIMPLEMENTED_IF(regs.src_params.block_size.width != 0); const bool is_remapping = regs.launch_dma.remap_enable != 0; // Deswizzle the input and copy it over. - const Parameters& src = regs.src_params; - const Parameters& dst = regs.dst_params; + const DMA::Parameters& src = regs.src_params; + const DMA::Parameters& dst = regs.dst_params; const u32 num_remap_components = regs.remap_const.num_dst_components_minus_one + 1; const u32 remap_components_size = regs.remap_const.component_size_minus_one + 1; diff --git a/src/video_core/engines/maxwell_dma.h b/src/video_core/engines/maxwell_dma.h index 0e594fa74..69e26cb32 100644 --- a/src/video_core/engines/maxwell_dma.h +++ b/src/video_core/engines/maxwell_dma.h @@ -24,6 +24,54 @@ namespace VideoCore { class RasterizerInterface; } +namespace Tegra { +namespace DMA { + +union Origin { + BitField<0, 16, u32> x; + BitField<16, 16, u32> y; +}; +static_assert(sizeof(Origin) == 4); + +struct ImageCopy { + u32 length_x{}; + u32 length_y{}; +}; + +union BlockSize { + BitField<0, 4, u32> width; + BitField<4, 4, u32> height; + BitField<8, 4, u32> depth; + BitField<12, 4, u32> gob_height; +}; +static_assert(sizeof(BlockSize) == 4); + +struct Parameters { + BlockSize block_size; + u32 width; + u32 height; + u32 depth; + u32 layer; + Origin origin; +}; +static_assert(sizeof(Parameters) == 24); + +struct ImageOperand { + u32 bytes_per_pixel; + Parameters params; + GPUVAddr address; +}; + +struct BufferOperand { + u32 pitch; + u32 width; + u32 height; + GPUVAddr address; +}; + +} // namespace DMA +} // namespace Tegra + namespace Tegra::Engines { class AccelerateDMAInterface { @@ -32,6 +80,12 @@ public: virtual bool BufferCopy(GPUVAddr src_address, GPUVAddr dest_address, u64 amount) = 0; virtual bool BufferClear(GPUVAddr src_address, u64 amount, u32 value) = 0; + + virtual bool ImageToBuffer(const DMA::ImageCopy& copy_info, const DMA::ImageOperand& src, + const DMA::BufferOperand& dst) = 0; + + virtual bool BufferToImage(const DMA::ImageCopy& copy_info, const DMA::BufferOperand& src, + const DMA::ImageOperand& dst) = 0; }; /** @@ -51,30 +105,6 @@ public: } }; - union BlockSize { - BitField<0, 4, u32> width; - BitField<4, 4, u32> height; - BitField<8, 4, u32> depth; - BitField<12, 4, u32> gob_height; - }; - static_assert(sizeof(BlockSize) == 4); - - union Origin { - BitField<0, 16, u32> x; - BitField<16, 16, u32> y; - }; - static_assert(sizeof(Origin) == 4); - - struct Parameters { - BlockSize block_size; - u32 width; - u32 height; - u32 depth; - u32 layer; - Origin origin; - }; - static_assert(sizeof(Parameters) == 24); - struct Semaphore { PackedGPUVAddr address; u32 payload; @@ -227,8 +257,6 @@ private: void CopyBlockLinearToBlockLinear(); - void FastCopyBlockLinearToPitch(); - void ReleaseSemaphore(); void ConsumeSinkImpl() override; @@ -261,17 +289,17 @@ private: u32 reserved05[0x3f]; PackedGPUVAddr offset_in; PackedGPUVAddr offset_out; - u32 pitch_in; - u32 pitch_out; + s32 pitch_in; + s32 pitch_out; u32 line_length_in; u32 line_count; u32 reserved06[0xb6]; u32 remap_consta_value; u32 remap_constb_value; RemapConst remap_const; - Parameters dst_params; + DMA::Parameters dst_params; u32 reserved07[0x1]; - Parameters src_params; + DMA::Parameters src_params; u32 reserved08[0x275]; u32 pm_trigger_end; u32 reserved09[0x3ba]; diff --git a/src/video_core/engines/sw_blitter/blitter.cpp b/src/video_core/engines/sw_blitter/blitter.cpp index 2f1ea4626..3c9f38559 100644 --- a/src/video_core/engines/sw_blitter/blitter.cpp +++ b/src/video_core/engines/sw_blitter/blitter.cpp @@ -193,7 +193,7 @@ bool SoftwareBlitEngine::Blit(Fermi2D::Surface& src, Fermi2D::Surface& dst, output_converter->ConvertFrom(impl->intermediate_dst, impl->dst_buffer); }; - // Do actuall Blit + // Do actual Blit impl->dst_buffer.resize(dst_copy_size); if (src.linear == Fermi2D::MemoryLayout::BlockLinear) { diff --git a/src/video_core/framebuffer_config.h b/src/video_core/framebuffer_config.h index d93f5a37f..5f3bffcab 100644 --- a/src/video_core/framebuffer_config.h +++ b/src/video_core/framebuffer_config.h @@ -5,8 +5,8 @@ #include "common/common_types.h" #include "common/math_util.h" -#include "core/hle/service/nvflinger/buffer_transform_flags.h" -#include "core/hle/service/nvflinger/pixel_format.h" +#include "core/hle/service/nvnflinger/buffer_transform_flags.h" +#include "core/hle/service/nvnflinger/pixel_format.h" namespace Tegra { diff --git a/src/video_core/gpu.cpp b/src/video_core/gpu.cpp index 7024a19cf..2e7f9c5ed 100644 --- a/src/video_core/gpu.cpp +++ b/src/video_core/gpu.cpp @@ -197,7 +197,7 @@ struct GPU::Impl { constexpr u64 gpu_ticks_num = 384; constexpr u64 gpu_ticks_den = 625; - u64 nanoseconds = system.CoreTiming().GetGlobalTimeNs().count(); + u64 nanoseconds = system.CoreTiming().GetCPUTimeNs().count(); if (Settings::values.use_fast_gpu_time.GetValue()) { nanoseconds /= 256; } diff --git a/src/video_core/gpu_thread.cpp b/src/video_core/gpu_thread.cpp index 7cc5647e9..f52f9e28f 100644 --- a/src/video_core/gpu_thread.cpp +++ b/src/video_core/gpu_thread.cpp @@ -25,7 +25,7 @@ static void RunThread(std::stop_token stop_token, Core::System& system, SCOPE_EXIT({ MicroProfileOnThreadExit(); }); Common::SetCurrentThreadName(name.c_str()); - Common::SetCurrentThreadPriority(Common::ThreadPriority::High); + Common::SetCurrentThreadPriority(Common::ThreadPriority::Critical); system.RegisterHostThread(); auto current_context = context.Acquire(); diff --git a/src/video_core/host_shaders/astc_decoder.comp b/src/video_core/host_shaders/astc_decoder.comp index d608678a3..bf2693559 100644 --- a/src/video_core/host_shaders/astc_decoder.comp +++ b/src/video_core/host_shaders/astc_decoder.comp @@ -125,7 +125,7 @@ uvec4 local_buff; uvec4 color_endpoint_data; int color_bitsread = 0; -// Four values, two endpoints, four maximum paritions +// Four values, two endpoints, four maximum partitions uint color_values[32]; int colvals_index = 0; diff --git a/src/video_core/host_shaders/opengl_smaa.glsl b/src/video_core/host_shaders/opengl_smaa.glsl index 3cbe87bbf..419f89bca 100644 --- a/src/video_core/host_shaders/opengl_smaa.glsl +++ b/src/video_core/host_shaders/opengl_smaa.glsl @@ -97,7 +97,7 @@ * half-rate linear filtering on GCN. * * If SMAA is applied to 64-bit color buffers, switching to point filtering - * when accesing them will increase the performance. Search for + * when accessing them will increase the performance. Search for * 'SMAASamplePoint' to see which textures may benefit from point * filtering, and where (which is basically the color input in the edge * detection and resolve passes). diff --git a/src/video_core/memory_manager.h b/src/video_core/memory_manager.h index cf56392ef..51ae2de68 100644 --- a/src/video_core/memory_manager.h +++ b/src/video_core/memory_manager.h @@ -103,8 +103,8 @@ public: /** * Returns a vector with all the subranges of cpu addresses mapped beneath. - * if the region is continous, a single pair will be returned. If it's unmapped, an empty vector - * will be returned; + * if the region is continuous, a single pair will be returned. If it's unmapped, an empty + * vector will be returned; */ std::vector<std::pair<GPUVAddr, std::size_t>> GetSubmappedRange(GPUVAddr gpu_addr, std::size_t size) const; diff --git a/src/video_core/query_cache.h b/src/video_core/query_cache.h index 00ce53e3e..8906ba6d8 100644 --- a/src/video_core/query_cache.h +++ b/src/video_core/query_cache.h @@ -341,7 +341,7 @@ public: /// Flushes the query to guest memory. virtual void Flush() { - // When counter is nullptr it means that it's just been reseted. We are supposed to write a + // When counter is nullptr it means that it's just been reset. We are supposed to write a // zero in these cases. const u64 value = counter ? counter->Query() : 0; std::memcpy(host_ptr, &value, sizeof(u64)); diff --git a/src/video_core/renderer_null/null_rasterizer.h b/src/video_core/renderer_null/null_rasterizer.h index 51f896e43..0c59e6a1f 100644 --- a/src/video_core/renderer_null/null_rasterizer.h +++ b/src/video_core/renderer_null/null_rasterizer.h @@ -22,6 +22,14 @@ public: explicit AccelerateDMA(); bool BufferCopy(GPUVAddr start_address, GPUVAddr end_address, u64 amount) override; bool BufferClear(GPUVAddr src_address, u64 amount, u32 value) override; + bool ImageToBuffer(const Tegra::DMA::ImageCopy& copy_info, const Tegra::DMA::ImageOperand& src, + const Tegra::DMA::BufferOperand& dst) override { + return false; + } + bool BufferToImage(const Tegra::DMA::ImageCopy& copy_info, const Tegra::DMA::BufferOperand& src, + const Tegra::DMA::ImageOperand& dst) override { + return false; + } }; class RasterizerNull final : public VideoCore::RasterizerAccelerated, diff --git a/src/video_core/renderer_opengl/blit_image.cpp b/src/video_core/renderer_opengl/blit_image.cpp index 9a560a73b..3b03e8d5a 100644 --- a/src/video_core/renderer_opengl/blit_image.cpp +++ b/src/video_core/renderer_opengl/blit_image.cpp @@ -22,7 +22,7 @@ BlitImageHelper::~BlitImageHelper() = default; void BlitImageHelper::BlitColor(GLuint dst_framebuffer, GLuint src_image_view, GLuint src_sampler, const Region2D& dst_region, const Region2D& src_region, const Extent3D& src_size) { - glEnable(GL_CULL_FACE); + glDisable(GL_CULL_FACE); glDisable(GL_COLOR_LOGIC_OP); glDisable(GL_DEPTH_TEST); glDisable(GL_STENCIL_TEST); @@ -31,7 +31,6 @@ void BlitImageHelper::BlitColor(GLuint dst_framebuffer, GLuint src_image_view, G glDisable(GL_ALPHA_TEST); glDisablei(GL_BLEND, 0); glPolygonMode(GL_FRONT_AND_BACK, GL_FILL); - glCullFace(GL_BACK); glFrontFace(GL_CW); glColorMaski(0, GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE); glDepthRangeIndexed(0, 0.0, 0.0); diff --git a/src/video_core/renderer_opengl/gl_fence_manager.cpp b/src/video_core/renderer_opengl/gl_fence_manager.cpp index 91463f854..5326172af 100644 --- a/src/video_core/renderer_opengl/gl_fence_manager.cpp +++ b/src/video_core/renderer_opengl/gl_fence_manager.cpp @@ -27,9 +27,7 @@ bool GLInnerFence::IsSignaled() const { return true; } ASSERT(sync_object.handle != 0); - GLint sync_status; - glGetSynciv(sync_object.handle, GL_SYNC_STATUS, 1, nullptr, &sync_status); - return sync_status == GL_SIGNALED; + return sync_object.IsSignaled(); } void GLInnerFence::Wait() { diff --git a/src/video_core/renderer_opengl/gl_graphics_pipeline.cpp b/src/video_core/renderer_opengl/gl_graphics_pipeline.cpp index 29491e762..89000d6e0 100644 --- a/src/video_core/renderer_opengl/gl_graphics_pipeline.cpp +++ b/src/video_core/renderer_opengl/gl_graphics_pipeline.cpp @@ -621,10 +621,7 @@ bool GraphicsPipeline::IsBuilt() noexcept { if (built_fence.handle == 0) { return false; } - // Timeout of zero means this is non-blocking - const auto sync_status = glClientWaitSync(built_fence.handle, 0, 0); - ASSERT(sync_status != GL_WAIT_FAILED); - is_built = sync_status != GL_TIMEOUT_EXPIRED; + is_built = built_fence.IsSignaled(); return is_built; } diff --git a/src/video_core/renderer_opengl/gl_rasterizer.cpp b/src/video_core/renderer_opengl/gl_rasterizer.cpp index 7bced675c..90e35e307 100644 --- a/src/video_core/renderer_opengl/gl_rasterizer.cpp +++ b/src/video_core/renderer_opengl/gl_rasterizer.cpp @@ -63,7 +63,7 @@ RasterizerOpenGL::RasterizerOpenGL(Core::Frontend::EmuWindow& emu_window_, Tegra buffer_cache(*this, cpu_memory_, buffer_cache_runtime), shader_cache(*this, emu_window_, device, texture_cache, buffer_cache, program_manager, state_tracker, gpu.ShaderNotify()), - query_cache(*this), accelerate_dma(buffer_cache), + query_cache(*this), accelerate_dma(buffer_cache, texture_cache), fence_manager(*this, gpu, texture_cache, buffer_cache, query_cache), blit_image(program_manager_) {} @@ -357,6 +357,7 @@ void RasterizerOpenGL::DrawTexture() { .y = static_cast<s32>(draw_texture_state.src_y1)}}; blit_image.BlitColor(texture_cache.GetFramebuffer()->Handle(), texture.DefaultHandle(), sampler->Handle(), dst_region, src_region, texture.size); + state_tracker.InvalidateState(); } ++num_queued_commands; @@ -576,7 +577,7 @@ bool RasterizerOpenGL::AccelerateConditionalRendering() { // Reimplement Host conditional rendering. return false; } - // Medium / Low Hack: stub any checks on queries writen into the buffer cache. + // Medium / Low Hack: stub any checks on queries written into the buffer cache. const GPUVAddr condition_address{maxwell3d->regs.render_enable.Address()}; Maxwell::ReportSemaphore::Compare cmp; if (gpu_memory->IsMemoryDirty(condition_address, sizeof(cmp), @@ -1262,7 +1263,8 @@ void RasterizerOpenGL::ReleaseChannel(s32 channel_id) { query_cache.EraseChannel(channel_id); } -AccelerateDMA::AccelerateDMA(BufferCache& buffer_cache_) : buffer_cache{buffer_cache_} {} +AccelerateDMA::AccelerateDMA(BufferCache& buffer_cache_, TextureCache& texture_cache_) + : buffer_cache{buffer_cache_}, texture_cache{texture_cache_} {} bool AccelerateDMA::BufferCopy(GPUVAddr src_address, GPUVAddr dest_address, u64 amount) { std::scoped_lock lock{buffer_cache.mutex}; @@ -1274,4 +1276,44 @@ bool AccelerateDMA::BufferClear(GPUVAddr src_address, u64 amount, u32 value) { return buffer_cache.DMAClear(src_address, amount, value); } +template <bool IS_IMAGE_UPLOAD> +bool AccelerateDMA::DmaBufferImageCopy(const Tegra::DMA::ImageCopy& copy_info, + const Tegra::DMA::BufferOperand& buffer_operand, + const Tegra::DMA::ImageOperand& image_operand) { + std::scoped_lock lock{buffer_cache.mutex, texture_cache.mutex}; + const auto image_id = texture_cache.DmaImageId(image_operand); + if (image_id == VideoCommon::NULL_IMAGE_ID) { + return false; + } + const u32 buffer_size = static_cast<u32>(buffer_operand.pitch * buffer_operand.height); + static constexpr auto sync_info = VideoCommon::ObtainBufferSynchronize::FullSynchronize; + const auto post_op = IS_IMAGE_UPLOAD ? VideoCommon::ObtainBufferOperation::DoNothing + : VideoCommon::ObtainBufferOperation::MarkAsWritten; + const auto [buffer, offset] = + buffer_cache.ObtainBuffer(buffer_operand.address, buffer_size, sync_info, post_op); + + const auto [image, copy] = texture_cache.DmaBufferImageCopy( + copy_info, buffer_operand, image_operand, image_id, IS_IMAGE_UPLOAD); + const std::span copy_span{©, 1}; + + if constexpr (IS_IMAGE_UPLOAD) { + image->UploadMemory(buffer->Handle(), offset, copy_span); + } else { + image->DownloadMemory(buffer->Handle(), offset, copy_span); + } + return true; +} + +bool AccelerateDMA::ImageToBuffer(const Tegra::DMA::ImageCopy& copy_info, + const Tegra::DMA::ImageOperand& image_operand, + const Tegra::DMA::BufferOperand& buffer_operand) { + return DmaBufferImageCopy<false>(copy_info, buffer_operand, image_operand); +} + +bool AccelerateDMA::BufferToImage(const Tegra::DMA::ImageCopy& copy_info, + const Tegra::DMA::BufferOperand& buffer_operand, + const Tegra::DMA::ImageOperand& image_operand) { + return DmaBufferImageCopy<true>(copy_info, buffer_operand, image_operand); +} + } // namespace OpenGL diff --git a/src/video_core/renderer_opengl/gl_rasterizer.h b/src/video_core/renderer_opengl/gl_rasterizer.h index 0c45832ae..ad6978bd0 100644 --- a/src/video_core/renderer_opengl/gl_rasterizer.h +++ b/src/video_core/renderer_opengl/gl_rasterizer.h @@ -50,14 +50,26 @@ static_assert(sizeof(BindlessSSBO) * CHAR_BIT == 128); class AccelerateDMA : public Tegra::Engines::AccelerateDMAInterface { public: - explicit AccelerateDMA(BufferCache& buffer_cache); + explicit AccelerateDMA(BufferCache& buffer_cache, TextureCache& texture_cache); bool BufferCopy(GPUVAddr src_address, GPUVAddr dest_address, u64 amount) override; bool BufferClear(GPUVAddr src_address, u64 amount, u32 value) override; + bool ImageToBuffer(const Tegra::DMA::ImageCopy& copy_info, const Tegra::DMA::ImageOperand& src, + const Tegra::DMA::BufferOperand& dst) override; + + bool BufferToImage(const Tegra::DMA::ImageCopy& copy_info, const Tegra::DMA::BufferOperand& src, + const Tegra::DMA::ImageOperand& dst) override; + private: + template <bool IS_IMAGE_UPLOAD> + bool DmaBufferImageCopy(const Tegra::DMA::ImageCopy& copy_info, + const Tegra::DMA::BufferOperand& src, + const Tegra::DMA::ImageOperand& dst); + BufferCache& buffer_cache; + TextureCache& texture_cache; }; class RasterizerOpenGL : public VideoCore::RasterizerAccelerated, @@ -150,7 +162,7 @@ private: /// Syncs the cull mode to match the guest state void SyncCullMode(); - /// Syncs the primitve restart to match the guest state + /// Syncs the primitive restart to match the guest state void SyncPrimitiveRestart(); /// Syncs the depth test state to match the guest state @@ -234,7 +246,7 @@ private: std::array<GLuint, MAX_TEXTURES> texture_handles{}; std::array<GLuint, MAX_IMAGES> image_handles{}; - /// Number of commands queued to the OpenGL driver. Resetted on flush. + /// Number of commands queued to the OpenGL driver. Reset on flush. size_t num_queued_commands = 0; bool has_written_global_memory = false; diff --git a/src/video_core/renderer_opengl/gl_resource_manager.cpp b/src/video_core/renderer_opengl/gl_resource_manager.cpp index 3a664fdec..eae8fd110 100644 --- a/src/video_core/renderer_opengl/gl_resource_manager.cpp +++ b/src/video_core/renderer_opengl/gl_resource_manager.cpp @@ -3,6 +3,7 @@ #include <string_view> #include <glad/glad.h> +#include "common/assert.h" #include "common/microprofile.h" #include "video_core/renderer_opengl/gl_resource_manager.h" #include "video_core/renderer_opengl/gl_shader_util.h" @@ -158,6 +159,15 @@ void OGLSync::Release() { handle = 0; } +bool OGLSync::IsSignaled() const noexcept { + // At least on Nvidia, glClientWaitSync with a timeout of 0 + // is faster than glGetSynciv of GL_SYNC_STATUS. + // Timeout of 0 means this check is non-blocking. + const auto sync_status = glClientWaitSync(handle, 0, 0); + ASSERT(sync_status != GL_WAIT_FAILED); + return sync_status != GL_TIMEOUT_EXPIRED; +} + void OGLFramebuffer::Create() { if (handle != 0) return; diff --git a/src/video_core/renderer_opengl/gl_resource_manager.h b/src/video_core/renderer_opengl/gl_resource_manager.h index bc05ba4bd..77362acd2 100644 --- a/src/video_core/renderer_opengl/gl_resource_manager.h +++ b/src/video_core/renderer_opengl/gl_resource_manager.h @@ -263,6 +263,9 @@ public: /// Deletes the internal OpenGL resource void Release(); + /// Checks if the sync has been signaled + bool IsSignaled() const noexcept; + GLsync handle = 0; }; diff --git a/src/video_core/renderer_opengl/gl_texture_cache.cpp b/src/video_core/renderer_opengl/gl_texture_cache.cpp index b047e7b3d..0b9c4a904 100644 --- a/src/video_core/renderer_opengl/gl_texture_cache.cpp +++ b/src/video_core/renderer_opengl/gl_texture_cache.cpp @@ -112,13 +112,17 @@ GLenum ImageTarget(Shader::TextureType type, int num_samples = 1) { return GL_NONE; } -GLenum TextureMode(PixelFormat format, bool is_first) { +GLenum TextureMode(PixelFormat format, std::array<SwizzleSource, 4> swizzle) { + bool any_r = + std::ranges::any_of(swizzle, [](SwizzleSource s) { return s == SwizzleSource::R; }); switch (format) { case PixelFormat::D24_UNORM_S8_UINT: case PixelFormat::D32_FLOAT_S8_UINT: - return is_first ? GL_DEPTH_COMPONENT : GL_STENCIL_INDEX; + // R = depth, G = stencil + return any_r ? GL_DEPTH_COMPONENT : GL_STENCIL_INDEX; case PixelFormat::S8_UINT_D24_UNORM: - return is_first ? GL_STENCIL_INDEX : GL_DEPTH_COMPONENT; + // R = stencil, G = depth + return any_r ? GL_STENCIL_INDEX : GL_DEPTH_COMPONENT; default: ASSERT(false); return GL_DEPTH_COMPONENT; @@ -208,8 +212,7 @@ void ApplySwizzle(GLuint handle, PixelFormat format, std::array<SwizzleSource, 4 case PixelFormat::D32_FLOAT_S8_UINT: case PixelFormat::S8_UINT_D24_UNORM: UNIMPLEMENTED_IF(swizzle[0] != SwizzleSource::R && swizzle[0] != SwizzleSource::G); - glTextureParameteri(handle, GL_DEPTH_STENCIL_TEXTURE_MODE, - TextureMode(format, swizzle[0] == SwizzleSource::R)); + glTextureParameteri(handle, GL_DEPTH_STENCIL_TEXTURE_MODE, TextureMode(format, swizzle)); std::ranges::transform(swizzle, swizzle.begin(), ConvertGreenRed); break; case PixelFormat::A5B5G5R1_UNORM: { @@ -714,9 +717,7 @@ std::optional<size_t> TextureCacheRuntime::StagingBuffers::FindBuffer(size_t req continue; } if (syncs[index].handle != 0) { - GLint status; - glGetSynciv(syncs[index].handle, GL_SYNC_STATUS, 1, nullptr, &status); - if (status != GL_SIGNALED) { + if (!syncs[index].IsSignaled()) { continue; } syncs[index].Release(); @@ -762,14 +763,14 @@ Image::Image(const VideoCommon::NullImageParams& params) : VideoCommon::ImageBas Image::~Image() = default; -void Image::UploadMemory(const ImageBufferMap& map, +void Image::UploadMemory(GLuint buffer_handle, size_t buffer_offset, std::span<const VideoCommon::BufferImageCopy> copies) { const bool is_rescaled = True(flags & ImageFlagBits::Rescaled); if (is_rescaled) { ScaleDown(true); } - glBindBuffer(GL_PIXEL_UNPACK_BUFFER, map.buffer); - glFlushMappedBufferRange(GL_PIXEL_UNPACK_BUFFER, map.offset, unswizzled_size_bytes); + glBindBuffer(GL_PIXEL_UNPACK_BUFFER, buffer_handle); + glFlushMappedBufferRange(GL_PIXEL_UNPACK_BUFFER, buffer_offset, unswizzled_size_bytes); glPixelStorei(GL_UNPACK_ALIGNMENT, 1); @@ -788,21 +789,26 @@ void Image::UploadMemory(const ImageBufferMap& map, current_image_height = copy.buffer_image_height; glPixelStorei(GL_UNPACK_IMAGE_HEIGHT, current_image_height); } - CopyBufferToImage(copy, map.offset); + CopyBufferToImage(copy, buffer_offset); } if (is_rescaled) { ScaleUp(); } } -void Image::DownloadMemory(ImageBufferMap& map, +void Image::UploadMemory(const ImageBufferMap& map, + std::span<const VideoCommon::BufferImageCopy> copies) { + UploadMemory(map.buffer, map.offset, copies); +} + +void Image::DownloadMemory(GLuint buffer_handle, size_t buffer_offset, std::span<const VideoCommon::BufferImageCopy> copies) { const bool is_rescaled = True(flags & ImageFlagBits::Rescaled); if (is_rescaled) { ScaleDown(); } glMemoryBarrier(GL_PIXEL_BUFFER_BARRIER_BIT); // TODO: Move this to its own API - glBindBuffer(GL_PIXEL_PACK_BUFFER, map.buffer); + glBindBuffer(GL_PIXEL_PACK_BUFFER, buffer_handle); glPixelStorei(GL_PACK_ALIGNMENT, 1); u32 current_row_length = std::numeric_limits<u32>::max(); @@ -820,13 +826,18 @@ void Image::DownloadMemory(ImageBufferMap& map, current_image_height = copy.buffer_image_height; glPixelStorei(GL_PACK_IMAGE_HEIGHT, current_image_height); } - CopyImageToBuffer(copy, map.offset); + CopyImageToBuffer(copy, buffer_offset); } if (is_rescaled) { ScaleUp(true); } } +void Image::DownloadMemory(ImageBufferMap& map, + std::span<const VideoCommon::BufferImageCopy> copies) { + DownloadMemory(map.buffer, map.offset, copies); +} + GLuint Image::StorageHandle() noexcept { switch (info.format) { case PixelFormat::A8B8G8R8_SRGB: diff --git a/src/video_core/renderer_opengl/gl_texture_cache.h b/src/video_core/renderer_opengl/gl_texture_cache.h index e30875496..911e4607a 100644 --- a/src/video_core/renderer_opengl/gl_texture_cache.h +++ b/src/video_core/renderer_opengl/gl_texture_cache.h @@ -206,9 +206,15 @@ public: Image(Image&&) = default; Image& operator=(Image&&) = default; + void UploadMemory(GLuint buffer_handle, size_t buffer_offset, + std::span<const VideoCommon::BufferImageCopy> copies); + void UploadMemory(const ImageBufferMap& map, std::span<const VideoCommon::BufferImageCopy> copies); + void DownloadMemory(GLuint buffer_handle, size_t buffer_offset, + std::span<const VideoCommon::BufferImageCopy> copies); + void DownloadMemory(ImageBufferMap& map, std::span<const VideoCommon::BufferImageCopy> copies); GLuint StorageHandle() noexcept; diff --git a/src/video_core/renderer_vulkan/fixed_pipeline_state.cpp b/src/video_core/renderer_vulkan/fixed_pipeline_state.cpp index f8398b511..e7df32d84 100644 --- a/src/video_core/renderer_vulkan/fixed_pipeline_state.cpp +++ b/src/video_core/renderer_vulkan/fixed_pipeline_state.cpp @@ -271,7 +271,7 @@ bool FixedPipelineState::operator==(const FixedPipelineState& rhs) const noexcep u32 FixedPipelineState::PackComparisonOp(Maxwell::ComparisonOp op) noexcept { // OpenGL enums go from 0x200 to 0x207 and the others from 1 to 8 - // If we substract 0x200 to OpenGL enums and 1 to the others we get a 0-7 range. + // If we subtract 0x200 to OpenGL enums and 1 to the others we get a 0-7 range. // Perfect for a hash. const u32 value = static_cast<u32>(op); return value - (value >= 0x200 ? 0x200 : 1); @@ -322,8 +322,8 @@ Maxwell::StencilOp::Op FixedPipelineState::UnpackStencilOp(u32 packed) noexcept } u32 FixedPipelineState::PackCullFace(Maxwell::CullFace cull) noexcept { - // FrontAndBack is 0x408, by substracting 0x406 in it we get 2. - // Individual cull faces are in 0x404 and 0x405, substracting 0x404 we get 0 and 1. + // FrontAndBack is 0x408, by subtracting 0x406 in it we get 2. + // Individual cull faces are in 0x404 and 0x405, subtracting 0x404 we get 0 and 1. const u32 value = static_cast<u32>(cull); return value - (value == 0x408 ? 0x406 : 0x404); } diff --git a/src/video_core/renderer_vulkan/maxwell_to_vk.cpp b/src/video_core/renderer_vulkan/maxwell_to_vk.cpp index ca52e2389..5dce51be8 100644 --- a/src/video_core/renderer_vulkan/maxwell_to_vk.cpp +++ b/src/video_core/renderer_vulkan/maxwell_to_vk.cpp @@ -166,7 +166,7 @@ struct FormatTuple { {VK_FORMAT_R16G16_UINT, Attachable | Storage}, // R16G16_UINT {VK_FORMAT_R16G16_SINT, Attachable | Storage}, // R16G16_SINT {VK_FORMAT_R16G16_SNORM, Attachable | Storage}, // R16G16_SNORM - {VK_FORMAT_UNDEFINED}, // R32G32B32_FLOAT + {VK_FORMAT_R32G32B32_SFLOAT}, // R32G32B32_FLOAT {VK_FORMAT_A8B8G8R8_SRGB_PACK32, Attachable}, // A8B8G8R8_SRGB {VK_FORMAT_R8G8_UNORM, Attachable | Storage}, // R8G8_UNORM {VK_FORMAT_R8G8_SNORM, Attachable | Storage}, // R8G8_SNORM @@ -234,11 +234,6 @@ FormatInfo SurfaceFormat(const Device& device, FormatType format_type, bool with PixelFormat pixel_format) { ASSERT(static_cast<size_t>(pixel_format) < std::size(tex_format_tuples)); FormatTuple tuple = tex_format_tuples[static_cast<size_t>(pixel_format)]; - if (tuple.format == VK_FORMAT_UNDEFINED) { - UNIMPLEMENTED_MSG("Unimplemented texture format with pixel format={}", pixel_format); - return FormatInfo{VK_FORMAT_A8B8G8R8_UNORM_PACK32, true, true}; - } - // Use A8B8G8R8_UNORM on hardware that doesn't support ASTC natively if (!device.IsOptimalAstcSupported() && VideoCore::Surface::IsPixelFormatASTC(pixel_format)) { const bool is_srgb = with_srgb && VideoCore::Surface::IsPixelFormatSRGB(pixel_format); diff --git a/src/video_core/renderer_vulkan/vk_buffer_cache.cpp b/src/video_core/renderer_vulkan/vk_buffer_cache.cpp index b0153a502..9cbcb3c8f 100644 --- a/src/video_core/renderer_vulkan/vk_buffer_cache.cpp +++ b/src/video_core/renderer_vulkan/vk_buffer_cache.cpp @@ -238,7 +238,7 @@ private: return indices; } - void MakeAndUpdateIndices(u8* staging_data, size_t quad_size, u32 quad, u32 first) { + void MakeAndUpdateIndices(u8* staging_data, size_t quad_size, u32 quad, u32 first) override { switch (index_type) { case VK_INDEX_TYPE_UINT8_EXT: std::memcpy(staging_data, MakeIndices<u8>(quad, first).data(), quad_size); @@ -278,7 +278,7 @@ private: return indices; } - void MakeAndUpdateIndices(u8* staging_data, size_t quad_size, u32 quad, u32 first) { + void MakeAndUpdateIndices(u8* staging_data, size_t quad_size, u32 quad, u32 first) override { switch (index_type) { case VK_INDEX_TYPE_UINT8_EXT: std::memcpy(staging_data, MakeIndices<u8>(quad, first).data(), quad_size); diff --git a/src/video_core/renderer_vulkan/vk_command_pool.cpp b/src/video_core/renderer_vulkan/vk_command_pool.cpp index 2f09de1c1..d0dbf7ca5 100644 --- a/src/video_core/renderer_vulkan/vk_command_pool.cpp +++ b/src/video_core/renderer_vulkan/vk_command_pool.cpp @@ -22,8 +22,8 @@ CommandPool::CommandPool(MasterSemaphore& master_semaphore_, const Device& devic CommandPool::~CommandPool() = default; void CommandPool::Allocate(size_t begin, size_t end) { - // Command buffers are going to be commited, recorded, executed every single usage cycle. - // They are also going to be reseted when commited. + // Command buffers are going to be committed, recorded, executed every single usage cycle. + // They are also going to be reset when committed. Pool& pool = pools.emplace_back(); pool.handle = device.GetLogical().CreateCommandPool({ .sType = VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO, diff --git a/src/video_core/renderer_vulkan/vk_rasterizer.cpp b/src/video_core/renderer_vulkan/vk_rasterizer.cpp index 719edbcfb..673ab478e 100644 --- a/src/video_core/renderer_vulkan/vk_rasterizer.cpp +++ b/src/video_core/renderer_vulkan/vk_rasterizer.cpp @@ -172,7 +172,7 @@ RasterizerVulkan::RasterizerVulkan(Core::Frontend::EmuWindow& emu_window_, Tegra buffer_cache(*this, cpu_memory_, buffer_cache_runtime), pipeline_cache(*this, device, scheduler, descriptor_pool, update_descriptor_queue, render_pass_cache, buffer_cache, texture_cache, gpu.ShaderNotify()), - query_cache{*this, device, scheduler}, accelerate_dma{buffer_cache}, + query_cache{*this, device, scheduler}, accelerate_dma(buffer_cache, texture_cache, scheduler), fence_manager(*this, gpu, texture_cache, buffer_cache, query_cache, device, scheduler), wfi_event(device.GetLogical().CreateEvent()) { scheduler.SetQueryCache(query_cache); @@ -671,7 +671,7 @@ bool RasterizerVulkan::AccelerateConditionalRendering() { // TODO(Blinkhawk): Reimplement Host conditional rendering. return false; } - // Medium / Low Hack: stub any checks on queries writen into the buffer cache. + // Medium / Low Hack: stub any checks on queries written into the buffer cache. const GPUVAddr condition_address{maxwell3d->regs.render_enable.Address()}; Maxwell::ReportSemaphore::Compare cmp; if (gpu_memory->IsMemoryDirty(condition_address, sizeof(cmp), @@ -756,7 +756,9 @@ void RasterizerVulkan::FlushWork() { draw_counter = 0; } -AccelerateDMA::AccelerateDMA(BufferCache& buffer_cache_) : buffer_cache{buffer_cache_} {} +AccelerateDMA::AccelerateDMA(BufferCache& buffer_cache_, TextureCache& texture_cache_, + Scheduler& scheduler_) + : buffer_cache{buffer_cache_}, texture_cache{texture_cache_}, scheduler{scheduler_} {} bool AccelerateDMA::BufferClear(GPUVAddr src_address, u64 amount, u32 value) { std::scoped_lock lock{buffer_cache.mutex}; @@ -768,6 +770,46 @@ bool AccelerateDMA::BufferCopy(GPUVAddr src_address, GPUVAddr dest_address, u64 return buffer_cache.DMACopy(src_address, dest_address, amount); } +template <bool IS_IMAGE_UPLOAD> +bool AccelerateDMA::DmaBufferImageCopy(const Tegra::DMA::ImageCopy& copy_info, + const Tegra::DMA::BufferOperand& buffer_operand, + const Tegra::DMA::ImageOperand& image_operand) { + std::scoped_lock lock{buffer_cache.mutex, texture_cache.mutex}; + const auto image_id = texture_cache.DmaImageId(image_operand); + if (image_id == VideoCommon::NULL_IMAGE_ID) { + return false; + } + const u32 buffer_size = static_cast<u32>(buffer_operand.pitch * buffer_operand.height); + static constexpr auto sync_info = VideoCommon::ObtainBufferSynchronize::FullSynchronize; + const auto post_op = IS_IMAGE_UPLOAD ? VideoCommon::ObtainBufferOperation::DoNothing + : VideoCommon::ObtainBufferOperation::MarkAsWritten; + const auto [buffer, offset] = + buffer_cache.ObtainBuffer(buffer_operand.address, buffer_size, sync_info, post_op); + + const auto [image, copy] = texture_cache.DmaBufferImageCopy( + copy_info, buffer_operand, image_operand, image_id, IS_IMAGE_UPLOAD); + const std::span copy_span{©, 1}; + + if constexpr (IS_IMAGE_UPLOAD) { + image->UploadMemory(buffer->Handle(), offset, copy_span); + } else { + image->DownloadMemory(buffer->Handle(), offset, copy_span); + } + return true; +} + +bool AccelerateDMA::ImageToBuffer(const Tegra::DMA::ImageCopy& copy_info, + const Tegra::DMA::ImageOperand& image_operand, + const Tegra::DMA::BufferOperand& buffer_operand) { + return DmaBufferImageCopy<false>(copy_info, buffer_operand, image_operand); +} + +bool AccelerateDMA::BufferToImage(const Tegra::DMA::ImageCopy& copy_info, + const Tegra::DMA::BufferOperand& buffer_operand, + const Tegra::DMA::ImageOperand& image_operand) { + return DmaBufferImageCopy<true>(copy_info, buffer_operand, image_operand); +} + void RasterizerVulkan::UpdateDynamicStates() { auto& regs = maxwell3d->regs; UpdateViewportsState(regs); @@ -1064,7 +1106,7 @@ void RasterizerVulkan::UpdateDepthBoundsTestEnable(Tegra::Engines::Maxwell3D::Re LOG_WARNING(Render_Vulkan, "Depth bounds is enabled but not supported"); enabled = false; } - scheduler.Record([enable = regs.depth_bounds_enable](vk::CommandBuffer cmdbuf) { + scheduler.Record([enable = enabled](vk::CommandBuffer cmdbuf) { cmdbuf.SetDepthBoundsTestEnableEXT(enable); }); } diff --git a/src/video_core/renderer_vulkan/vk_rasterizer.h b/src/video_core/renderer_vulkan/vk_rasterizer.h index a0508b57c..1659fbc13 100644 --- a/src/video_core/renderer_vulkan/vk_rasterizer.h +++ b/src/video_core/renderer_vulkan/vk_rasterizer.h @@ -45,14 +45,28 @@ class StateTracker; class AccelerateDMA : public Tegra::Engines::AccelerateDMAInterface { public: - explicit AccelerateDMA(BufferCache& buffer_cache); + explicit AccelerateDMA(BufferCache& buffer_cache, TextureCache& texture_cache, + Scheduler& scheduler); bool BufferCopy(GPUVAddr start_address, GPUVAddr end_address, u64 amount) override; bool BufferClear(GPUVAddr src_address, u64 amount, u32 value) override; + bool ImageToBuffer(const Tegra::DMA::ImageCopy& copy_info, const Tegra::DMA::ImageOperand& src, + const Tegra::DMA::BufferOperand& dst) override; + + bool BufferToImage(const Tegra::DMA::ImageCopy& copy_info, const Tegra::DMA::BufferOperand& src, + const Tegra::DMA::ImageOperand& dst) override; + private: + template <bool IS_IMAGE_UPLOAD> + bool DmaBufferImageCopy(const Tegra::DMA::ImageCopy& copy_info, + const Tegra::DMA::BufferOperand& src, + const Tegra::DMA::ImageOperand& dst); + BufferCache& buffer_cache; + TextureCache& texture_cache; + Scheduler& scheduler; }; class RasterizerVulkan final : public VideoCore::RasterizerAccelerated, diff --git a/src/video_core/renderer_vulkan/vk_resource_pool.cpp b/src/video_core/renderer_vulkan/vk_resource_pool.cpp index 6c8ac22f4..6572f82ba 100644 --- a/src/video_core/renderer_vulkan/vk_resource_pool.cpp +++ b/src/video_core/renderer_vulkan/vk_resource_pool.cpp @@ -37,7 +37,7 @@ size_t ResourcePool::CommitResource() { found = free_resource; } } - // Free iterator is hinted to the resource after the one that's been commited. + // Free iterator is hinted to the resource after the one that's been committed. hint_iterator = (*found + 1) % ticks.size(); return *found; } @@ -46,7 +46,7 @@ size_t ResourcePool::ManageOverflow() { const size_t old_capacity = ticks.size(); Grow(); - // The last entry is guaranted to be free, since it's the first element of the freshly + // The last entry is guaranteed to be free, since it's the first element of the freshly // allocated resources. return old_capacity; } diff --git a/src/video_core/renderer_vulkan/vk_scheduler.cpp b/src/video_core/renderer_vulkan/vk_scheduler.cpp index e03685af1..c636a1625 100644 --- a/src/video_core/renderer_vulkan/vk_scheduler.cpp +++ b/src/video_core/renderer_vulkan/vk_scheduler.cpp @@ -47,14 +47,15 @@ Scheduler::Scheduler(const Device& device_, StateTracker& state_tracker_) Scheduler::~Scheduler() = default; void Scheduler::Flush(VkSemaphore signal_semaphore, VkSemaphore wait_semaphore) { + // When flushing, we only send data to the worker thread; no waiting is necessary. SubmitExecution(signal_semaphore, wait_semaphore); AllocateNewContext(); } void Scheduler::Finish(VkSemaphore signal_semaphore, VkSemaphore wait_semaphore) { + // When finishing, we need to wait for the submission to have executed on the device. const u64 presubmit_tick = CurrentTick(); SubmitExecution(signal_semaphore, wait_semaphore); - WaitWorker(); Wait(presubmit_tick); AllocateNewContext(); } @@ -63,8 +64,13 @@ void Scheduler::WaitWorker() { MICROPROFILE_SCOPE(Vulkan_WaitForWorker); DispatchWork(); - std::unique_lock lock{work_mutex}; - wait_cv.wait(lock, [this] { return work_queue.empty(); }); + // Ensure the queue is drained. + std::unique_lock ql{queue_mutex}; + event_cv.wait(ql, [this] { return work_queue.empty(); }); + + // Now wait for execution to finish. + // This needs to be done in the same order as WorkerThread. + std::unique_lock el{execution_mutex}; } void Scheduler::DispatchWork() { @@ -72,10 +78,10 @@ void Scheduler::DispatchWork() { return; } { - std::scoped_lock lock{work_mutex}; + std::scoped_lock ql{queue_mutex}; work_queue.push(std::move(chunk)); } - work_cv.notify_one(); + event_cv.notify_all(); AcquireNewChunk(); } @@ -137,30 +143,55 @@ bool Scheduler::UpdateRescaling(bool is_rescaling) { void Scheduler::WorkerThread(std::stop_token stop_token) { Common::SetCurrentThreadName("VulkanWorker"); - do { + + const auto TryPopQueue{[this](auto& work) -> bool { + if (work_queue.empty()) { + return false; + } + + work = std::move(work_queue.front()); + work_queue.pop(); + event_cv.notify_all(); + return true; + }}; + + while (!stop_token.stop_requested()) { std::unique_ptr<CommandChunk> work; - bool has_submit{false}; + { - std::unique_lock lock{work_mutex}; - if (work_queue.empty()) { - wait_cv.notify_all(); - } - Common::CondvarWait(work_cv, lock, stop_token, [&] { return !work_queue.empty(); }); + std::unique_lock lk{queue_mutex}; + + // Wait for work. + Common::CondvarWait(event_cv, lk, stop_token, [&] { return TryPopQueue(work); }); + + // If we've been asked to stop, we're done. if (stop_token.stop_requested()) { - continue; + return; } - work = std::move(work_queue.front()); - work_queue.pop(); - has_submit = work->HasSubmit(); + // Exchange lock ownership so that we take the execution lock before + // the queue lock goes out of scope. This allows us to force execution + // to complete in the next step. + std::exchange(lk, std::unique_lock{execution_mutex}); + + // Perform the work, tracking whether the chunk was a submission + // before executing. + const bool has_submit = work->HasSubmit(); work->ExecuteAll(current_cmdbuf); + + // If the chunk was a submission, reallocate the command buffer. + if (has_submit) { + AllocateWorkerCommandBuffer(); + } } - if (has_submit) { - AllocateWorkerCommandBuffer(); + + { + std::scoped_lock rl{reserve_mutex}; + + // Recycle the chunk back to the reserve. + chunk_reserve.emplace_back(std::move(work)); } - std::scoped_lock reserve_lock{reserve_mutex}; - chunk_reserve.push_back(std::move(work)); - } while (!stop_token.stop_requested()); + } } void Scheduler::AllocateWorkerCommandBuffer() { @@ -289,13 +320,16 @@ void Scheduler::EndRenderPass() { } void Scheduler::AcquireNewChunk() { - std::scoped_lock lock{reserve_mutex}; + std::scoped_lock rl{reserve_mutex}; + if (chunk_reserve.empty()) { + // If we don't have anything reserved, we need to make a new chunk. chunk = std::make_unique<CommandChunk>(); - return; + } else { + // Otherwise, we can just take from the reserve. + chunk = std::make_unique<CommandChunk>(); + chunk_reserve.pop_back(); } - chunk = std::move(chunk_reserve.back()); - chunk_reserve.pop_back(); } } // namespace Vulkan diff --git a/src/video_core/renderer_vulkan/vk_scheduler.h b/src/video_core/renderer_vulkan/vk_scheduler.h index bd4cb0f7e..8d75ce987 100644 --- a/src/video_core/renderer_vulkan/vk_scheduler.h +++ b/src/video_core/renderer_vulkan/vk_scheduler.h @@ -232,10 +232,10 @@ private: std::queue<std::unique_ptr<CommandChunk>> work_queue; std::vector<std::unique_ptr<CommandChunk>> chunk_reserve; + std::mutex execution_mutex; std::mutex reserve_mutex; - std::mutex work_mutex; - std::condition_variable_any work_cv; - std::condition_variable wait_cv; + std::mutex queue_mutex; + std::condition_variable_any event_cv; std::jthread worker_thread; }; diff --git a/src/video_core/renderer_vulkan/vk_swapchain.cpp b/src/video_core/renderer_vulkan/vk_swapchain.cpp index b6810eef9..85fdce6e5 100644 --- a/src/video_core/renderer_vulkan/vk_swapchain.cpp +++ b/src/video_core/renderer_vulkan/vk_swapchain.cpp @@ -159,7 +159,7 @@ void Swapchain::CreateSwapchain(const VkSurfaceCapabilitiesKHR& capabilities, bo present_mode = ChooseSwapPresentMode(present_modes); u32 requested_image_count{capabilities.minImageCount + 1}; - // Ensure Tripple buffering if possible. + // Ensure Triple buffering if possible. if (capabilities.maxImageCount > 0) { if (requested_image_count > capabilities.maxImageCount) { requested_image_count = capabilities.maxImageCount; diff --git a/src/video_core/renderer_vulkan/vk_texture_cache.cpp b/src/video_core/renderer_vulkan/vk_texture_cache.cpp index 80adb70eb..ae15f6976 100644 --- a/src/video_core/renderer_vulkan/vk_texture_cache.cpp +++ b/src/video_core/renderer_vulkan/vk_texture_cache.cpp @@ -189,13 +189,16 @@ constexpr VkBorderColor ConvertBorderColor(const std::array<float, 4>& color) { if (info.IsRenderTarget()) { return ImageAspectMask(info.format); } - const bool is_first = info.Swizzle()[0] == SwizzleSource::R; + bool any_r = + std::ranges::any_of(info.Swizzle(), [](SwizzleSource s) { return s == SwizzleSource::R; }); switch (info.format) { case PixelFormat::D24_UNORM_S8_UINT: case PixelFormat::D32_FLOAT_S8_UINT: - return is_first ? VK_IMAGE_ASPECT_DEPTH_BIT : VK_IMAGE_ASPECT_STENCIL_BIT; + // R = depth, G = stencil + return any_r ? VK_IMAGE_ASPECT_DEPTH_BIT : VK_IMAGE_ASPECT_STENCIL_BIT; case PixelFormat::S8_UINT_D24_UNORM: - return is_first ? VK_IMAGE_ASPECT_STENCIL_BIT : VK_IMAGE_ASPECT_DEPTH_BIT; + // R = stencil, G = depth + return any_r ? VK_IMAGE_ASPECT_STENCIL_BIT : VK_IMAGE_ASPECT_DEPTH_BIT; case PixelFormat::D16_UNORM: case PixelFormat::D32_FLOAT: return VK_IMAGE_ASPECT_DEPTH_BIT; @@ -864,13 +867,19 @@ void TextureCacheRuntime::ReinterpretImage(Image& dst, Image& src, const VkImageAspectFlags src_aspect_mask = src.AspectMask(); const VkImageAspectFlags dst_aspect_mask = dst.AspectMask(); - std::ranges::transform(copies, vk_in_copies.begin(), [src_aspect_mask](const auto& copy) { - return MakeBufferImageCopy(copy, true, src_aspect_mask); - }); + const auto bpp_in = BytesPerBlock(src.info.format) / DefaultBlockWidth(src.info.format); + const auto bpp_out = BytesPerBlock(dst.info.format) / DefaultBlockWidth(dst.info.format); + std::ranges::transform(copies, vk_in_copies.begin(), + [src_aspect_mask, bpp_in, bpp_out](const auto& copy) { + auto copy2 = copy; + copy2.src_offset.x = (bpp_out * copy.src_offset.x) / bpp_in; + copy2.extent.width = (bpp_out * copy.extent.width) / bpp_in; + return MakeBufferImageCopy(copy2, true, src_aspect_mask); + }); std::ranges::transform(copies, vk_out_copies.begin(), [dst_aspect_mask](const auto& copy) { return MakeBufferImageCopy(copy, false, dst_aspect_mask); }); - const u32 img_bpp = BytesPerBlock(src.info.format); + const u32 img_bpp = BytesPerBlock(dst.info.format); size_t total_size = 0; for (const auto& copy : copies) { total_size += copy.extent.width * copy.extent.height * copy.extent.depth * img_bpp; @@ -1306,15 +1315,16 @@ Image::Image(const VideoCommon::NullImageParams& params) : VideoCommon::ImageBas Image::~Image() = default; -void Image::UploadMemory(const StagingBufferRef& map, std::span<const BufferImageCopy> copies) { +void Image::UploadMemory(VkBuffer buffer, VkDeviceSize offset, + std::span<const VideoCommon::BufferImageCopy> copies) { // TODO: Move this to another API const bool is_rescaled = True(flags & ImageFlagBits::Rescaled); if (is_rescaled) { ScaleDown(true); } scheduler->RequestOutsideRenderPassOperationContext(); - std::vector vk_copies = TransformBufferImageCopies(copies, map.offset, aspect_mask); - const VkBuffer src_buffer = map.buffer; + std::vector vk_copies = TransformBufferImageCopies(copies, offset, aspect_mask); + const VkBuffer src_buffer = buffer; const VkImage vk_image = *original_image; const VkImageAspectFlags vk_aspect_mask = aspect_mask; const bool is_initialized = std::exchange(initialized, true); @@ -1327,14 +1337,19 @@ void Image::UploadMemory(const StagingBufferRef& map, std::span<const BufferImag } } -void Image::DownloadMemory(const StagingBufferRef& map, std::span<const BufferImageCopy> copies) { +void Image::UploadMemory(const StagingBufferRef& map, std::span<const BufferImageCopy> copies) { + UploadMemory(map.buffer, map.offset, copies); +} + +void Image::DownloadMemory(VkBuffer buffer, VkDeviceSize offset, + std::span<const VideoCommon::BufferImageCopy> copies) { const bool is_rescaled = True(flags & ImageFlagBits::Rescaled); if (is_rescaled) { ScaleDown(); } - std::vector vk_copies = TransformBufferImageCopies(copies, map.offset, aspect_mask); + std::vector vk_copies = TransformBufferImageCopies(copies, offset, aspect_mask); scheduler->RequestOutsideRenderPassOperationContext(); - scheduler->Record([buffer = map.buffer, image = *original_image, aspect_mask = aspect_mask, + scheduler->Record([buffer, image = *original_image, aspect_mask = aspect_mask, vk_copies](vk::CommandBuffer cmdbuf) { const VkImageMemoryBarrier read_barrier{ .sType = VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER, @@ -1389,6 +1404,10 @@ void Image::DownloadMemory(const StagingBufferRef& map, std::span<const BufferIm } } +void Image::DownloadMemory(const StagingBufferRef& map, std::span<const BufferImageCopy> copies) { + DownloadMemory(map.buffer, map.offset, copies); +} + bool Image::IsRescaled() const noexcept { return True(flags & ImageFlagBits::Rescaled); } @@ -1763,7 +1782,7 @@ Sampler::Sampler(TextureCacheRuntime& runtime, const Tegra::Texture::TSCEntry& t .minLod = tsc.mipmap_filter == TextureMipmapFilter::None ? 0.0f : tsc.MinLod(), .maxLod = tsc.mipmap_filter == TextureMipmapFilter::None ? 0.25f : tsc.MaxLod(), .borderColor = - arbitrary_borders ? VK_BORDER_COLOR_INT_CUSTOM_EXT : ConvertBorderColor(color), + arbitrary_borders ? VK_BORDER_COLOR_FLOAT_CUSTOM_EXT : ConvertBorderColor(color), .unnormalizedCoordinates = VK_FALSE, }); } diff --git a/src/video_core/renderer_vulkan/vk_texture_cache.h b/src/video_core/renderer_vulkan/vk_texture_cache.h index 0ce39616f..d5ee23f8d 100644 --- a/src/video_core/renderer_vulkan/vk_texture_cache.h +++ b/src/video_core/renderer_vulkan/vk_texture_cache.h @@ -132,9 +132,15 @@ public: Image(Image&&) = default; Image& operator=(Image&&) = default; + void UploadMemory(VkBuffer buffer, VkDeviceSize offset, + std::span<const VideoCommon::BufferImageCopy> copies); + void UploadMemory(const StagingBufferRef& map, std::span<const VideoCommon::BufferImageCopy> copies); + void DownloadMemory(VkBuffer buffer, VkDeviceSize offset, + std::span<const VideoCommon::BufferImageCopy> copies); + void DownloadMemory(const StagingBufferRef& map, std::span<const VideoCommon::BufferImageCopy> copies); diff --git a/src/video_core/renderer_vulkan/vk_update_descriptor.cpp b/src/video_core/renderer_vulkan/vk_update_descriptor.cpp index 4d4a6753b..009dab0b6 100644 --- a/src/video_core/renderer_vulkan/vk_update_descriptor.cpp +++ b/src/video_core/renderer_vulkan/vk_update_descriptor.cpp @@ -25,7 +25,7 @@ void UpdateDescriptorQueue::TickFrame() { void UpdateDescriptorQueue::Acquire() { // Minimum number of entries required. - // This is the maximum number of entries a single draw call migth use. + // This is the maximum number of entries a single draw call might use. static constexpr size_t MIN_ENTRIES = 0x400; if (std::distance(payload.data(), payload_cursor) + MIN_ENTRIES >= payload.max_size()) { diff --git a/src/video_core/texture_cache/format_lookup_table.cpp b/src/video_core/texture_cache/format_lookup_table.cpp index 08aa8ca33..5fc2b2fec 100644 --- a/src/video_core/texture_cache/format_lookup_table.cpp +++ b/src/video_core/texture_cache/format_lookup_table.cpp @@ -42,15 +42,15 @@ PixelFormat PixelFormatFromTextureInfo(TextureFormat format, ComponentType red, ComponentType blue, ComponentType alpha, bool is_srgb) noexcept { switch (Hash(format, red, green, blue, alpha, is_srgb)) { - case Hash(TextureFormat::A8R8G8B8, UNORM): + case Hash(TextureFormat::A8B8G8R8, UNORM): return PixelFormat::A8B8G8R8_UNORM; - case Hash(TextureFormat::A8R8G8B8, SNORM): + case Hash(TextureFormat::A8B8G8R8, SNORM): return PixelFormat::A8B8G8R8_SNORM; - case Hash(TextureFormat::A8R8G8B8, UINT): + case Hash(TextureFormat::A8B8G8R8, UINT): return PixelFormat::A8B8G8R8_UINT; - case Hash(TextureFormat::A8R8G8B8, SINT): + case Hash(TextureFormat::A8B8G8R8, SINT): return PixelFormat::A8B8G8R8_SINT; - case Hash(TextureFormat::A8R8G8B8, UNORM, SRGB): + case Hash(TextureFormat::A8B8G8R8, UNORM, SRGB): return PixelFormat::A8B8G8R8_SRGB; case Hash(TextureFormat::B5G6R5, UNORM): return PixelFormat::B5G6R5_UNORM; @@ -74,13 +74,13 @@ PixelFormat PixelFormatFromTextureInfo(TextureFormat format, ComponentType red, return PixelFormat::R8_UINT; case Hash(TextureFormat::R8, SINT): return PixelFormat::R8_SINT; - case Hash(TextureFormat::R8G8, UNORM): + case Hash(TextureFormat::G8R8, UNORM): return PixelFormat::R8G8_UNORM; - case Hash(TextureFormat::R8G8, SNORM): + case Hash(TextureFormat::G8R8, SNORM): return PixelFormat::R8G8_SNORM; - case Hash(TextureFormat::R8G8, UINT): + case Hash(TextureFormat::G8R8, UINT): return PixelFormat::R8G8_UINT; - case Hash(TextureFormat::R8G8, SINT): + case Hash(TextureFormat::G8R8, SINT): return PixelFormat::R8G8_SINT; case Hash(TextureFormat::R16G16B16A16, FLOAT): return PixelFormat::R16G16B16A16_FLOAT; @@ -136,49 +136,49 @@ PixelFormat PixelFormatFromTextureInfo(TextureFormat format, ComponentType red, return PixelFormat::R32_SINT; case Hash(TextureFormat::E5B9G9R9, FLOAT): return PixelFormat::E5B9G9R9_FLOAT; - case Hash(TextureFormat::D32, FLOAT): + case Hash(TextureFormat::Z32, FLOAT): return PixelFormat::D32_FLOAT; - case Hash(TextureFormat::D16, UNORM): + case Hash(TextureFormat::Z16, UNORM): return PixelFormat::D16_UNORM; - case Hash(TextureFormat::S8D24, UINT, UNORM, UNORM, UNORM, LINEAR): + case Hash(TextureFormat::Z24S8, UINT, UNORM, UNORM, UNORM, LINEAR): return PixelFormat::S8_UINT_D24_UNORM; - case Hash(TextureFormat::S8D24, UINT, UNORM, UINT, UINT, LINEAR): + case Hash(TextureFormat::Z24S8, UINT, UNORM, UINT, UINT, LINEAR): return PixelFormat::S8_UINT_D24_UNORM; - case Hash(TextureFormat::R8G24, UINT, UNORM, UNORM, UNORM, LINEAR): + case Hash(TextureFormat::G24R8, UINT, UNORM, UNORM, UNORM, LINEAR): return PixelFormat::S8_UINT_D24_UNORM; - case Hash(TextureFormat::D24S8, UNORM, UINT, UINT, UINT, LINEAR): + case Hash(TextureFormat::S8Z24, UNORM, UINT, UINT, UINT, LINEAR): return PixelFormat::D24_UNORM_S8_UINT; - case Hash(TextureFormat::D32S8, FLOAT, UINT, UNORM, UNORM, LINEAR): + case Hash(TextureFormat::Z32_X24S8, FLOAT, UINT, UNORM, UNORM, LINEAR): return PixelFormat::D32_FLOAT_S8_UINT; - case Hash(TextureFormat::R32_B24G8, FLOAT, UINT, UNORM, UNORM, LINEAR): + case Hash(TextureFormat::R32B24G8, FLOAT, UINT, UNORM, UNORM, LINEAR): return PixelFormat::D32_FLOAT_S8_UINT; - case Hash(TextureFormat::BC1_RGBA, UNORM, LINEAR): + case Hash(TextureFormat::DXT1, UNORM, LINEAR): return PixelFormat::BC1_RGBA_UNORM; - case Hash(TextureFormat::BC1_RGBA, UNORM, SRGB): + case Hash(TextureFormat::DXT1, UNORM, SRGB): return PixelFormat::BC1_RGBA_SRGB; - case Hash(TextureFormat::BC2, UNORM, LINEAR): + case Hash(TextureFormat::DXT23, UNORM, LINEAR): return PixelFormat::BC2_UNORM; - case Hash(TextureFormat::BC2, UNORM, SRGB): + case Hash(TextureFormat::DXT23, UNORM, SRGB): return PixelFormat::BC2_SRGB; - case Hash(TextureFormat::BC3, UNORM, LINEAR): + case Hash(TextureFormat::DXT45, UNORM, LINEAR): return PixelFormat::BC3_UNORM; - case Hash(TextureFormat::BC3, UNORM, SRGB): + case Hash(TextureFormat::DXT45, UNORM, SRGB): return PixelFormat::BC3_SRGB; - case Hash(TextureFormat::BC4, UNORM): + case Hash(TextureFormat::DXN1, UNORM): return PixelFormat::BC4_UNORM; - case Hash(TextureFormat::BC4, SNORM): + case Hash(TextureFormat::DXN1, SNORM): return PixelFormat::BC4_SNORM; - case Hash(TextureFormat::BC5, UNORM): + case Hash(TextureFormat::DXN2, UNORM): return PixelFormat::BC5_UNORM; - case Hash(TextureFormat::BC5, SNORM): + case Hash(TextureFormat::DXN2, SNORM): return PixelFormat::BC5_SNORM; - case Hash(TextureFormat::BC7, UNORM, LINEAR): + case Hash(TextureFormat::BC7U, UNORM, LINEAR): return PixelFormat::BC7_UNORM; - case Hash(TextureFormat::BC7, UNORM, SRGB): + case Hash(TextureFormat::BC7U, UNORM, SRGB): return PixelFormat::BC7_SRGB; - case Hash(TextureFormat::BC6H_SFLOAT, FLOAT): + case Hash(TextureFormat::BC6H_S16, FLOAT): return PixelFormat::BC6H_SFLOAT; - case Hash(TextureFormat::BC6H_UFLOAT, FLOAT): + case Hash(TextureFormat::BC6H_U16, FLOAT): return PixelFormat::BC6H_UFLOAT; case Hash(TextureFormat::ASTC_2D_4X4, UNORM, LINEAR): return PixelFormat::ASTC_2D_4X4_UNORM; diff --git a/src/video_core/texture_cache/image_base.h b/src/video_core/texture_cache/image_base.h index e8fa592d2..329396bb6 100644 --- a/src/video_core/texture_cache/image_base.h +++ b/src/video_core/texture_cache/image_base.h @@ -25,7 +25,7 @@ enum class ImageFlagBits : u32 { Registered = 1 << 6, ///< True when the image is registered Picked = 1 << 7, ///< Temporary flag to mark the image as picked Remapped = 1 << 8, ///< Image has been remapped. - Sparse = 1 << 9, ///< Image has non continous submemory. + Sparse = 1 << 9, ///< Image has non continuous submemory. // Garbage Collection Flags BadOverlap = 1 << 10, ///< This image overlaps other but doesn't fit, has higher diff --git a/src/video_core/texture_cache/image_info.cpp b/src/video_core/texture_cache/image_info.cpp index e9100091e..a1296b574 100644 --- a/src/video_core/texture_cache/image_info.cpp +++ b/src/video_core/texture_cache/image_info.cpp @@ -216,10 +216,51 @@ ImageInfo::ImageInfo(const Tegra::Engines::Fermi2D::Surface& config) noexcept { .height = config.height, .depth = 1, }; - rescaleable = block.depth == 0; - rescaleable &= size.height > 256; + rescaleable = block.depth == 0 && size.height > 256; downscaleable = size.height > 512; } } +static PixelFormat ByteSizeToFormat(u32 bytes_per_pixel) { + switch (bytes_per_pixel) { + case 1: + return PixelFormat::R8_UINT; + case 2: + return PixelFormat::R8G8_UINT; + case 4: + return PixelFormat::A8B8G8R8_UINT; + case 8: + return PixelFormat::R16G16B16A16_UINT; + case 16: + return PixelFormat::R32G32B32A32_UINT; + default: + UNIMPLEMENTED(); + return PixelFormat::Invalid; + } +} + +ImageInfo::ImageInfo(const Tegra::DMA::ImageOperand& config) noexcept { + const u32 bytes_per_pixel = config.bytes_per_pixel; + format = ByteSizeToFormat(bytes_per_pixel); + type = config.params.block_size.depth > 0 ? ImageType::e3D : ImageType::e2D; + num_samples = 1; + block = Extent3D{ + .width = config.params.block_size.width, + .height = config.params.block_size.height, + .depth = config.params.block_size.depth, + }; + size = Extent3D{ + .width = config.params.width, + .height = config.params.height, + .depth = config.params.depth, + }; + tile_width_spacing = 0; + resources.levels = 1; + resources.layers = 1; + layer_stride = CalculateLayerStride(*this); + maybe_unaligned_layer_stride = CalculateLayerSize(*this); + rescaleable = block.depth == 0 && size.height > 256; + downscaleable = size.height > 512; +} + } // namespace VideoCommon diff --git a/src/video_core/texture_cache/image_info.h b/src/video_core/texture_cache/image_info.h index 93755e15e..a12f5b44f 100644 --- a/src/video_core/texture_cache/image_info.h +++ b/src/video_core/texture_cache/image_info.h @@ -5,6 +5,7 @@ #include "video_core/engines/fermi_2d.h" #include "video_core/engines/maxwell_3d.h" +#include "video_core/engines/maxwell_dma.h" #include "video_core/surface.h" #include "video_core/texture_cache/types.h" @@ -19,6 +20,7 @@ struct ImageInfo { explicit ImageInfo(const Tegra::Engines::Maxwell3D::Regs& regs, size_t index) noexcept; explicit ImageInfo(const Tegra::Engines::Maxwell3D::Regs& regs) noexcept; explicit ImageInfo(const Tegra::Engines::Fermi2D::Surface& config) noexcept; + explicit ImageInfo(const Tegra::DMA::ImageOperand& config) noexcept; PixelFormat format = PixelFormat::Invalid; ImageType type = ImageType::e1D; diff --git a/src/video_core/texture_cache/texture_cache.h b/src/video_core/texture_cache/texture_cache.h index 9dd152fbe..8e8b9a5e6 100644 --- a/src/video_core/texture_cache/texture_cache.h +++ b/src/video_core/texture_cache/texture_cache.h @@ -745,6 +745,25 @@ void TextureCache<P>::PopAsyncFlushes() { } template <class P> +ImageId TextureCache<P>::DmaImageId(const Tegra::DMA::ImageOperand& operand) { + const ImageInfo dst_info(operand); + const ImageId dst_id = FindDMAImage(dst_info, operand.address); + if (!dst_id) { + return NULL_IMAGE_ID; + } + const auto& image = slot_images[dst_id]; + if (False(image.flags & ImageFlagBits::GpuModified)) { + // No need to waste time on an image that's synced with guest + return NULL_IMAGE_ID; + } + const auto base = image.TryFindBase(operand.address); + if (!base) { + return NULL_IMAGE_ID; + } + return dst_id; +} + +template <class P> bool TextureCache<P>::IsRescaling() const noexcept { return is_rescaling; } @@ -772,6 +791,49 @@ bool TextureCache<P>::IsRegionGpuModified(VAddr addr, size_t size) { } template <class P> +std::pair<typename TextureCache<P>::Image*, BufferImageCopy> TextureCache<P>::DmaBufferImageCopy( + const Tegra::DMA::ImageCopy& copy_info, const Tegra::DMA::BufferOperand& buffer_operand, + const Tegra::DMA::ImageOperand& image_operand, ImageId image_id, bool modifies_image) { + const auto [level, base] = PrepareDmaImage(image_id, image_operand.address, modifies_image); + auto* image = &slot_images[image_id]; + const u32 buffer_size = static_cast<u32>(buffer_operand.pitch * buffer_operand.height); + const u32 bpp = VideoCore::Surface::BytesPerBlock(image->info.format); + const auto convert = [old_bpp = image_operand.bytes_per_pixel, bpp](u32 value) { + return (old_bpp * value) / bpp; + }; + const u32 base_x = convert(image_operand.params.origin.x.Value()); + const u32 base_y = image_operand.params.origin.y.Value(); + const u32 length_x = convert(copy_info.length_x); + const u32 length_y = copy_info.length_y; + + const BufferImageCopy copy{ + .buffer_offset = 0, + .buffer_size = buffer_size, + .buffer_row_length = convert(buffer_operand.pitch), + .buffer_image_height = buffer_operand.height, + .image_subresource = + { + .base_level = static_cast<s32>(level), + .base_layer = static_cast<s32>(base), + .num_layers = 1, + }, + .image_offset = + { + .x = static_cast<s32>(base_x), + .y = static_cast<s32>(base_y), + .z = 0, + }, + .image_extent = + { + .width = length_x, + .height = length_y, + .depth = 1, + }, + }; + return {image, copy}; +} + +template <class P> void TextureCache<P>::RefreshContents(Image& image, ImageId image_id) { if (False(image.flags & ImageFlagBits::CpuModified)) { // Only upload modified images @@ -1359,6 +1421,63 @@ std::optional<typename TextureCache<P>::BlitImages> TextureCache<P>::GetBlitImag } template <class P> +ImageId TextureCache<P>::FindDMAImage(const ImageInfo& info, GPUVAddr gpu_addr) { + std::optional<VAddr> cpu_addr = gpu_memory->GpuToCpuAddress(gpu_addr); + if (!cpu_addr) { + cpu_addr = gpu_memory->GpuToCpuAddress(gpu_addr, CalculateGuestSizeInBytes(info)); + if (!cpu_addr) { + return ImageId{}; + } + } + ImageId image_id{}; + boost::container::small_vector<ImageId, 1> image_ids; + const auto lambda = [&](ImageId existing_image_id, ImageBase& existing_image) { + if (True(existing_image.flags & ImageFlagBits::Remapped)) { + return false; + } + if (info.type == ImageType::Linear || existing_image.info.type == ImageType::Linear) + [[unlikely]] { + const bool strict_size = True(existing_image.flags & ImageFlagBits::Strong); + const ImageInfo& existing = existing_image.info; + if (existing_image.gpu_addr == gpu_addr && existing.type == info.type && + existing.pitch == info.pitch && + IsPitchLinearSameSize(existing, info, strict_size) && + IsViewCompatible(existing.format, info.format, false, true)) { + image_id = existing_image_id; + image_ids.push_back(existing_image_id); + return true; + } + } else if (IsSubCopy(info, existing_image, gpu_addr)) { + image_id = existing_image_id; + image_ids.push_back(existing_image_id); + return true; + } + return false; + }; + ForEachImageInRegion(*cpu_addr, CalculateGuestSizeInBytes(info), lambda); + if (image_ids.size() <= 1) [[likely]] { + return image_id; + } + auto image_ids_compare = [this](ImageId a, ImageId b) { + auto& image_a = slot_images[a]; + auto& image_b = slot_images[b]; + return image_a.modification_tick < image_b.modification_tick; + }; + return *std::ranges::max_element(image_ids, image_ids_compare); +} + +template <class P> +std::pair<u32, u32> TextureCache<P>::PrepareDmaImage(ImageId dst_id, GPUVAddr base_addr, + bool mark_as_modified) { + const auto& image = slot_images[dst_id]; + const auto base = image.TryFindBase(base_addr); + PrepareImage(dst_id, mark_as_modified, false); + const auto& new_image = slot_images[dst_id]; + lru_cache.Touch(new_image.lru_index, frame_tick); + return std::make_pair(base->level, base->layer); +} + +template <class P> SamplerId TextureCache<P>::FindSampler(const TSCEntry& config) { if (std::ranges::all_of(config.raw, [](u64 value) { return value == 0; })) { return NULL_SAMPLER_ID; diff --git a/src/video_core/texture_cache/texture_cache_base.h b/src/video_core/texture_cache/texture_cache_base.h index 013836933..5a5b4179c 100644 --- a/src/video_core/texture_cache/texture_cache_base.h +++ b/src/video_core/texture_cache/texture_cache_base.h @@ -209,6 +209,12 @@ public: /// Pop asynchronous downloads void PopAsyncFlushes(); + [[nodiscard]] ImageId DmaImageId(const Tegra::DMA::ImageOperand& operand); + + [[nodiscard]] std::pair<Image*, BufferImageCopy> DmaBufferImageCopy( + const Tegra::DMA::ImageCopy& copy_info, const Tegra::DMA::BufferOperand& buffer_operand, + const Tegra::DMA::ImageOperand& image_operand, ImageId image_id, bool modifies_image); + /// Return true when a CPU region is modified from the GPU [[nodiscard]] bool IsRegionGpuModified(VAddr addr, size_t size); @@ -300,6 +306,8 @@ private: /// Remove joined images from the cache [[nodiscard]] ImageId JoinImages(const ImageInfo& info, GPUVAddr gpu_addr, VAddr cpu_addr); + [[nodiscard]] ImageId FindDMAImage(const ImageInfo& info, GPUVAddr gpu_addr); + /// Return a blit image pair from the given guest blit parameters [[nodiscard]] std::optional<BlitImages> GetBlitImages( const Tegra::Engines::Fermi2D::Surface& dst, const Tegra::Engines::Fermi2D::Surface& src, @@ -381,6 +389,9 @@ private: /// Returns true if the current clear parameters clear the whole image of a given image view [[nodiscard]] bool IsFullClear(ImageViewId id); + [[nodiscard]] std::pair<u32, u32> PrepareDmaImage(ImageId dst_id, GPUVAddr base_addr, + bool mark_as_modified); + bool ImageCanRescale(ImageBase& image); void InvalidateScale(Image& image); bool ScaleUp(Image& image); diff --git a/src/video_core/texture_cache/types.h b/src/video_core/texture_cache/types.h index 0453456b4..a0e10643f 100644 --- a/src/video_core/texture_cache/types.h +++ b/src/video_core/texture_cache/types.h @@ -54,6 +54,7 @@ enum class RelaxedOptions : u32 { Format = 1 << 1, Samples = 1 << 2, ForceBrokenViews = 1 << 3, + FormatBpp = 1 << 4, }; DECLARE_ENUM_FLAG_OPERATORS(RelaxedOptions) diff --git a/src/video_core/texture_cache/util.cpp b/src/video_core/texture_cache/util.cpp index 697f86641..de37db684 100644 --- a/src/video_core/texture_cache/util.cpp +++ b/src/video_core/texture_cache/util.cpp @@ -743,6 +743,44 @@ std::vector<ImageCopy> MakeShrinkImageCopies(const ImageInfo& dst, const ImageIn return copies; } +std::vector<ImageCopy> MakeReinterpretImageCopies(const ImageInfo& src, u32 up_scale, + u32 down_shift) { + std::vector<ImageCopy> copies; + copies.reserve(src.resources.levels); + const bool is_3d = src.type == ImageType::e3D; + for (s32 level = 0; level < src.resources.levels; ++level) { + ImageCopy& copy = copies.emplace_back(); + copy.src_subresource = SubresourceLayers{ + .base_level = level, + .base_layer = 0, + .num_layers = src.resources.layers, + }; + copy.dst_subresource = SubresourceLayers{ + .base_level = level, + .base_layer = 0, + .num_layers = src.resources.layers, + }; + copy.src_offset = Offset3D{ + .x = 0, + .y = 0, + .z = 0, + }; + copy.dst_offset = Offset3D{ + .x = 0, + .y = 0, + .z = 0, + }; + const Extent3D mip_size = AdjustMipSize(src.size, level); + copy.extent = AdjustSamplesSize(mip_size, src.num_samples); + if (is_3d) { + copy.extent.depth = src.size.depth; + } + copy.extent.width = std::max<u32>((copy.extent.width * up_scale) >> down_shift, 1); + copy.extent.height = std::max<u32>((copy.extent.height * up_scale) >> down_shift, 1); + } + return copies; +} + bool IsValidEntry(const Tegra::MemoryManager& gpu_memory, const TICEntry& config) { const GPUVAddr address = config.Address(); if (address == 0) { @@ -999,6 +1037,20 @@ bool IsBlockLinearSizeCompatible(const ImageInfo& lhs, const ImageInfo& rhs, u32 } } +bool IsBlockLinearSizeCompatibleBPPRelaxed(const ImageInfo& lhs, const ImageInfo& rhs, + u32 lhs_level, u32 rhs_level) noexcept { + ASSERT(lhs.type != ImageType::Linear); + ASSERT(rhs.type != ImageType::Linear); + const auto lhs_bpp = BytesPerBlock(lhs.format); + const auto rhs_bpp = BytesPerBlock(rhs.format); + const Extent3D lhs_size = AdjustMipSize(lhs.size, lhs_level); + const Extent3D rhs_size = AdjustMipSize(rhs.size, rhs_level); + return Common::AlignUpLog2(lhs_size.width * lhs_bpp, GOB_SIZE_X_SHIFT) == + Common::AlignUpLog2(rhs_size.width * rhs_bpp, GOB_SIZE_X_SHIFT) && + Common::AlignUpLog2(lhs_size.height, GOB_SIZE_Y_SHIFT) == + Common::AlignUpLog2(rhs_size.height, GOB_SIZE_Y_SHIFT); +} + bool IsPitchLinearSameSize(const ImageInfo& lhs, const ImageInfo& rhs, bool strict_size) noexcept { ASSERT(lhs.type == ImageType::Linear); ASSERT(rhs.type == ImageType::Linear); @@ -1073,7 +1125,8 @@ std::optional<SubresourceBase> FindSubresource(const ImageInfo& candidate, const // Format checking is relaxed, but we still have to check for matching bytes per block. // This avoids creating a view for blits on UE4 titles where formats with different bytes // per block are aliased. - if (BytesPerBlock(existing.format) != BytesPerBlock(candidate.format)) { + if (BytesPerBlock(existing.format) != BytesPerBlock(candidate.format) && + False(options & RelaxedOptions::FormatBpp)) { return std::nullopt; } } else { @@ -1088,10 +1141,8 @@ std::optional<SubresourceBase> FindSubresource(const ImageInfo& candidate, const if (existing.type != candidate.type) { return std::nullopt; } - if (False(options & RelaxedOptions::Samples)) { - if (existing.num_samples != candidate.num_samples) { - return std::nullopt; - } + if (False(options & RelaxedOptions::Samples) && existing.num_samples != candidate.num_samples) { + return std::nullopt; } if (existing.resources.levels < candidate.resources.levels + base->level) { return std::nullopt; @@ -1101,14 +1152,16 @@ std::optional<SubresourceBase> FindSubresource(const ImageInfo& candidate, const if (mip_depth < candidate.size.depth + base->layer) { return std::nullopt; } - } else { - if (existing.resources.layers < candidate.resources.layers + base->layer) { - return std::nullopt; - } + } else if (existing.resources.layers < candidate.resources.layers + base->layer) { + return std::nullopt; } const bool strict_size = False(options & RelaxedOptions::Size); if (!IsBlockLinearSizeCompatible(existing, candidate, base->level, 0, strict_size)) { - return std::nullopt; + if (False(options & RelaxedOptions::FormatBpp)) { + return std::nullopt; + } else if (!IsBlockLinearSizeCompatibleBPPRelaxed(existing, candidate, base->level, 0)) { + return std::nullopt; + } } // TODO: compare block sizes return base; @@ -1120,6 +1173,31 @@ bool IsSubresource(const ImageInfo& candidate, const ImageBase& image, GPUVAddr .has_value(); } +bool IsSubCopy(const ImageInfo& candidate, const ImageBase& image, GPUVAddr candidate_addr) { + const std::optional<SubresourceBase> base = image.TryFindBase(candidate_addr); + if (!base) { + return false; + } + const ImageInfo& existing = image.info; + if (existing.resources.levels < candidate.resources.levels + base->level) { + return false; + } + if (existing.type == ImageType::e3D) { + const u32 mip_depth = std::max(1U, existing.size.depth << base->level); + if (mip_depth < candidate.size.depth + base->layer) { + return false; + } + } else { + if (existing.resources.layers < candidate.resources.layers + base->layer) { + return false; + } + } + if (!IsBlockLinearSizeCompatibleBPPRelaxed(existing, candidate, base->level, 0)) { + return false; + } + return true; +} + void DeduceBlitImages(ImageInfo& dst_info, ImageInfo& src_info, const ImageBase* dst, const ImageBase* src) { const auto original_dst_format = dst_info.format; diff --git a/src/video_core/texture_cache/util.h b/src/video_core/texture_cache/util.h index d103db8ae..84aa6880d 100644 --- a/src/video_core/texture_cache/util.h +++ b/src/video_core/texture_cache/util.h @@ -56,6 +56,10 @@ struct OverlapResult { SubresourceBase base, u32 up_scale = 1, u32 down_shift = 0); +[[nodiscard]] std::vector<ImageCopy> MakeReinterpretImageCopies(const ImageInfo& src, + u32 up_scale = 1, + u32 down_shift = 0); + [[nodiscard]] bool IsValidEntry(const Tegra::MemoryManager& gpu_memory, const TICEntry& config); [[nodiscard]] std::vector<BufferImageCopy> UnswizzleImage(Tegra::MemoryManager& gpu_memory, @@ -88,6 +92,9 @@ void SwizzleImage(Tegra::MemoryManager& gpu_memory, GPUVAddr gpu_addr, const Ima [[nodiscard]] bool IsPitchLinearSameSize(const ImageInfo& lhs, const ImageInfo& rhs, bool strict_size) noexcept; +[[nodiscard]] bool IsBlockLinearSizeCompatibleBPPRelaxed(const ImageInfo& lhs, const ImageInfo& rhs, + u32 lhs_level, u32 rhs_level) noexcept; + [[nodiscard]] std::optional<OverlapResult> ResolveOverlap(const ImageInfo& new_info, GPUVAddr gpu_addr, VAddr cpu_addr, const ImageBase& overlap, @@ -106,6 +113,9 @@ void SwizzleImage(Tegra::MemoryManager& gpu_memory, GPUVAddr gpu_addr, const Ima GPUVAddr candidate_addr, RelaxedOptions options, bool broken_views, bool native_bgr); +[[nodiscard]] bool IsSubCopy(const ImageInfo& candidate, const ImageBase& image, + GPUVAddr candidate_addr); + void DeduceBlitImages(ImageInfo& dst_info, ImageInfo& src_info, const ImageBase* dst, const ImageBase* src); diff --git a/src/video_core/textures/astc.cpp b/src/video_core/textures/astc.cpp index 4381eed1d..a68bc0d77 100644 --- a/src/video_core/textures/astc.cpp +++ b/src/video_core/textures/astc.cpp @@ -1571,7 +1571,7 @@ static void DecompressBlock(std::span<const u8, 16> inBuf, const u32 blockWidth, assert(strm.GetBitsRead() + weightParams.GetPackedBitSize() == 128); // Decode both color data and texel weight data - u32 colorValues[32]; // Four values, two endpoints, four maximum paritions + u32 colorValues[32]; // Four values, two endpoints, four maximum partitions DecodeColorValues(colorValues, colorEndpointData, colorEndpointMode, nPartitions, colorDataBits); diff --git a/src/video_core/textures/texture.h b/src/video_core/textures/texture.h index 7c4553a53..7e5837b20 100644 --- a/src/video_core/textures/texture.h +++ b/src/video_core/textures/texture.h @@ -15,26 +15,26 @@ enum class TextureFormat : u32 { R32G32B32 = 0x02, R16G16B16A16 = 0x03, R32G32 = 0x04, - R32_B24G8 = 0x05, + R32B24G8 = 0x05, ETC2_RGB = 0x06, X8B8G8R8 = 0x07, - A8R8G8B8 = 0x08, + A8B8G8R8 = 0x08, A2B10G10R10 = 0x09, ETC2_RGB_PTA = 0x0a, ETC2_RGBA = 0x0b, R16G16 = 0x0c, - R24G8 = 0x0d, - R8G24 = 0x0e, + G8R24 = 0x0d, + G24R8 = 0x0e, R32 = 0x0f, - BC6H_SFLOAT = 0x10, - BC6H_UFLOAT = 0x11, + BC6H_S16 = 0x10, + BC6H_U16 = 0x11, A4B4G4R4 = 0x12, A5B5G5R1 = 0x13, A1B5G5R5 = 0x14, B5G6R5 = 0x15, B6G5R5 = 0x16, - BC7 = 0x17, - R8G8 = 0x18, + BC7U = 0x17, + G8R8 = 0x18, EAC = 0x19, EACX2 = 0x1a, R16 = 0x1b, @@ -46,33 +46,33 @@ enum class TextureFormat : u32 { B10G11R11 = 0x21, G8B8G8R8 = 0x22, B8G8R8G8 = 0x23, - BC1_RGBA = 0x24, - BC2 = 0x25, - BC3 = 0x26, - BC4 = 0x27, - BC5 = 0x28, - S8D24 = 0x29, - X8D24 = 0x2a, - D24S8 = 0x2b, - X4V4D24__COV4R4V = 0x2c, - X4V4D24__COV8R8V = 0x2d, - V8D24__COV4R12V = 0x2e, - D32 = 0x2f, - D32S8 = 0x30, - X8D24_X20V4S8__COV4R4V = 0x31, - X8D24_X20V4S8__COV8R8V = 0x32, - D32_X20V4X8__COV4R4V = 0x33, - D32_X20V4X8__COV8R8V = 0x34, - D32_X20V4S8__COV4R4V = 0x35, - D32_X20V4S8__COV8R8V = 0x36, - X8D24_X16V8S8__COV4R12V = 0x37, - D32_X16V8X8__COV4R12V = 0x38, - D32_X16V8S8__COV4R12V = 0x39, - D16 = 0x3a, - V8D24__COV8R24V = 0x3b, - X8D24_X16V8S8__COV8R24V = 0x3c, - D32_X16V8X8__COV8R24V = 0x3d, - D32_X16V8S8__COV8R24V = 0x3e, + DXT1 = 0x24, + DXT23 = 0x25, + DXT45 = 0x26, + DXN1 = 0x27, + DXN2 = 0x28, + Z24S8 = 0x29, + X8Z24 = 0x2a, + S8Z24 = 0x2b, + X4V4Z24__COV4R4V = 0x2c, + X4V4Z24__COV8R8V = 0x2d, + V8Z24__COV4R12V = 0x2e, + Z32 = 0x2f, + Z32_X24S8 = 0x30, + X8Z24_X20V4S8__COV4R4V = 0x31, + X8Z24_X20V4S8__COV8R8V = 0x32, + Z32_X20V4X8__COV4R4V = 0x33, + Z32_X20V4X8__COV8R8V = 0x34, + Z32_X20V4S8__COV4R4V = 0x35, + Z32_X20V4S8__COV8R8V = 0x36, + X8Z24_X16V8S8__COV4R12V = 0x37, + Z32_X16V8X8__COV4R12V = 0x38, + Z32_X16V8S8__COV4R12V = 0x39, + Z16 = 0x3a, + V8Z24__COV8R24V = 0x3b, + X8Z24_X16V8S8__COV8R24V = 0x3c, + Z32_X16V8X8__COV8R24V = 0x3d, + Z32_X16V8S8__COV8R24V = 0x3e, ASTC_2D_4X4 = 0x40, ASTC_2D_5X5 = 0x41, ASTC_2D_6X6 = 0x42, diff --git a/src/video_core/vulkan_common/vulkan_device.cpp b/src/video_core/vulkan_common/vulkan_device.cpp index 48f1a3d14..6f288b3f8 100644 --- a/src/video_core/vulkan_common/vulkan_device.cpp +++ b/src/video_core/vulkan_common/vulkan_device.cpp @@ -401,6 +401,12 @@ Device::Device(VkInstance instance_, vk::PhysicalDevice physical_, VkSurfaceKHR loaded_extensions.erase(VK_EXT_EXTENDED_DYNAMIC_STATE_2_EXTENSION_NAME); } } + if (extensions.extended_dynamic_state3 && is_radv) { + LOG_WARNING(Render_Vulkan, "RADV has broken extendedDynamicState3ColorBlendEquation"); + features.extended_dynamic_state3.extendedDynamicState3ColorBlendEnable = false; + features.extended_dynamic_state3.extendedDynamicState3ColorBlendEquation = false; + dynamic_state3_blending = false; + } if (extensions.vertex_input_dynamic_state && is_radv) { // TODO(ameerj): Blacklist only offending driver versions // TODO(ameerj): Confirm if RDNA1 is affected @@ -417,7 +423,7 @@ Device::Device(VkInstance instance_, vk::PhysicalDevice physical_, VkSurfaceKHR sets_per_pool = 64; if (is_amd_driver) { - // AMD drivers need a higher amount of Sets per Pool in certain circunstances like in XC2. + // AMD drivers need a higher amount of Sets per Pool in certain circumstances like in XC2. sets_per_pool = 96; // Disable VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT on AMD GCN4 and lower as it is broken. if (!features.shader_float16_int8.shaderFloat16) { diff --git a/src/video_core/vulkan_common/vulkan_device.h b/src/video_core/vulkan_common/vulkan_device.h index 0662a2d9f..41b5da18a 100644 --- a/src/video_core/vulkan_common/vulkan_device.h +++ b/src/video_core/vulkan_common/vulkan_device.h @@ -180,7 +180,7 @@ public: ~Device(); /** - * Returns a format supported by the device for the passed requeriments. + * Returns a format supported by the device for the passed requirements. * @param wanted_format The ideal format to be returned. It may not be the returned format. * @param wanted_usage The usage that must be fulfilled even if the format is not supported. * @param format_type Format type usage. @@ -259,12 +259,12 @@ public: bool ShouldBoostClocks() const; - /// Returns uniform buffer alignment requeriment. + /// Returns uniform buffer alignment requirement. VkDeviceSize GetUniformBufferAlignment() const { return properties.properties.limits.minUniformBufferOffsetAlignment; } - /// Returns storage alignment requeriment. + /// Returns storage alignment requirement. VkDeviceSize GetStorageBufferAlignment() const { return properties.properties.limits.minStorageBufferOffsetAlignment; } @@ -656,7 +656,7 @@ private: bool is_integrated{}; ///< Is GPU an iGPU. bool is_virtual{}; ///< Is GPU a virtual GPU. bool is_non_gpu{}; ///< Is SoftwareRasterizer, FPGA, non-GPU device. - bool has_broken_cube_compatibility{}; ///< Has broken cube compatiblity bit + bool has_broken_cube_compatibility{}; ///< Has broken cube compatibility bit bool has_renderdoc{}; ///< Has RenderDoc attached bool has_nsight_graphics{}; ///< Has Nsight Graphics attached bool supports_d24_depth{}; ///< Supports D24 depth buffers. diff --git a/src/video_core/vulkan_common/vulkan_wrapper.h b/src/video_core/vulkan_common/vulkan_wrapper.h index e86f661cb..4ff328a21 100644 --- a/src/video_core/vulkan_common/vulkan_wrapper.h +++ b/src/video_core/vulkan_common/vulkan_wrapper.h @@ -68,7 +68,7 @@ public: constexpr Span(const Range& range) : ptr{std::data(range)}, num{std::size(range)} {} /// Construct a span from a pointer and a size. - /// This is inteded for subranges. + /// This is intended for subranges. constexpr Span(const T* ptr_, std::size_t num_) noexcept : ptr{ptr_}, num{num_} {} /// Returns the data pointer by the span. @@ -390,11 +390,11 @@ public: Handle(const Handle&) = delete; Handle& operator=(const Handle&) = delete; - /// Construct a handle transfering the ownership from another handle. + /// Construct a handle transferring the ownership from another handle. Handle(Handle&& rhs) noexcept : handle{std::exchange(rhs.handle, nullptr)}, owner{rhs.owner}, dld{rhs.dld} {} - /// Assign the current handle transfering the ownership from another handle. + /// Assign the current handle transferring the ownership from another handle. /// Destroys any previously held object. Handle& operator=(Handle&& rhs) noexcept { Release(); @@ -463,10 +463,10 @@ public: Handle(const Handle&) = delete; Handle& operator=(const Handle&) = delete; - /// Construct a handle transfering ownership from another handle. + /// Construct a handle transferring ownership from another handle. Handle(Handle&& rhs) noexcept : handle{std::exchange(rhs.handle, nullptr)}, dld{rhs.dld} {} - /// Assign the current handle transfering the ownership from another handle. + /// Assign the current handle transferring the ownership from another handle. /// Destroys any previously held object. Handle& operator=(Handle&& rhs) noexcept { Release(); @@ -533,12 +533,12 @@ public: PoolAllocations(const PoolAllocations&) = delete; PoolAllocations& operator=(const PoolAllocations&) = delete; - /// Construct an allocation transfering ownership from another allocation. + /// Construct an allocation transferring ownership from another allocation. PoolAllocations(PoolAllocations&& rhs) noexcept : allocations{std::move(rhs.allocations)}, num{rhs.num}, device{rhs.device}, pool{rhs.pool}, dld{rhs.dld} {} - /// Assign an allocation transfering ownership from another allocation. + /// Assign an allocation transferring ownership from another allocation. PoolAllocations& operator=(PoolAllocations&& rhs) noexcept { allocations = std::move(rhs.allocations); num = rhs.num; diff --git a/src/yuzu/applets/qt_web_browser.h b/src/yuzu/applets/qt_web_browser.h index e8fe511ed..ceae7926e 100644 --- a/src/yuzu/applets/qt_web_browser.h +++ b/src/yuzu/applets/qt_web_browser.h @@ -110,7 +110,7 @@ private: /** * Handles button presses to execute functions assigned in yuzu_key_callbacks. * yuzu_key_callbacks contains specialized functions for the buttons in the window footer - * that can be overriden by games to achieve desired functionality. + * that can be overridden by games to achieve desired functionality. * * @tparam HIDButton The list of buttons contained in yuzu_key_callbacks */ diff --git a/src/yuzu/compatdb.cpp b/src/yuzu/compatdb.cpp index 05f49c0d2..a57a96a38 100644 --- a/src/yuzu/compatdb.cpp +++ b/src/yuzu/compatdb.cpp @@ -76,7 +76,7 @@ void CompatDB::Submit() { compatibility_Graphical->addButton(ui->radioButton_Audio_Minor, 1); compatibility_Audio->addButton(ui->radioButton_Audio_No, 2); - const int compatiblity = static_cast<int>(CalculateCompatibility()); + const int compatibility = static_cast<int>(CalculateCompatibility()); switch ((static_cast<CompatDBPage>(currentId()))) { case CompatDBPage::Intro: @@ -113,9 +113,9 @@ void CompatDB::Submit() { break; case CompatDBPage::Final: back(); - LOG_INFO(Frontend, "Compatibility Rating: {}", compatiblity); + LOG_INFO(Frontend, "Compatibility Rating: {}", compatibility); telemetry_session.AddField(Common::Telemetry::FieldType::UserFeedback, "Compatibility", - compatiblity); + compatibility); button(NextButton)->setEnabled(false); button(NextButton)->setText(tr("Submitting")); diff --git a/src/yuzu/configuration/configure_audio.cpp b/src/yuzu/configuration/configure_audio.cpp index 70cc6f84b..fcd6d61a0 100644 --- a/src/yuzu/configuration/configure_audio.cpp +++ b/src/yuzu/configuration/configure_audio.cpp @@ -10,6 +10,7 @@ #include "ui_configure_audio.h" #include "yuzu/configuration/configuration_shared.h" #include "yuzu/configuration/configure_audio.h" +#include "yuzu/uisettings.h" ConfigureAudio::ConfigureAudio(const Core::System& system_, QWidget* parent) : QWidget(parent), ui(std::make_unique<Ui::ConfigureAudio>()), system{system_} { @@ -47,6 +48,7 @@ void ConfigureAudio::SetConfiguration() { const auto volume_value = static_cast<int>(Settings::values.volume.GetValue()); ui->volume_slider->setValue(volume_value); + ui->toggle_background_mute->setChecked(UISettings::values.mute_when_in_background.GetValue()); if (!Settings::IsConfiguringGlobal()) { if (Settings::values.volume.UsingGlobal()) { @@ -56,8 +58,13 @@ void ConfigureAudio::SetConfiguration() { ui->volume_combo_box->setCurrentIndex(1); ui->volume_slider->setEnabled(true); } + ConfigurationShared::SetPerGameSetting(ui->combo_sound, &Settings::values.sound_index); + ConfigurationShared::SetHighlight(ui->mode_label, + !Settings::values.sound_index.UsingGlobal()); ConfigurationShared::SetHighlight(ui->volume_layout, !Settings::values.volume.UsingGlobal()); + } else { + ui->combo_sound->setCurrentIndex(Settings::values.sound_index.GetValue()); } SetVolumeIndicatorText(ui->volume_slider->sliderPosition()); } @@ -109,6 +116,8 @@ void ConfigureAudio::SetVolumeIndicatorText(int percentage) { } void ConfigureAudio::ApplyConfiguration() { + ConfigurationShared::ApplyPerGameSetting(&Settings::values.sound_index, ui->combo_sound); + if (Settings::IsConfiguringGlobal()) { Settings::values.sink_id = ui->sink_combo_box->itemText(ui->sink_combo_box->currentIndex()).toStdString(); @@ -116,6 +125,7 @@ void ConfigureAudio::ApplyConfiguration() { ui->output_combo_box->itemText(ui->output_combo_box->currentIndex()).toStdString()); Settings::values.audio_input_device_id.SetValue( ui->input_combo_box->itemText(ui->input_combo_box->currentIndex()).toStdString()); + UISettings::values.mute_when_in_background = ui->toggle_background_mute->isChecked(); // Guard if during game and set to game-specific value if (Settings::values.volume.UsingGlobal()) { @@ -173,11 +183,14 @@ void ConfigureAudio::RetranslateUI() { void ConfigureAudio::SetupPerGameUI() { if (Settings::IsConfiguringGlobal()) { + ui->combo_sound->setEnabled(Settings::values.sound_index.UsingGlobal()); ui->volume_slider->setEnabled(Settings::values.volume.UsingGlobal()); - return; } + ConfigurationShared::SetColoredComboBox(ui->combo_sound, ui->mode_label, + Settings::values.sound_index.GetValue(true)); + connect(ui->volume_combo_box, qOverload<int>(&QComboBox::activated), this, [this](int index) { ui->volume_slider->setEnabled(index == 1); ConfigurationShared::SetHighlight(ui->volume_layout, index == 1); diff --git a/src/yuzu/configuration/configure_audio.ui b/src/yuzu/configuration/configure_audio.ui index 6034d8581..4128c83ad 100644 --- a/src/yuzu/configuration/configure_audio.ui +++ b/src/yuzu/configuration/configure_audio.ui @@ -39,7 +39,7 @@ <item> <widget class="QLabel" name="output_label"> <property name="text"> - <string>Output Device</string> + <string>Output Device:</string> </property> </widget> </item> @@ -53,7 +53,7 @@ <item> <widget class="QLabel" name="input_label"> <property name="text"> - <string>Input Device</string> + <string>Input Device:</string> </property> </widget> </item> @@ -62,6 +62,36 @@ </item> </layout> </item> + <item> + <layout class="QHBoxLayout" name="mode_layout"> + <item> + <widget class="QLabel" name="mode_label"> + <property name="text"> + <string>Sound Output Mode:</string> + </property> + </widget> + </item> + <item> + <widget class="QComboBox" name="combo_sound"> + <item> + <property name="text"> + <string>Mono</string> + </property> + </item> + <item> + <property name="text"> + <string>Stereo</string> + </property> + </item> + <item> + <property name="text"> + <string>Surround</string> + </property> + </item> + </widget> + </item> + </layout> + </item> <item> <widget class="QWidget" name="volume_layout" native="true"> <layout class="QHBoxLayout" name="horizontalLayout_2"> @@ -149,6 +179,17 @@ </layout> </widget> </item> + <item> + <layout class="QHBoxLayout" name="mute_layout"> + <item> + <widget class="QCheckBox" name="toggle_background_mute"> + <property name="text"> + <string>Mute audio when in background</string> + </property> + </widget> + </item> + </layout> + </item> </layout> </widget> </item> diff --git a/src/yuzu/configuration/configure_general.cpp b/src/yuzu/configuration/configure_general.cpp index 7ade01ba6..207bcdc4d 100644 --- a/src/yuzu/configuration/configure_general.cpp +++ b/src/yuzu/configuration/configure_general.cpp @@ -42,7 +42,6 @@ void ConfigureGeneral::SetConfiguration() { ui->toggle_check_exit->setChecked(UISettings::values.confirm_before_closing.GetValue()); ui->toggle_user_on_boot->setChecked(UISettings::values.select_user_on_boot.GetValue()); ui->toggle_background_pause->setChecked(UISettings::values.pause_when_in_background.GetValue()); - ui->toggle_background_mute->setChecked(UISettings::values.mute_when_in_background.GetValue()); ui->toggle_hide_mouse->setChecked(UISettings::values.hide_mouse.GetValue()); ui->toggle_speed_limit->setChecked(Settings::values.use_speed_limit.GetValue()); @@ -88,7 +87,6 @@ void ConfigureGeneral::ApplyConfiguration() { UISettings::values.confirm_before_closing = ui->toggle_check_exit->isChecked(); UISettings::values.select_user_on_boot = ui->toggle_user_on_boot->isChecked(); UISettings::values.pause_when_in_background = ui->toggle_background_pause->isChecked(); - UISettings::values.mute_when_in_background = ui->toggle_background_mute->isChecked(); UISettings::values.hide_mouse = ui->toggle_hide_mouse->isChecked(); // Guard if during game and set to game-specific value diff --git a/src/yuzu/configuration/configure_general.ui b/src/yuzu/configuration/configure_general.ui index 5b90b1109..6cd79673c 100644 --- a/src/yuzu/configuration/configure_general.ui +++ b/src/yuzu/configuration/configure_general.ui @@ -90,13 +90,6 @@ </widget> </item> <item> - <widget class="QCheckBox" name="toggle_background_mute"> - <property name="text"> - <string>Mute audio when in background</string> - </property> - </widget> - </item> - <item> <widget class="QCheckBox" name="toggle_hide_mouse"> <property name="text"> <string>Hide mouse on inactivity</string> diff --git a/src/yuzu/configuration/configure_hotkeys.h b/src/yuzu/configuration/configure_hotkeys.h index b45ecb185..e8e414320 100644 --- a/src/yuzu/configuration/configure_hotkeys.h +++ b/src/yuzu/configuration/configure_hotkeys.h @@ -34,7 +34,7 @@ public: /** * Populates the hotkey list widget using data from the provided registry. - * Called everytime the Configure dialog is opened. + * Called every time the Configure dialog is opened. * @param registry The HotkeyRegistry whose data is used to populate the list. */ void Populate(const HotkeyRegistry& registry); diff --git a/src/yuzu/configuration/configure_input_player.h b/src/yuzu/configuration/configure_input_player.h index 99a9c875d..d4df43d73 100644 --- a/src/yuzu/configuration/configure_input_player.h +++ b/src/yuzu/configuration/configure_input_player.h @@ -224,7 +224,7 @@ private: /// Bottom row is where console wide settings are held, and its "owned" by the parent /// ConfigureInput widget. On show, add this widget to the main layout. This will change the - /// parent of the widget to this widget (but thats fine). + /// parent of the widget to this widget (but that's fine). QWidget* bottom_row; Core::HID::HIDCore& hid_core; diff --git a/src/yuzu/configuration/configure_input_player_widget.h b/src/yuzu/configuration/configure_input_player_widget.h index 0e9e95e85..267d134de 100644 --- a/src/yuzu/configuration/configure_input_player_widget.h +++ b/src/yuzu/configuration/configure_input_player_widget.h @@ -43,7 +43,7 @@ public: // Handles emulated controller events void ControllerUpdate(Core::HID::ControllerTriggerType type); - // Updates input on sheduled interval + // Updates input on scheduled interval void UpdateInput(); protected: diff --git a/src/yuzu/configuration/configure_system.cpp b/src/yuzu/configuration/configure_system.cpp index 9ea4c02da..6af34f793 100644 --- a/src/yuzu/configuration/configure_system.cpp +++ b/src/yuzu/configuration/configure_system.cpp @@ -40,8 +40,6 @@ static bool IsValidLocale(u32 region_index, u32 language_index) { ConfigureSystem::ConfigureSystem(Core::System& system_, QWidget* parent) : QWidget(parent), ui{std::make_unique<Ui::ConfigureSystem>()}, system{system_} { ui->setupUi(this); - connect(ui->button_regenerate_console_id, &QPushButton::clicked, this, - &ConfigureSystem::RefreshConsoleID); connect(ui->rng_seed_checkbox, &QCheckBox::stateChanged, this, [this](int state) { ui->rng_seed_edit->setEnabled(state == Qt::Checked); @@ -76,9 +74,6 @@ ConfigureSystem::ConfigureSystem(Core::System& system_, QWidget* parent) locale_check); connect(ui->combo_region, qOverload<int>(&QComboBox::currentIndexChanged), this, locale_check); - ui->label_console_id->setVisible(Settings::IsConfiguringGlobal()); - ui->button_regenerate_console_id->setVisible(Settings::IsConfiguringGlobal()); - SetupPerGameUI(); SetConfiguration(); @@ -121,14 +116,12 @@ void ConfigureSystem::SetConfiguration() { ui->combo_language->setCurrentIndex(Settings::values.language_index.GetValue()); ui->combo_region->setCurrentIndex(Settings::values.region_index.GetValue()); ui->combo_time_zone->setCurrentIndex(Settings::values.time_zone_index.GetValue()); - ui->combo_sound->setCurrentIndex(Settings::values.sound_index.GetValue()); } else { ConfigurationShared::SetPerGameSetting(ui->combo_language, &Settings::values.language_index); ConfigurationShared::SetPerGameSetting(ui->combo_region, &Settings::values.region_index); ConfigurationShared::SetPerGameSetting(ui->combo_time_zone, &Settings::values.time_zone_index); - ConfigurationShared::SetPerGameSetting(ui->combo_sound, &Settings::values.sound_index); ConfigurationShared::SetHighlight(ui->label_language, !Settings::values.language_index.UsingGlobal()); @@ -136,8 +129,6 @@ void ConfigureSystem::SetConfiguration() { !Settings::values.region_index.UsingGlobal()); ConfigurationShared::SetHighlight(ui->label_timezone, !Settings::values.time_zone_index.UsingGlobal()); - ConfigurationShared::SetHighlight(ui->label_sound, - !Settings::values.sound_index.UsingGlobal()); } } @@ -169,7 +160,6 @@ void ConfigureSystem::ApplyConfiguration() { ConfigurationShared::ApplyPerGameSetting(&Settings::values.region_index, ui->combo_region); ConfigurationShared::ApplyPerGameSetting(&Settings::values.time_zone_index, ui->combo_time_zone); - ConfigurationShared::ApplyPerGameSetting(&Settings::values.sound_index, ui->combo_sound); if (Settings::IsConfiguringGlobal()) { // Guard if during game and set to game-specific value @@ -202,29 +192,11 @@ void ConfigureSystem::ApplyConfiguration() { } } -void ConfigureSystem::RefreshConsoleID() { - QMessageBox::StandardButton reply; - QString warning_text = tr("This will replace your current virtual Switch with a new one. " - "Your current virtual Switch will not be recoverable. " - "This might have unexpected effects in games. This might fail, " - "if you use an outdated config savegame. Continue?"); - reply = QMessageBox::critical(this, tr("Warning"), warning_text, - QMessageBox::No | QMessageBox::Yes); - if (reply == QMessageBox::No) { - return; - } - - u64 console_id{}; - ui->label_console_id->setText( - tr("Console ID: 0x%1").arg(QString::number(console_id, 16).toUpper())); -} - void ConfigureSystem::SetupPerGameUI() { if (Settings::IsConfiguringGlobal()) { ui->combo_language->setEnabled(Settings::values.language_index.UsingGlobal()); ui->combo_region->setEnabled(Settings::values.region_index.UsingGlobal()); ui->combo_time_zone->setEnabled(Settings::values.time_zone_index.UsingGlobal()); - ui->combo_sound->setEnabled(Settings::values.sound_index.UsingGlobal()); ui->rng_seed_checkbox->setEnabled(Settings::values.rng_seed.UsingGlobal()); ui->rng_seed_edit->setEnabled(Settings::values.rng_seed.UsingGlobal()); @@ -237,8 +209,6 @@ void ConfigureSystem::SetupPerGameUI() { Settings::values.region_index.GetValue(true)); ConfigurationShared::SetColoredComboBox(ui->combo_time_zone, ui->label_timezone, Settings::values.time_zone_index.GetValue(true)); - ConfigurationShared::SetColoredComboBox(ui->combo_sound, ui->label_sound, - Settings::values.sound_index.GetValue(true)); ConfigurationShared::SetColoredTristate( ui->rng_seed_checkbox, Settings::values.rng_seed.UsingGlobal(), diff --git a/src/yuzu/configuration/configure_system.h b/src/yuzu/configuration/configure_system.h index a7f086258..ec28724a1 100644 --- a/src/yuzu/configuration/configure_system.h +++ b/src/yuzu/configuration/configure_system.h @@ -35,8 +35,6 @@ private: void ReadSystemSettings(); - void RefreshConsoleID(); - void SetupPerGameUI(); std::unique_ptr<Ui::ConfigureSystem> ui; diff --git a/src/yuzu/configuration/configure_system.ui b/src/yuzu/configuration/configure_system.ui index 0459cd924..9e7bc3b93 100644 --- a/src/yuzu/configuration/configure_system.ui +++ b/src/yuzu/configuration/configure_system.ui @@ -411,7 +411,7 @@ </item> </widget> </item> - <item row="5" column="0"> + <item row="4" column="0"> <widget class="QCheckBox" name="custom_rtc_checkbox"> <property name="text"> <string>Custom RTC</string> @@ -425,54 +425,21 @@ </property> </widget> </item> - <item row="6" column="0"> + <item row="5" column="0"> <widget class="QCheckBox" name="rng_seed_checkbox"> <property name="text"> <string>RNG Seed</string> </property> </widget> </item> - <item row="7" column="0"> + <item row="6" column="0"> <widget class="QLabel" name="device_name_label"> <property name="text"> <string>Device Name</string> </property> </widget> </item> - <item row="3" column="1"> - <widget class="QComboBox" name="combo_sound"> - <item> - <property name="text"> - <string>Mono</string> - </property> - </item> - <item> - <property name="text"> - <string>Stereo</string> - </property> - </item> - <item> - <property name="text"> - <string>Surround</string> - </property> - </item> - </widget> - </item> - <item row="4" column="0"> - <widget class="QLabel" name="label_console_id"> - <property name="text"> - <string>Console ID:</string> - </property> - </widget> - </item> - <item row="3" column="0"> - <widget class="QLabel" name="label_sound"> - <property name="text"> - <string>Sound output mode</string> - </property> - </widget> - </item> - <item row="5" column="1"> + <item row="4" column="1"> <widget class="QDateTimeEdit" name="custom_rtc_edit"> <property name="minimumDate"> <date> @@ -483,14 +450,14 @@ </property> </widget> </item> - <item row="7" column="1"> + <item row="6" column="1"> <widget class="QLineEdit" name="device_name_edit"> <property name="maxLength"> <number>128</number> </property> </widget> </item> - <item row="6" column="1"> + <item row="5" column="1"> <widget class="QLineEdit" name="rng_seed_edit"> <property name="sizePolicy"> <sizepolicy hsizetype="Minimum" vsizetype="Fixed"> @@ -511,22 +478,6 @@ </property> </widget> </item> - <item row="4" column="1"> - <widget class="QPushButton" name="button_regenerate_console_id"> - <property name="sizePolicy"> - <sizepolicy hsizetype="Fixed" vsizetype="Fixed"> - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> - </property> - <property name="layoutDirection"> - <enum>Qt::RightToLeft</enum> - </property> - <property name="text"> - <string>Regenerate</string> - </property> - </widget> - </item> </layout> </item> </layout> diff --git a/src/yuzu/debugger/wait_tree.cpp b/src/yuzu/debugger/wait_tree.cpp index 7f7c5fc42..0783a2430 100644 --- a/src/yuzu/debugger/wait_tree.cpp +++ b/src/yuzu/debugger/wait_tree.cpp @@ -112,33 +112,6 @@ QString WaitTreeText::GetText() const { return text; } -WaitTreeMutexInfo::WaitTreeMutexInfo(VAddr mutex_address_, const Kernel::KHandleTable& handle_table, - Core::System& system_) - : mutex_address{mutex_address_}, system{system_} { - mutex_value = system.Memory().Read32(mutex_address); - owner_handle = static_cast<Kernel::Handle>(mutex_value & Kernel::Svc::HandleWaitMask); - owner = handle_table.GetObject<Kernel::KThread>(owner_handle).GetPointerUnsafe(); -} - -WaitTreeMutexInfo::~WaitTreeMutexInfo() = default; - -QString WaitTreeMutexInfo::GetText() const { - return tr("waiting for mutex 0x%1").arg(mutex_address, 16, 16, QLatin1Char{'0'}); -} - -std::vector<std::unique_ptr<WaitTreeItem>> WaitTreeMutexInfo::GetChildren() const { - const bool has_waiters = (mutex_value & Kernel::Svc::HandleWaitMask) != 0; - - std::vector<std::unique_ptr<WaitTreeItem>> list; - list.push_back(std::make_unique<WaitTreeText>(tr("has waiters: %1").arg(has_waiters))); - list.push_back(std::make_unique<WaitTreeText>( - tr("owner handle: 0x%1").arg(owner_handle, 8, 16, QLatin1Char{'0'}))); - if (owner != nullptr) { - list.push_back(std::make_unique<WaitTreeThread>(*owner, system)); - } - return list; -} - WaitTreeCallstack::WaitTreeCallstack(const Kernel::KThread& thread_, Core::System& system_) : thread{thread_}, system{system_} {} WaitTreeCallstack::~WaitTreeCallstack() = default; @@ -182,10 +155,9 @@ bool WaitTreeExpandableItem::IsExpandable() const { } QString WaitTreeSynchronizationObject::GetText() const { - return tr("[%1] %2 %3") + return tr("[%1] %2") .arg(object.GetId()) - .arg(QString::fromStdString(object.GetTypeObj().GetName()), - QString::fromStdString(object.GetName())); + .arg(QString::fromStdString(object.GetTypeObj().GetName())); } std::unique_ptr<WaitTreeSynchronizationObject> WaitTreeSynchronizationObject::make( @@ -217,26 +189,6 @@ std::vector<std::unique_ptr<WaitTreeItem>> WaitTreeSynchronizationObject::GetChi return list; } -WaitTreeObjectList::WaitTreeObjectList(const std::vector<Kernel::KSynchronizationObject*>& list, - bool w_all, Core::System& system_) - : object_list(list), wait_all(w_all), system{system_} {} - -WaitTreeObjectList::~WaitTreeObjectList() = default; - -QString WaitTreeObjectList::GetText() const { - if (wait_all) - return tr("waiting for all objects"); - return tr("waiting for one of the following objects"); -} - -std::vector<std::unique_ptr<WaitTreeItem>> WaitTreeObjectList::GetChildren() const { - std::vector<std::unique_ptr<WaitTreeItem>> list(object_list.size()); - std::transform(object_list.begin(), object_list.end(), list.begin(), [this](const auto& t) { - return WaitTreeSynchronizationObject::make(*t, system); - }); - return list; -} - WaitTreeThread::WaitTreeThread(const Kernel::KThread& thread, Core::System& system_) : WaitTreeSynchronizationObject(thread, system_), system{system_} {} WaitTreeThread::~WaitTreeThread() = default; @@ -348,32 +300,14 @@ std::vector<std::unique_ptr<WaitTreeItem>> WaitTreeThread::GetChildren() const { list.push_back(std::make_unique<WaitTreeText>(tr("processor = %1").arg(processor))); list.push_back(std::make_unique<WaitTreeText>( - tr("ideal core = %1").arg(thread.GetIdealCoreForDebugging()))); - list.push_back(std::make_unique<WaitTreeText>( tr("affinity mask = %1").arg(thread.GetAffinityMask().GetAffinityMask()))); - list.push_back(std::make_unique<WaitTreeText>(tr("thread id = %1").arg(thread.GetThreadID()))); + list.push_back(std::make_unique<WaitTreeText>(tr("thread id = %1").arg(thread.GetThreadId()))); list.push_back(std::make_unique<WaitTreeText>(tr("priority = %1(current) / %2(normal)") .arg(thread.GetPriority()) .arg(thread.GetBasePriority()))); list.push_back(std::make_unique<WaitTreeText>( tr("last running ticks = %1").arg(thread.GetLastScheduledTick()))); - const VAddr mutex_wait_address = thread.GetMutexWaitAddressForDebugging(); - if (mutex_wait_address != 0) { - const auto& handle_table = thread.GetOwnerProcess()->GetHandleTable(); - list.push_back( - std::make_unique<WaitTreeMutexInfo>(mutex_wait_address, handle_table, system)); - } else { - list.push_back(std::make_unique<WaitTreeText>(tr("not waiting for mutex"))); - } - - if (thread.GetState() == Kernel::ThreadState::Waiting && - thread.GetWaitReasonForDebugging() == - Kernel::ThreadWaitReasonForDebugging::Synchronization) { - list.push_back(std::make_unique<WaitTreeObjectList>(thread.GetWaitObjectsForDebugging(), - thread.IsCancellable(), system)); - } - list.push_back(std::make_unique<WaitTreeCallstack>(thread, system)); return list; diff --git a/src/yuzu/debugger/wait_tree.h b/src/yuzu/debugger/wait_tree.h index 7e528b592..23c329fbe 100644 --- a/src/yuzu/debugger/wait_tree.h +++ b/src/yuzu/debugger/wait_tree.h @@ -74,25 +74,6 @@ public: bool IsExpandable() const override; }; -class WaitTreeMutexInfo : public WaitTreeExpandableItem { - Q_OBJECT -public: - explicit WaitTreeMutexInfo(VAddr mutex_address_, const Kernel::KHandleTable& handle_table, - Core::System& system_); - ~WaitTreeMutexInfo() override; - - QString GetText() const override; - std::vector<std::unique_ptr<WaitTreeItem>> GetChildren() const override; - -private: - VAddr mutex_address{}; - u32 mutex_value{}; - Kernel::Handle owner_handle{}; - Kernel::KThread* owner{}; - - Core::System& system; -}; - class WaitTreeCallstack : public WaitTreeExpandableItem { Q_OBJECT public: @@ -127,23 +108,6 @@ private: Core::System& system; }; -class WaitTreeObjectList : public WaitTreeExpandableItem { - Q_OBJECT -public: - WaitTreeObjectList(const std::vector<Kernel::KSynchronizationObject*>& list, bool wait_all, - Core::System& system_); - ~WaitTreeObjectList() override; - - QString GetText() const override; - std::vector<std::unique_ptr<WaitTreeItem>> GetChildren() const override; - -private: - const std::vector<Kernel::KSynchronizationObject*>& object_list; - bool wait_all; - - Core::System& system; -}; - class WaitTreeThread : public WaitTreeSynchronizationObject { Q_OBJECT public: diff --git a/src/yuzu/loading_screen.cpp b/src/yuzu/loading_screen.cpp index e263a07a7..b081fff6b 100644 --- a/src/yuzu/loading_screen.cpp +++ b/src/yuzu/loading_screen.cpp @@ -153,7 +153,7 @@ void LoadingScreen::OnLoadProgress(VideoCore::LoadCallbackStage stage, std::size } QString estimate; - // If theres a drastic slowdown in the rate, then display an estimate + // If there's a drastic slowdown in the rate, then display an estimate if (now - previous_time > milliseconds{50} || slow_shader_compile_start) { if (!slow_shader_compile_start) { slow_shader_start = steady_clock::now(); diff --git a/src/yuzu/main.cpp b/src/yuzu/main.cpp index f233b065e..ae14884b5 100644 --- a/src/yuzu/main.cpp +++ b/src/yuzu/main.cpp @@ -91,6 +91,9 @@ static FileSys::VirtualFile VfsDirectoryCreateFileWrapper(const FileSys::Virtual #include "common/microprofile.h" #include "common/scm_rev.h" #include "common/scope_exit.h" +#ifdef _WIN32 +#include "common/windows/timer_resolution.h" +#endif #ifdef ARCHITECTURE_x86_64 #include "common/x64/cpu_detect.h" #endif @@ -271,7 +274,7 @@ static QString PrettyProductName() { #ifdef _WIN32 static void OverrideWindowsFont() { - // Qt5 chooses these fonts on Windows and they have fairly ugly alphanumeric/cyrllic characters + // Qt5 chooses these fonts on Windows and they have fairly ugly alphanumeric/cyrillic characters // Asking to use "MS Shell Dlg 2" gives better other chars while leaving the Chinese Characters. const QString startup_font = QApplication::font().family(); const QStringList ugly_fonts = {QStringLiteral("SimSun"), QStringLiteral("PMingLiU")}; @@ -377,6 +380,12 @@ GMainWindow::GMainWindow(std::unique_ptr<Config> config_, bool has_broken_vulkan LOG_INFO(Frontend, "Host RAM: {:.2f} GiB", Common::GetMemInfo().TotalPhysicalMemory / f64{1_GiB}); LOG_INFO(Frontend, "Host Swap: {:.2f} GiB", Common::GetMemInfo().TotalSwapMemory / f64{1_GiB}); +#ifdef _WIN32 + LOG_INFO(Frontend, "Host Timer Resolution: {:.4f} ms", + std::chrono::duration_cast<std::chrono::duration<f64, std::milli>>( + Common::Windows::SetCurrentTimerResolutionToMaximum()) + .count()); +#endif UpdateWindowTitle(); show(); @@ -3587,7 +3596,7 @@ bool GMainWindow::CreateShortcut(const std::string& shortcut_path, const std::st const std::string& command, const std::string& arguments, const std::string& categories, const std::string& keywords) { #if defined(__linux__) || defined(__FreeBSD__) - // This desktop file template was writting referencing + // This desktop file template was writing referencing // https://specifications.freedesktop.org/desktop-entry-spec/desktop-entry-spec-1.0.html std::string shortcut_contents{}; shortcut_contents.append("[Desktop Entry]\n"); diff --git a/src/yuzu/multiplayer/lobby.cpp b/src/yuzu/multiplayer/lobby.cpp index 6c93e3511..387f6f7c9 100644 --- a/src/yuzu/multiplayer/lobby.cpp +++ b/src/yuzu/multiplayer/lobby.cpp @@ -278,7 +278,7 @@ void Lobby::OnRefreshLobby() { } } - // Reenable the refresh button and resize the columns + // Re-enable the refresh button and resize the columns ui->refresh_list->setEnabled(true); ui->refresh_list->setText(tr("Refresh List")); ui->room_list->header()->stretchLastSection(); diff --git a/src/yuzu/multiplayer/state.cpp b/src/yuzu/multiplayer/state.cpp index 285bb150d..d82ca9aee 100644 --- a/src/yuzu/multiplayer/state.cpp +++ b/src/yuzu/multiplayer/state.cpp @@ -112,7 +112,7 @@ void MultiplayerState::SetNotificationStatus(NotificationStatus status) { void MultiplayerState::UpdateNotificationStatus() { switch (notification_status) { - case NotificationStatus::Unitialized: + case NotificationStatus::Uninitialized: status_icon->setPixmap(QIcon::fromTheme(QStringLiteral("disconnected")).pixmap(16)); status_text->setText(tr("Not Connected. Click here to find a room!")); leave_room->setEnabled(false); diff --git a/src/yuzu/multiplayer/state.h b/src/yuzu/multiplayer/state.h index 5d681c5c6..d6149838f 100644 --- a/src/yuzu/multiplayer/state.h +++ b/src/yuzu/multiplayer/state.h @@ -23,7 +23,7 @@ class MultiplayerState : public QWidget { public: enum class NotificationStatus { - Unitialized, + Uninitialized, Disconnected, Connected, Notification, @@ -98,7 +98,7 @@ private: QAction* show_room; std::shared_ptr<Core::AnnounceMultiplayerSession> announce_multiplayer_session; Network::RoomMember::State current_state = Network::RoomMember::State::Uninitialized; - NotificationStatus notification_status = NotificationStatus::Unitialized; + NotificationStatus notification_status = NotificationStatus::Uninitialized; bool has_mod_perms = false; Network::RoomMember::CallbackHandle<Network::RoomMember::State> state_callback_handle; Network::RoomMember::CallbackHandle<Network::RoomMember::Error> error_callback_handle; diff --git a/src/yuzu/startup_checks.cpp b/src/yuzu/startup_checks.cpp index 9f702fe95..5e1f76339 100644 --- a/src/yuzu/startup_checks.cpp +++ b/src/yuzu/startup_checks.cpp @@ -86,7 +86,7 @@ bool StartupChecks(const char* arg0, bool* has_broken_vulkan, bool perform_vulka return false; } - // Wait until the processs exits and get exit code from it + // Wait until the process exits and get exit code from it WaitForSingleObject(process_info.hProcess, INFINITE); DWORD exit_code = STILL_ACTIVE; const int err = GetExitCodeProcess(process_info.hProcess, &exit_code); diff --git a/src/yuzu/util/overlay_dialog.h b/src/yuzu/util/overlay_dialog.h index 872283d61..62f9da311 100644 --- a/src/yuzu/util/overlay_dialog.h +++ b/src/yuzu/util/overlay_dialog.h @@ -71,7 +71,7 @@ private: const QString& left_button_text, const QString& right_button_text, Qt::Alignment alignment); - /// Moves and resizes the dialog to be fully overlayed on top of the parent window. + /// Moves and resizes the dialog to be fully overlaid on top of the parent window. void MoveAndResizeWindow(); /** diff --git a/src/yuzu_cmd/yuzu.cpp b/src/yuzu_cmd/yuzu.cpp index 77edd58ca..5f39ece32 100644 --- a/src/yuzu_cmd/yuzu.cpp +++ b/src/yuzu_cmd/yuzu.cpp @@ -42,6 +42,8 @@ #include <windows.h> #include <shellapi.h> + +#include "common/windows/timer_resolution.h" #endif #undef _UNICODE @@ -314,6 +316,8 @@ int main(int argc, char** argv) { #ifdef _WIN32 LocalFree(argv_w); + + Common::Windows::SetCurrentTimerResolutionToMaximum(); #endif MicroProfileOnThreadCreate("EmuThread"); |