Commit Graph

10564 Commits

Author SHA1 Message Date
Zephyron 51800e249b service/ssl: Register ssl:s service to fix game hangs
Added registration for the 'ssl:s' service using the same implementation as
the regular 'ssl' service. This fixes issues with certain titles that hang indefinitely while
waiting for this service to become available.

The issue appears in logs as:
"Server is not registered! service=ssl:s"
"Waiting for service ssl:s to become available"

This is a simple fix that reuses the existing SSL implementation instead of
creating a separate one, as both services share the same functionality.

This commit enhances the Multiplayer Function

Signed-off-by: Zephyron <zephyron@citron-emu.org>
2025-03-16 19:33:00 +10:00
Zephyron 12c63997d2 core(base_clock_rate): Revert Back To 1,020 MHz
- This Commit Accidentally Slipped By In A Previous Commit (dad8859679)
- This Has Caused Many Errors & Networking Issues Particularly On Android
- Now Uses Safe, Default 1.02 GHz

Signed-off-by: Zephyron <zephyron@citron-emu.org>
2025-03-13 16:10:04 +10:00
Zephyron 1023125be5 android: Add mandatory firmware and title.keys setup steps
- Downgrade Kotlin and Android plugin versions to ensure build compatibility.
- Add setup steps for title.keys installation and mandatory firmware setup.
- Persist auto-generated keys to improve emulator compatibility.
- Update key manager to write derived keys to filesystem.
- Implement UI handling for mandatory firmware installation checks.
2025-03-13 16:04:11 +10:00
Zephyron dad8859679 android: Update build system and optimize ARM NCE implementation
- Update Kotlin from 1.9.20 to 2.1.20-RC2
- Upgrade Java version from 17 to 21
- Update Android Gradle plugin from 8.1.2 to 8.9.0
- Update Gradle wrapper from 8.10.2 to 8.11.1
- Update NDK version to 29.0.13113456 rc1
- Update all Android dependencies to latest versions
- Simplify ARM NCE implementation by removing custom TLB handling
- Improve alignment and access fault handling
- Update hardware BASE_CLOCK_RATE from 1.02GHz to 1.785GHz
- Add citron Emulator Project copyright notices

Signed-off-by: Zephyron <zephyron@citron-emu.org>
2025-03-11 20:48:51 +10:00
Zephyron b24dd921aa revert 31694994f2
revert arm_nce: Hash TLB to MLP L2 Update
2025-03-06 06:44:06 +00:00
Zephyron 9a65205dba revert ee3d858935
revert Follow Up Of the previous commit with the update of TLB update
2025-03-06 06:43:37 +00:00
Zephyron af4f08be33 revert 6565055865
revert Fix: Core_Memory logging and ARM_NCE Mutex logging
2025-03-06 06:42:48 +00:00
Zephyron 4491127f52 revert 031c635095
revert arm: corrected declarations
2025-03-06 06:41:01 +00:00
CamilleLaVey 031c635095 arm: corrected declarations 2025-03-05 11:12:44 -04:00
CamilleLaVey 6565055865 Fix: Core_Memory logging and ARM_NCE Mutex logging 2025-03-05 00:25:31 -04:00
CamilleLaVey ee3d858935 Follow Up Of the previous commit with the update of TLB update 2025-03-04 22:50:01 -04:00
CamilleLaVey 31694994f2 arm_nce: Hash TLB to MLP L2 Update 2025-03-04 22:28:03 -04:00
CamilleLaVey 4197fa84a0 revert e4342324fe
revert Changes of the previous commits
2025-03-04 02:33:14 +00:00
CamilleLaVey e4342324fe Changes of the previous commits 2025-03-03 21:49:07 -04:00
Zephyron cfe437aacf arm: Improve TLB implementation and fault handling in NCE
This commit enhances the Translation Lookaside Buffer (TLB) implementation
in the ARM Native Code Execution (NCE) component to increase stability,
particularly on Android devices. The changes prioritize robustness and
error recovery over performance optimizations.

Key improvements:
- Replace set-associative TLB with a simpler linear search implementation
- Implement a basic LRU replacement policy for TLB entries
- Add validation checks for memory addresses before TLB insertion
- Ensure proper page alignment for guest and host addresses
- Enhance alignment fault handling with instruction skipping as fallback
- Add comprehensive debug logging for memory access errors
- Improve error recovery in guest memory access scenarios

These changes should significantly reduce crashes during emulation on
Android devices by gracefully handling memory access edge cases that
previously resulted in hard crashes.

Co-Authored-By: Camille LaVey <camillelavey@citron-emu.org>
Signed-off-by: Zephyron <zephyron@citron-emu.org>
2025-02-28 17:11:07 +10:00
Zephyron 84e5fbc089 feat: Make firmware mandatory for title launching
This commit implements a requirement for firmware to be installed before titles
can be launched, similar to how keys are required.

Changes include:
- Add IsFirmwareAvailable method to KeyManager to check for essential keys
- Add CheckFirmwarePresence method to verify actual firmware files (NCAs)
- Add firmware checks in game loading process for both desktop and Android
- Add error messages when firmware is missing
- Add strings for firmware-related error messages

The implementation checks for both essential keys and the presence of system
applets like Mii Edit and Home Menu to ensure proper firmware is installed.
Games will not launch if firmware is missing, and users will be shown an
appropriate error message.
2025-02-28 16:15:10 +10:00
Zephyron a442078ee4 feat: Remove autogenerated key functionality
This commit removes the functionality that automatically generates and writes
keys to *_autogenerated files. The key derivation logic is preserved, but
derived keys are now only stored in memory and not written to disk.

Changes include:
- Remove loading from *_autogenerated key files
- Make WriteKeyToFile a no-op function
- Remove all file writing operations in SetKey methods
- Remove file writing for keyblobs and other derived keys
- Update copyright notices

This change improves security by not storing derived keys on disk and
simplifies the key management system.
2025-02-28 15:27:12 +10:00
Zephyron 5ca1f0e365 core/arm/nce: Implement TLB caching system
Adds a software TLB cache to improve memory access performance in the NCE
(Native Code Execution) system. Key changes include:

- Implement set-associative TLB with 64 sets and 8 ways
- Add TLB lookup before memory access in HandleGuestAccessFault
- Implement LRU replacement policy with access frequency consideration
- Add thread context caching to reduce overhead
- Add proper synchronization with mutex locks
- Add helper functions for TLB management (lookup, insert, invalidate)

This change should improve performance by reducing redundant memory
translations and providing faster access to frequently used pages.
2025-02-25 18:37:14 +10:00
Zephyron 0576d40bf0 Remove redundant TranslateIPv4 function
Remove the TranslateIPv4 function that converts in_addr to IPv4Address, as it
appears to be unused or redundant. The functionality might be handled elsewhere
in the codebase or no longer needed.
2025-02-19 19:53:35 +10:00
Zephyron 43495b6045 network: Improve network interface handling and address resolution
- Return loopback address (127.0.0.1) when no network interface is selected
- Improve IPv4 address string conversion and handling
- Add explicit handling for "None" network interface selection
- Change IsAnyInternetRequestAccepted logging from ERROR to DEBUG
- Simplify internet request acceptance check to assume availability

This change makes the network interface handling more robust by providing
fallback behaviors and improving address resolution. It also reduces
unnecessary error logging for expected scenarios.
2025-02-17 21:59:15 +10:00
Zephyron c5e480e55d feat: Add Home Menu launch support and system improvements
This commit adds support for launching the system Home Menu and implements
several system-level improvements:

- Add Home Menu launch functionality through new UI action
- Implement shutdown/reboot sequence handlers in GlobalStateController
- Add support for reserved region extra size in page tables
- Enhance audio controller with output management
- Expand parental control service capabilities
- Add profile service improvements for user management

Technical changes:
- Add OnHomeMenu() handler to launch QLaunch system applet
- Implement m_alias_region_extra_size tracking in page tables
- Add new CreateProcessFlag for reserved region extra size
- Expand audio controller interface with output management
- Add self-controller methods to various services
- Implement play timer and profile service improvements

The changes primarily focus on system menu integration and core service
improvements to better support system functionality.
2025-02-17 17:33:10 +10:00
Zephyron 7730d14b4a build: upgrade fmt and SDL2
Update fmt library to version 11.0.2 and make necessary adjustments:
- Replace fmt/format.h includes with fmt/ranges.h
- Add const qualifiers to formatter::format functions
- Update CMake to require fmt version 11

Additional dependency updates:
- Update SDL2 bundled version from 2.28.2 to 2.32.0
- Update catch2 to version 3.8.0
- Update vcpkg baseline to c82f74667287d3dc386bce81e44964370c91a289
2025-02-16 13:38:05 +10:00
Zephyron 677b8f476a service/am: Implement SetRequestExitToLibraryAppletAtExecuteNextProgramEnabled
- Removes STUBBED designation as implementation is now complete
- Changes log level from WARNING to DEBUG
- Properly sets the exit request flag under lock protection
2025-02-16 12:02:52 +10:00
Zephyron 5cbde61d3c service/am: Implement CreateManagedDisplaySeparableLayer
- Removes STUBBED designation as implementation is now complete
- Changes log level from WARNING to DEBUG
- Adds proper locking when accessing the display layer manager
- Fixes parameter alignment in function declaration
2025-02-16 12:01:27 +10:00
Zephyron 33a1996ca4 service/nvnflinger: Unstub GetNativeHandle
Removes the STUBBED designation from GetNativeHandle in IHOSBinderDriver
as the implementation is now complete. Changes the log level from WARNING
to DEBUG to reflect this status.

The function properly handles binder ID validation and returns the
appropriate handle as documented in switchbrew.
2025-02-16 11:59:08 +10:00
Zephyron a7af4d001b service/vi: Improve OpenDisplay validation
Updates the OpenDisplay function in IApplicationDisplayService to properly
validate display names. Instead of only accepting "Default", now validates
against all known valid display names: "Default", "External", "Edid",
"Internal", and "Null".

- Changes log level from WARNING to DEBUG since this is no longer stubbed
- Adds proper validation for all valid display names
- Returns ResultOperationFailed for invalid display names
- Improves logging by including the requested display name
2025-02-16 11:57:23 +10:00
Zephyron ef884ce39c service/aoc: Implement CheckAddOnContentMountStatus
Implements the CheckAddOnContentMountStatus command for the aoc:u service.
This function checks whether add-on content (DLC) is currently mounted.

Currently returns false as we don't yet track mounted content state.
Changed log level from WARNING to DEBUG since this is no longer stubbed.
2025-02-16 11:55:13 +10:00
Zephyron dcf6f9a071
Revert "Replace yuzu identifiers with citron"
This reverts commit d4ad55ed21.
2025-02-09 18:19:08 +10:00
Zephyron b42a0fb227
network: Fix 0.0 FPS bug on Android (Part 2)
- Add network interface enumeration support for Android
- Implement fallback loopback interface when no interfaces are detected
- Add ability to force offline mode on critical network errors
- Improve socket initialization with better error handling
- Add socket state tracking (domain, type, protocol)
- Make translation functions static and mark as maybe_unused
- Add detailed logging for network initialization failures

Part 2 of the Android FPS bug fix focuses on network resilience,
particularly handling cases where network initialization fails.
Instead of hanging the emulator, it now gracefully falls back to
offline mode and provides better diagnostic information.
2025-02-09 15:44:43 +10:00
Zephyron d4ad55ed21
Replace yuzu identifiers with citron
Update magic numbers and default identifiers across codebase:
- UUID default value
- Thread magic number
- Amiibo name
- Vulkan cache magic number
- Shader cache magic number
2025-02-09 12:07:50 +10:00
Zephyron 6e16a8db1c
service/nvdrv: Implement NVGPU_GPU_IOCTL_NUM_VSMS
- Add IoctlNumVsms struct definition
- Implement ioctl 0x13 to return number of SM units (2 for Tegra X1)
2025-02-09 11:43:08 +10:00
Zephyron 384a18927b
service/friend: Clean up friend service implementation
- Remove unused function stubs
- Improve GetCompletionEvent implementation
- Clean up response builder naming
2025-02-09 11:40:46 +10:00
Zephyron 76716b5248
service/audio: Clean up audio controller implementation
- Remove Unknown5000 function and related debug commands
- Fix incorrect service name in log message
2025-02-09 11:39:16 +10:00
Zephyron 6917a22a2c
service/acc: Clean up account service implementation
- Remove unused function stubs
- Add version information comments
- Add clang-format markers
- Remove duplicate TrySelectUserWithoutInteraction function
- Fix formatting and code style
2025-02-09 11:36:58 +10:00
Zephyron d783806b1e
service/friend: implement additional friend service functions
- Add implementations for previously stubbed functions:
  * Cancel - Handle operation cancellation
  * RequestSyncFriendList - Friend list synchronization
  * GetUserPresenceView - User presence information
  * LoadUserSetting - User settings loading
- Improve GetCompletionEvent implementation:
  * Add proper event signaling
  * Use clearer variable names
  * Improve debug logging
- Enhance logging messages:
  * Add more descriptive debug messages
  * Include user ID in presence view logging
  * Use consistent naming in response builders
- Fix response builder formatting for consistency

These changes improve the friend service implementation by adding
support for more friend-related functionality while enhancing
the debugging experience through better logging and code
organization.
2025-02-08 20:39:47 +10:00
Zephyron 268d322d7f
service/audio: implement Unknown5000 and add debug commands
- Add Unknown5000 implementation to create duplicate controller interface
- Add new debug-related command handlers:
  * OverrideDefaultTargetForDebug (50001)
  * SetForceOverrideExternalDeviceNameForDebug (50003)
  * ClearForceOverrideExternalDeviceNameForDebug (50004)
- Add proper debug logging for interface creation
- Update header with new function declaration
- Fix missing commas in function registration array

These changes improve the audio controller implementation by
adding support for interface duplication and debug override
functionality. The implementation maintains proper interface
lifetime management using SharedFrom.
2025-02-08 20:35:38 +10:00
Zephyron 92b70b31e0
service/nim: implement CreateServerInterface2 and improve logging
- Add CreateServerInterface2 implementation for NIM_ECA service
- Change log level from WARNING to DEBUG for CreateServerInterface
- Add descriptive log message for server interface creation
- Maintain consistent interface creation pattern between both versions
- Fix missing comma in function registration array

These changes improve the NIM service implementation by adding
support for the newer server interface creation method while
making logging more appropriate for stubbed functions.
2025-02-08 20:28:25 +10:00
Zephyron 4792ba752e
service/mm: add missing vector include and update copyright
- Add missing <vector> include for std::vector usage
- Add Citron copyright notice
- Maintain existing include ordering

This is a minor cleanup change to ensure proper header inclusion
and copyright attribution.
2025-02-08 20:24:09 +10:00
Zephyron b8fe6b6f7c
service/acc: implement Nintendo Account integration and cleanup
- Add Nintendo Account related implementations:
  * GetNintendoAccountId
  * GetNintendoAccountUserResourceCache
  * IsLinkedWithNintendoAccount
  * StoreSaveDataThumbnailApplication
- Improve version handling:
  * Add proper firmware version comments
  * Implement deprecated and new TrySelectUserWithoutInteraction
  * Update service interface versioning
- Clean up code organization:
  * Remove redundant clang-format markers
  * Fix constructor formatting
  * Improve error handling in InitializeApplicationInfoBase
  * Add proper debug logging
  * Update copyright headers
- Add proper documentation for buffer types and sizes

These changes improve Nintendo Account integration support while
cleaning up the codebase and improving version compatibility
handling. The implementation provides stubs for network-related
functionality to allow applications to proceed while proper
integration is developed.
2025-02-08 20:21:47 +10:00
Zephyron 0acfbc5fa1
service/nifm: implement additional network interface functions
- Add implementations for previously stubbed functions:
  * EnumerateNetworkInterfaces
  * EnumerateNetworkProfiles
  * ConfirmSystemAvailability
  * SetBackgroundRequestEnabled
- Add proper debug logging for new implementations
- Update header with new function declarations
- Add Citron copyright notice
- Improve response builder naming for clarity

These implementations return success status with empty results
to allow applications to proceed while proper network interface
management is developed. Debug logging has been added to track
usage of these functions.
2025-02-08 19:58:19 +10:00
Zephyron e3128c6e98
service/sm: improve service manager implementation
- Reorder error codes to match numerical order
- Rename RegisterClient to Initialize in service registration
  to match actual function name
- Update function declaration order in header to match implementation
- Improve QueryPointerBufferSize implementation:
  * Add proper documentation comment
  * Use constexpr for maximum transfer memory size
  * Use std::numeric_limits where appropriate
  * Improve debug logging message
  * Use meaningful constant name

These changes improve code organization and clarity while making
the service manager interface more consistent with Nintendo's
official naming conventions.
2025-02-08 19:50:28 +10:00
Zephyron b89a85e228
service/set: improve settings handling and update serial number
- Update default console serial number prefix from "YUZ" to "CIT"
- Improve GetSettingsItemValueImpl template implementation:
  * Add proper buffer management using std::vector
  * Fix potential buffer overflow issues
  * Use clearer variable naming
  * Add proper size handling with actual_size
  * Use memcpy for safer data copying

These changes improve the safety of settings handling while
updating the emulator's identity to use the Citron prefix
instead of yuzu's.
2025-02-08 19:45:27 +10:00
Zephyron cc48197448
service/hid: reorganize gesture-related functions
- Move SetGestureOutputRanges function registration to be with other
  gesture-related functions (next to ActivateGesture)
- Move SetGestureOutputRanges implementation to be with other
  gesture-related implementations
- Change log level from WARNING to DEBUG for SetGestureOutputRanges
- Move function declaration to private section with other IPC handlers
- Update function ordering to match service registration order

These changes improve code organization by grouping related
functionality together and maintain consistency between the
interface registration and implementation ordering.
2025-02-08 19:39:53 +10:00
Zephyron 0010882f36
service: fix typo in NPNS GetStateChangeEvent function name
Fix spelling of "GetStateChangeEvent" function name in both INpnsSystem
and INpnsUser interfaces. The function was incorrectly spelled as
"GetStateChangeEVent" with a capital 'V'.
2025-02-08 19:35:59 +10:00
Zephyron c31768ec15
core: improve nvdrv and buffer queue implementations
Buffer Queue Changes:
- Add assertion for buffer state in free slots
- Improve error handling for buffer dequeuing
- Add buffer count validation checks
- Update log levels for better diagnostics

NVDRV Changes:
- Add host1x reference to nvhost_nvdec_common
- Improve ioctl error reporting with more detailed messages
- Reorder function declarations in nvhost_ctrl_gpu
- Add stub for unimplemented ioctl command 0x13
- Clean up initialization of boolean flags

These changes improve error handling and debugging capabilities
while adding additional safety checks for buffer management.
The nvdrv interface is also made more robust with better error
reporting and proper hardware access patterns.
2025-02-08 19:29:49 +10:00
Zephyron 227db142e2
sockets: reorder errno values numerically
Reorder the Errno enum values to be in ascending numerical order,
moving NOMEM (12) to be between AGAIN (11) and INVAL (22). This
improves readability and makes it easier to verify completeness
of the error code list.
2025-02-08 19:21:47 +10:00
Zephyron 89ecb641f1
api_version: Update Atmosphere version and add citron copyright
Update the Atmosphere release version minor number from 0 to 8 to match
newer firmware versions. Also add copyright notice for citron Emulator
Project.

This change maintains compatibility with newer system versions while
preserving the existing version number format.
2025-02-04 16:26:57 +10:00
Zephyron 14065ae7cb
kernel/svc: Refactor UnmapProcessCodeMemory validation
Improve the validation logic in UnmapProcessCodeMemory by:

- Add missing size validation check at the start
- Reorganize validation checks into logical groups
- Simplify error handling using R_UNLESS macros
- Remove redundant page table range check
- Add copyright notice for Citron Emulator Project
- Add ResultInvalidSize constant definition

The changes make the validation code more concise and easier to follow
while maintaining the same validation requirements. Error handling is now
more consistent with other SVC implementations.
2025-02-03 16:13:21 +10:00
Zephyron 71e652123b
memory: Improve debug logging and validation in InvalidateNCE
Add more detailed debug logging and validation to the InvalidateNCE function:

- Add entry debug log showing NCE invalidation request details
- Add upfront validation of memory region before proceeding
- Add debug logs for rasterizer and separate heap handling cases
- Add warning logs for invalid address ranges and failed invalidations
- Improve error message formatting and clarity
- Group related operations with descriptive comments

These changes make it easier to debug NCE invalidation issues by providing
more visibility into the validation steps and failure cases.
2025-02-03 16:10:34 +10:00
Zephyron f4b9e54b22
common/nvdrv: improve memory validation and error handling
Implements several improvements to memory handling and validation:

- host_memory: Add IsValidMapping() and IsDirectMappingEnabled() methods to
  validate memory access
- host_memory: Fix virtual base offset calculation to use proper pointer
  arithmetic
- host_memory: Add size field to track allocation size
- nvhost_ctrl_gpu: Return InvalidState instead of InvalidValue for TPC mask
  buffer size validation
- Update copyright year for citron

The changes improve memory safety by adding explicit validation checks and
fixing pointer arithmetic in the virtual memory implementation.
2025-02-01 21:50:33 +10:00