Commit Graph

10542 Commits

Author SHA1 Message Date
Zephyron
49b17b42d0 service: mm: Implement proper parameter handling for MM service
Add proper type definitions and parameter handling for the Memory Management
(mm:u) service based on the Switch documentation:

- Add Module enum for hardware components (CPU, GPU, EMC, etc)
- Add Priority and Setting type definitions as u32
- Add EventClearMode enum for initialization
- Implement proper parameter handling for all IPC calls
- Add detailed logging with parameter values

The Module enum now properly reflects the documented hardware components:
CPU, GPU, EMC, System Bus, Memory Select, and NVIDIA modules (NVDEC,
NVENC, NVJPG).

This makes the implementation match the documented nn::mmnv::IRequest
interface.

Refs: switchbrew.org/wiki/Display_services#mm:u
2025-05-11 12:38:23 +01:00
Zephyron
1a160d651d service/nvdrv: Relax GPU validation and improve error handling
Relaxes validation checks in the NVDRV GPU service and improves error notifier
handling to prevent potential hangs. Key changes:

- Remove strict size validation in SetErrorNotifier
- Relax GPFIFO entry count validation to only check for non-zero values
- Add proper error notifier state tracking in GPU class
- Improve debug logging messages

The previous strict validation was causing issues with some games like ACNH.
These changes maintain necessary checks while being more permissive with
edge cases that don't impact functionality.

Technical changes:
- Store error notifier state in GPU class for future implementation
- Remove upper bound check on GPFIFO entries
- Simplify error notifier setup flow

This should resolve hanging issues while maintaining core functionality.
2025-05-11 12:18:43 +01:00
Zephyron
5117f6496a service/nvdrv: Implement stubbed GPU functions
Implements several previously stubbed functions in the NVDRV service:
- Initialize proper transfer memory handling
- Add error notifier configuration
- Implement channel timeout and timeslice management
- Add object context allocation and tracking
- Add GPU interface stubs for new functionality

The changes improve the accuracy of GPU-related operations while maintaining
compatibility with the existing codebase. All functions now properly validate
parameters and handle endianness correctly using _le types.
2025-05-11 12:18:33 +01:00
Zephyron
7f1e5090e9 service-am: Handle panic conditions in SetTerminateResult
- Prevents propagation of panic conditions when setting termination results
- Previously, panic error codes could trigger cascading crashes
- Only stores non-error termination results while allowing successful completion
- Fixes crash when applications set panic-related termination codes (0x1A80A)
2025-05-11 12:17:03 +01:00
Zephyron
bc82a4f41b service: vi: Remove stubbed warning from GetManagerDisplayService
- The GetManagerDisplayService function in IApplicationDisplayService is fully implemented, so remove the stubbed warning and change the log level to DEBUG to match its implementation status.
2025-05-11 12:17:03 +01:00
Zephyron
9ef8867bd4 arm/video: Fix shader extension and exception handling
Two main changes in this commit:

1. Replace NVIDIA-specific GL_NV_gpu_shader5 extension with the more widely
   supported GL_EXT_shader_explicit_arithmetic_types_float16 in the scaleforce
   shader. This improves compatibility across different GPU vendors.

2. Refactor ARM32 exception handling:
   - Restructure exception cases for better readability
   - Update exception handling to match current Dynarmic API
   - Fix indentation in switch statement
   - Remove AccessViolation case as it's no longer supported in current API

These changes improve shader compatibility and align the exception handling
with the current Dynarmic implementation.
2025-05-11 12:17:03 +01:00
Zephyron
221efc2294 memory: Improve null pointer and unmapped memory handling
- Update vcpkg baseline to a42af01b72c28a8e1d7b48107b33e4f286a55ef6
- Add SPIRV-Tools and SPIRV-Headers as submodules
- Update Vulkan-related submodules to latest stable versions
- Improve memory access error handling:
  - Add specific handling for null pointer accesses in ARM32 emulation
  - Return 0 for null pointer reads instead of undefined behavior
  - Silently ignore writes to null pointers
  - Add more detailed error messages distinguishing between null pointer
    access and other unmapped memory errors
  - Treat addresses below 0x1000 as potential null pointer accesses

These changes should provide more graceful handling of null pointer
accesses and improve stability when running games that attempt invalid
memory operations.
2025-05-11 12:17:03 +01:00
Zephyron
75c7b8a672 fix(sm_controller): Correct QueryPointerBufferSize implementation
- Updated the QueryPointerBufferSize function to return the correct u16 pointer buffer size.
- Ensured the function logs its call at the debug level.
- Used IPC::ResponseBuilder to construct the response with the correct buffer size.

This change addresses the stubbed implementation and ensures compliance with the HIPC protocol.
2025-05-11 12:17:03 +01:00
Zephyron
b3ff92116e fix: Implement SetGestureOutputRanges to handle unimplemented function error
- Added the SetGestureOutputRanges function to the IHidServer class to address the unimplemented function '92' error.
- This fix was discovered through log analysis, which showed a critical assertion failure in the HID service for an unknown function '92'.
- The log indicated a userspace panic and backtrace, pointing to the need for implementing this function to prevent execution breaks.
- Updated CMakeLists.txt to remove specific version requirements for several packages, enhancing flexibility.
- Updated subproject commit references for VulkanMemoryAllocator and vcpkg.

- REF: https://switchbrew.org/wiki/HID_services#ActivateGesture
2025-05-11 12:17:03 +01:00
Zephyron
455992c2a7 kernel: Implement SystemResourceSize info type for VAMM initialization
Adds support for InfoType::SystemResourceSize (0x1C) which is required for
proper initialization of the Virtual Address Memory Manager (VAMM). This
implementation:

1. Adds SystemResourceSize to the InfoType enum in svc_types.h
2. Implements the GetInfo handler for SystemResourceSize in svc_info.cpp
3. Returns 512MB (0x20000000 bytes) as the system resource size
4. Adds debug logging for the SVC call

The 512MB value is chosen based on typical system resource allocations
needed for VAMM initialization on the Nintendo Switch.

This fixes crashes in games that rely on VAMM functionality, particularly
during nn::os::detail::VammManager::InitializeIfEnabled().
2025-05-11 12:17:03 +01:00
Zephyron
4f61ee284f core: Improve device memory and buffer queue handling
This commit makes several improvements to device memory management and buffer
queue handling:

DeviceMemoryManager:
- Add null pointer and size checks for ReadBlock
- Fill unmapped memory with a known pattern (0xCC) instead of zeros
- Add better error logging for invalid memory accesses
- Add null pointer check for source pointer in memcpy

BufferQueueProducer:
- Improve error handling in WaitForFreeSlotThenRelock
- Add proper abandoned state checking during wait conditions
- Clean up and simplify buffer scanning logic
- Improve logging messages with more descriptive information
- Remove redundant buffer count validation
- Fix potential infinite loop condition during wait

These changes improve stability and error handling while making the code more
maintainable and debuggable. The use of a known pattern for unmapped memory
helps identify uninitialized memory access issues.
2025-05-11 12:17:03 +01:00
Zephyron
2e739c8692 service/am: Implement friend invitation storage channel
Implements TryPopFromFriendInvitationStorageChannel to properly handle
friend invitation data storage and retrieval. This includes:

- Add ResultNoData error code to am_results.h
- Add friend_invitation_storage_channel storage queue to Applet struct
- Implement proper data handling in TryPopFromFriendInvitationStorageChannel

The implementation now properly manages a queue of friend invitation data
and returns appropriate results based on data availability.
2025-05-11 12:17:03 +01:00
Zephyron
f1afe954ec nvdrv: Fix incorrect IoctlZbcSetTable structure size assertion
Resolves a build failure caused by a mismatch between the defined and expected size of the `IoctlZbcSetTable` structure in `nvhost_ctrl_gpu`. The `static_assert` incorrectly expected the size to be 44 bytes, while the actual size was 48 bytes.

Changes include:
- Updated `static_assert` to correctly reflect the 48-byte size of `IoctlZbcSetTable`.
- Verified packing and alignment to ensure compliance with hardware specifications.
- Reviewed and confirmed correctness of `u32` type definitions.

This fix addresses a regression introduced in commit 9be4bf9aa5, which implemented ZBCSetTable functionality, and ensures successful compilation and adherence to the ZBC table implementation's design.
2025-05-11 12:17:03 +01:00
Zephyron
de5f95c477 nvdrv: Implement ZBCSetTable functionality
Implements basic Zero Bandwidth Clear (ZBC) table support in nvhost_ctrl_gpu.
This adds storage and validation for both color and depth clear values,
replacing the previous stub implementation. ZBC is a hardware optimization
technique used by NVIDIA GPUs to efficiently handle buffer clearing operations.

Changes include:
- Added ZBC table storage structures
- Implemented parameter validation
- Added separate handling for color and depth modes
- Improved debug logging
- Added documentation explaining ZBC functionality
2025-05-11 12:17:03 +01:00
Zephyron
57fee6e570 core: Add support for 10GB and 12GB memory configurations
- Add Memory_10Gb and Memory_12Gb to MemoryLayout enum
- Update memory layout settings to support up to 12GB
- Add SMC enums for 10GB and 12GB memory sizes and arrangements
- Increase MainMemorySizeMax from 8GB to 12GB
- Add memory pool size calculations for 10GB and 12GB configurations
- Update UI translations for new memory options
2025-05-11 12:17:03 +01:00
Zephyron
001e337260 arm: Skip duplicate consecutive addresses in backtrace output
Adds logic to track and skip duplicate consecutive addresses when logging
backtraces. This improves log readability by removing redundant entries
that point to the same address in sequence.
2025-05-11 12:17:03 +01:00
yuzubot
f4b721ac06 "Merge Tagged PR 13018" 2025-05-11 12:17:03 +01:00
Mike Lothian
e2da935917 Boost: Fix building against Boost 1.88.0 2025-05-11 12:16:29 +01:00
Zuckerwatte1
30cf1e08c5 Add 12gb DRAM option (#90)
This adds the option to allow the emulator to use 12gb of RAM for something like really big texture packs.

Co-authored-by: smiRaphi <neogt404@gmail.com>
Reviewed-on: http://vub63vv26q6v27xzv2dtcd25xumubshogm67yrpaz2rculqxs7jlfqad.onion/torzu-emu/torzu/pulls/90
Co-authored-by: Zuckerwatte1 <zuckerwatte1@noreply.localhost>
Co-committed-by: Zuckerwatte1 <zuckerwatte1@noreply.localhost>
2024-12-20 15:24:58 +00:00
EmulationEnjoyer
65202006a2 arm: Skip duplicate consecutive addresses in backtrace output
ref: aa56430f2a
2024-12-20 15:24:58 +00:00
EmulationEnjoyer
a8405749cb chore(HLE): Update HLE API version constants
- Updated Horizon OS version to 19.0.1 and NintendoSDK version to 1.0. Adjusted `VERSION_HASH`, `DISPLAY_VERSION`, and `DISPLAY_TITLE` to match the new firmware versions.

ref: fcb6444037
2024-12-20 15:24:58 +00:00
EmulationEnjoyer
8f4e5de1a4 core: Add new error modules to ErrorModule enum
- Add support for homebrew error modules to improve error handling
2024-12-20 15:24:58 +00:00
EmulationEnjoyer
f0d0c16733 feat: update HLE API version constants to Horizon OS 19.0.0
- Updated Horizon OS version constants from 12.1.0 to 19.0.0.
- Changed the version hash from `76b10c2dab7d3aa73fc162f8dff1655e6a21caf4` to `52971eebbba7ab9e6e23d73753aa63e0c3794b16`.
- Updated `DISPLAY_TITLE` and `DISPLAY_VERSION` to reflect the new firmware version "NintendoSDK Firmware for NX 19.0.0-4.0".
- Incremented Atmosphere release version constants to 1.8.0.

ref: 3276bf8780
2024-12-20 15:24:58 +00:00
lui
b76a6a79bc externals: update fmt to 11.0.2 and vcpkg to 2024.09.30 (#68)
Updated to fmt 11 with the required source changes for it to work.

Also updated vcpkg for this, and as an added benefit it fixes the `Unable to find a valid Visual Studio instance` error, and the VS 2019 build tools are no longer required. Just make sure to delete the existing downloaded vcpkg tool and binaries in `externals/vcpkg` if you have compiled before, or else it will continue to use the old version and give the error.

Reviewed-on: http://vub63vv26q6v27xzv2dtcd25xumubshogm67yrpaz2rculqxs7jlfqad.onion/torzu-emu/torzu/pulls/68
Co-authored-by: lui <lui@vub63vv26q6v27xzv2dtcd25xumubshogm67yrpaz2rculqxs7jlfqad.onion>
Co-committed-by: lui <lui@vub63vv26q6v27xzv2dtcd25xumubshogm67yrpaz2rculqxs7jlfqad.onion>
2024-12-20 15:24:58 +00:00
Herman Semenov
7bebaad1bf Using reserve() for optimization inserts, marked unused pair items and minor code refactor 2024-12-20 15:24:58 +00:00
echosys
8ba1e751c4 Be more explicit on struct init (#46)
Older versions of gcc (gcc-11 which is used in the build guide) seem to struggle with these two struct initializations (if I understand this correctly it is using "designated initialization" which is new in C++20) leading to compile errors (see #42).
This replaces those two initializations with a more explicit one that also compiles on gcc-11.

Reviewed-on: http://vub63vv26q6v27xzv2dtcd25xumubshogm67yrpaz2rculqxs7jlfqad.onion/torzu-emu/torzu/pulls/46
Co-authored-by: echosys <echosys@noreply.localhost>
Co-committed-by: echosys <echosys@noreply.localhost>
2024-12-20 15:24:58 +00:00
spectranator
685f07c068 Added ILibraryAppletSelfAccessor::UnpopInData stub 2024-12-20 15:24:58 +00:00
Reg Tiangha
4c7af937f1 hardware_composer.cpp: Add missing includes 2024-12-20 15:24:57 +00:00
Jarrod Norwell
2084af908c Stubbed QueryLastPlayTime 2024-12-20 15:24:57 +00:00
Jarrod Norwell
cc3e48774c Added HDCP authentication state event and stubs 2024-12-20 15:24:57 +00:00
Jarrod Norwell
2b4befd23d Added ISslConnection::{Get,Set}NextAlpnProto stubs 2024-12-20 15:24:57 +00:00
Jarrod Norwell
2cacc52680 Added missing error codes and increased audio renderer revision (fixes Animal Well) 2024-12-20 15:24:57 +00:00
Mike Lothian
c39939fd8e Use fmt 11.0.0 2024-12-20 15:24:57 +00:00
spectranator
0b587b91c9 Simplified CoreTiming::GetClockTicks() 2024-12-20 15:24:57 +00:00
spectranator
701f391d00 Disabled problematic MSVC warning-to-errors 2024-12-20 15:24:57 +00:00
spectranator
f89d3ca9ed Added option to synchronize core tick speed to max speed percentage 2024-12-20 15:24:57 +00:00
Jarrod Norwell
ec78bac6ab Rewrote mm:u to follow switchbrew.org documentation 2024-12-20 15:24:57 +00:00
lol
b6cd4b66b2 fix qlaunch on firmware 18 2024-12-20 15:24:57 +00:00
Exverge
f0437e57fd Map methods in firmware 18.0.0 2024-12-20 15:24:57 +00:00
darktux
2c04264053 Implemented IFriendService::GetUserPresenceView stub to get QLaunch friends list running 2024-12-20 15:24:57 +00:00
darktux
c454967221 Return correct amount of values from IFriendService::GetReceivedFriendRequestCount 2024-12-20 15:24:57 +00:00
darktux
0ef53d4d96 Added v18.0.0 stubs 2024-12-20 15:24:57 +00:00
darktux
075c4782e0 Implemented a more correct version of ISfServiceMonitor::GetGroupInfo 2024-12-20 15:24:57 +00:00
darktux
628a1649e3 Actually return 0 in IFriendService::GetReceivedFriendRequestCount 2024-12-20 15:24:57 +00:00
darktux
662ce7f3a0 Fixed minor issues from previous PR related to buffers and a typo in npns 2024-12-20 15:24:57 +00:00
darktux
8b6b7ab647 Removed telemetry and anonymized SCM (git) strings 2024-12-20 15:24:57 +00:00
darktux
e6d40911b3 Always report command ID in log and implement LoadUserSetting stub 2024-12-20 15:24:57 +00:00
Lucas Clemente Vella
2b67d9f860 Solves warning about GuestMemory having internal linkage.
It is very hard to explain why this public interface class was defined
in an anonymous namespace inside a header file.
2024-12-20 15:24:57 +00:00
Belal Ashraf
6cca22e167 Fix NROs crashing and loading infinitely 2024-12-20 15:24:57 +00:00
Exverge
1a561852bb fix: resume application when library applets are closed 2024-12-20 15:24:57 +00:00