* IPC refactor part 3 + 4: New server HIPC message processor with source generator based serialization
* Make types match on calls to AlignUp/AlignDown
* Formatting
* Address some PR feedback
* Move BitfieldExtensions to Ryujinx.Common.Utilities and consolidate implementations
* Rename Reader/Writer to SpanReader/SpanWriter and move to Ryujinx.Common.Memory
* Implement EventType
* Address more PR feedback
* Log request processing errors since they are not normal
* Rename waitable to multiwait and add missing lock
* PR feedback
* Ac_K PR feedback
* Replace Array.Clear(x, 0, x.Length) with Array.Clear(x)
* Use DateTime.UnixEpoch field
* Replace SHA256.ComputeHash calls with static SHA256.HashData call
More performant and avoids the need to initialize a SHA256 instance.
* common: Make BinaryReaderExtensions Read & Write take unamanged types
This allows us to not rely on Marshal.PtrToStructure and Marshal.StructureToPtr for those.
* common: Make MemoryHelper Read & Write takes unamanged types
* Update Marshal.SizeOf => Unsafe.SizeOf when appropriate and start moving software applet to unmanaged types
* Update readme to mention .NET 7
* infra: Migrate to .NET 7
.NET 7 is still in preview but this prepare for the release coming up
next month.
* Use Random.Shared in CreateRandom
* Move UInt128Utils.cs to Ryujinx.Common project
* Fix inverted parameters in System.UInt128 constructor
* Fix Visual Studio complains on Ryujinx.Graphics.Vic
* time: Fix missing alignment enforcement in SystemClockContext
Fixes at least Smash
* time: Fix missing alignment enforcement in SteadyClockContext
Fix games (like recent version of Smash) using time shared memory
* Switch to .NET 7.0.100 release
* Enable Tiered PGO
* Ensure CreateId validity requirements are meet when doing random generation
Also enforce correct packing layout for other Mii structures.
This fix a Mario Kart 8 crashes related to the default Miis.
Because of that PR, TimeZoneRule was bigger than 0x4000 thanks to a
misuse of a constant.
This commit address this issue and add a new unit test to ensure the size of
TimeZoneRule is 0x4000 bytes.
Also address suggestions that were lost on the original PR.
* time: Make TimeZoneRule blittable and avoid copies
This drastically reduce overhead of using TimeZoneRule around the
codebase.
Effect on games is unknown
* Add missing Box type
* Ensure we clean the structure still
This doesn't perform any copies
* Address gdkchan's comments
* Simplify Box
* Refactor CPU interface
* Use IExecutionContext interface on SVC handler, change how CPU interrupts invokes the handlers
* Make CpuEngine take a ITickSource rather than returning one
The previous implementation had the scenario where the CPU engine had to implement the tick source in mind, like for example, when we have a hypervisor and the game can read CNTPCT on the host directly. However given that we need to do conversion due to different frequencies anyway, it's not worth it. It's better to just let the user pass the tick source and redirect any reads to CNTPCT to the user tick source
* XML docs for the public interfaces
* PPTC invalidation due to NativeInterface function name changes
* Fix build of the CPU tests
* PR feedback
* hle: Some cleanup
This PR cleaned up a bit the HLE folder and the VirtualFileSystem one, since we use LibHac, we can use some class of it directly instead of duplicate things. The "Content" of VFS folder is removed since it should be handled in the NCM service directly.
A larger cleanup should be done later since there is still be duplicated code here and there.
* Fix Headless.SDL2
* Addresses gdkchan feedback
* ntc: Implement IEnsureNetworkClockAvailabilityService
This PR implement a basic `IEnsureNetworkClockAvailabilityService` checked by RE. It's needed by Splatoon 2 with Guest Internet Access enabled. Game is now playable with this setting.
* Update Ryujinx.HLE/HOS/Services/Nim/Ntc/StaticService/IEnsureNetworkClockAvailabilityService.cs
Co-authored-by: gdkchan <gab.dark.100@gmail.com>
Co-authored-by: gdkchan <gab.dark.100@gmail.com>
* timezone: Make timezone implementation safe
* hle: Do not use TrimEnd to parse ASCII strings
This adds an util that handle reading an ASCII string in a safe way.
Previously it was possible to read malformed data that could cause
various undefined behaviours in multiple services.
* hid: Remove an useless unsafe modifier on keyboard update
* Address gdkchan's comment
* Address gdkchan's comment
* hos: Cleanup the project
Since a lot of changes has been done on the HOS project, there are some leftover here and there, or class just used in one service, things at wrong places, and more.
This PR fixes that, additionnally to that, I've realigned some vars because I though it make the code more readable.
* Address gdkchan feedback
* addresses Thog feedback
* Revert ElfSymbol
* hle: Simplify ServiceNotImplementedException
This removes the need to pass in whether the command is a Tipc command or a Hipc command to the exception constructor.
* hle: Use the IPC Message type to determine command type
This allows differentiating between Tipc and Hipc commands when invoking a handler that supports handling both Tipc and Hipc commands.
* Refactoring of KMemoryManager class
* Replace some trivial uses of DRAM address with VA
* Get rid of GetDramAddressFromVa
* Abstracting more operations on derived page table class
* Run auto-format on KPageTableBase
* Managed to make TryConvertVaToPa private, few uses remains now
* Implement guest physical pages ref counting, remove manual freeing
* Make DoMmuOperation private and call new abstract methods only from the base class
* Pass pages count rather than size on Map/UnmapMemory
* Change memory managers to take host pointers
* Fix a guest memory leak and simplify KPageTable
* Expose new methods for host range query and mapping
* Some refactoring of MapPagesFromClientProcess to allow proper page ref counting and mapping without KPageLists
* Remove more uses of AddVaRangeToPageList, now only one remains (shared memory page checking)
* Add a SharedMemoryStorage class, will be useful for host mapping
* Sayonara AddVaRangeToPageList, you served us well
* Start to implement host memory mapping (WIP)
* Support memory tracking through host exception handling
* Fix some access violations from HLE service guest memory access and CPU
* Fix memory tracking
* Fix mapping list bugs, including a race and a error adding mapping ranges
* Simple page table for memory tracking
* Simple "volatile" region handle mode
* Update UBOs directly (experimental, rough)
* Fix the overlap check
* Only set non-modified buffers as volatile
* Fix some memory tracking issues
* Fix possible race in MapBufferFromClientProcess (block list updates were not locked)
* Write uniform update to memory immediately, only defer the buffer set.
* Fix some memory tracking issues
* Pass correct pages count on shared memory unmap
* Armeilleure Signal Handler v1 + Unix changes
Unix currently behaves like windows, rather than remapping physical
* Actually check if the host platform is unix
* Fix decommit on linux.
* Implement windows 10 placeholder shared memory, fix a buffer issue.
* Make PTC version something that will never match with master
* Remove testing variable for block count
* Add reference count for memory manager, fix dispose
Can still deadlock with OpenAL
* Add address validation, use page table for mapped check, add docs
Might clean up the page table traversing routines.
* Implement batched mapping/tracking.
* Move documentation, fix tests.
* Cleanup uniform buffer update stuff.
* Remove unnecessary assignment.
* Add unsafe host mapped memory switch
On by default. Would be good to turn this off for untrusted code (homebrew, exefs mods) and give the user the option to turn it on manually, though that requires some UI work.
* Remove C# exception handlers
They have issues due to current .NET limitations, so the meilleure one fully replaces them for now.
* Fix MapPhysicalMemory on the software MemoryManager.
* Null check for GetHostAddress, docs
* Add configuration for setting memory manager mode (not in UI yet)
* Add config to UI
* Fix type mismatch on Unix signal handler code emit
* Fix 6GB DRAM mode.
The size can be greater than `uint.MaxValue` when the DRAM is >4GB.
* Address some feedback.
* More detailed error if backing memory cannot be mapped.
* SetLastError on all OS functions for consistency
* Force pages dirty with UBO update instead of setting them directly.
Seems to be much faster across a few games. Need retesting.
* Rebase, configuration rework, fix mem tracking regression
* Fix race in FreePages
* Set memory managers null after decrementing ref count
* Remove readonly keyword, as this is now modified.
* Use a local variable for the signal handler rather than a register.
* Fix bug with buffer resize, and index/uniform buffer binding.
Should fix flickering in games.
* Add InvalidAccessHandler to MemoryTracking
Doesn't do anything yet
* Call invalid access handler on unmapped read/write.
Same rules as the regular memory manager.
* Make unsafe mapped memory its own MemoryManagerType
* Move FlushUboDirty into UpdateState.
* Buffer dirty cache, rather than ubo cache
Much cleaner, may be reusable for Inline2Memory updates.
* This doesn't return anything anymore.
* Add sigaction remove methods, correct a few function signatures.
* Return empty list of physical regions for size 0.
* Also on AddressSpaceManager
Co-authored-by: gdkchan <gab.dark.100@gmail.com>
* Make all title id instances unsigned
* Replace address and size with ulong instead of signed types
Long overdue change.
Also change some logics here and there to optimize with the new memory
manager.
* Address Ac_K's comments
* Remove uneeded cast all around
* Fixes some others misalignment
* Rename CommandAttribute as CommandHIpcAttribute to prepare for 12.x changes
* Implement inital support for TIPC and adds SM command ids
* *Ipc to *ipc
* Missed a ref in last commit...
* CommandAttributeTIpc to CommandAttributeTipc
* Addresses comment and fixes some bugs around
TIPC doesn't have any padding requirements as buffer C isn't a thing
Fix for RegisterService inverting two argument only on TIPC
I happened to notice this when checking Ryu's IPC structures. After double checking with RE it seems the current check is incorrect so use the correct member to fix that.
* IPC refactor part 2: Use ReplyAndReceive on HLE services and remove special handling from kernel
* Fix for applet transfer memory + some nits
* Keep handles if possible to avoid server handle table exhaustion
* Fix IPC ZeroFill bug
* am: Correctly implement CreateManagedDisplayLayer and implement CreateManagedDisplaySeparableLayer
CreateManagedDisplaySeparableLayer is requires since 10.x+ when appletResourceUserId != 0
* Make it exit properly
* Make ServiceNotImplementedException show the full message again
* Allow yielding execution to avoid starving other threads
* Only wait if active
* Merge IVirtualMemoryManager and IAddressSpaceManager
* Fix Ro loading data from the wrong process
Co-authored-by: Thog <me@thog.eu>
* Clean up and update readme
THis clean up and improve the README a bit.
* Apply suggestions from code review
Co-authored-by: EmulationFanatic <62343878+EmulationFanatic@users.noreply.github.com>
Co-authored-by: EmulationFanatic <62343878+EmulationFanatic@users.noreply.github.com>
* Logger class changes only
Now compile-time checking is possible with the help of Nullable Value
types.
* Misc formatting
* Manual optimizations
PrintGuestLog
PrintGuestStackTrace
Surfaceflinger DequeueBuffer
* Reduce SendVibrationXX log level to Debug
* Add Notice log level
This level is always enabled and used to print system info, etc...
Also, rewrite LogColor to switch expression as colors are static
* Unify unhandled exception event handlers
* Print enabled LogLevels during init
* Re-add App Exit disposes in proper order
nit: switch case spacing
* Revert PrintGuestStackTrace to Info logs due to #1407
PrintGuestStackTrace is now called in some critical error handlers
so revert to old behavior as KThread isn't part of Guest.
* Batch replace Logger statements
The error code was taken from Switchbrew (https://switchbrew.org/wiki/Error_codes)
Even if TimeServiceNotInitialized's "description" is 0, the result "value" of "(0 << ErrorCodeShift) | ModuleId" is 0x74 so it is not the same as "Success" (0)
* Implement a new physical memory manager and replace DeviceMemory
* Proper generic constraints
* Fix debug build
* Add memory tests
* New CPU memory manager and general code cleanup
* Remove host memory management from CPU project, use Ryujinx.Memory instead
* Fix tests
* Document exceptions on MemoryBlock
* Fix leak on unix memory allocation
* Proper disposal of some objects on tests
* Fix JitCache not being set as initialized
* GetRef without checks for 8-bits and 16-bits CAS
* Add MemoryBlock destructor
* Throw in separate method to improve codegen
* Address PR feedback
* QueryModified improvements
* Fix memory write tracking not marking all pages as modified in some cases
* Simplify MarkRegionAsModified
* Remove XML doc for ghost param
* Add back optimization to avoid useless buffer updates
* Add Ryujinx.Cpu project, move MemoryManager there and remove MemoryBlockWrapper
* Some nits
* Do not perform address translation when size is 0
* Address PR feedback and format NativeInterface class
* Remove ghost parameter description
* Update Ryujinx.Cpu to .NET Core 3.1
* Address PR feedback
* Fix build
* Return a well defined value for GetPhysicalAddress with invalid VA, and do not return unmapped ranges as modified
* Typo
* Reduce requirements for running homebrews
This commit change the following behaviours:
- TimeZoneBinary system archive isn't required until guest code call LoadTimeZoneRule.
- Fonts system archives aren't requred until a "pl:u" IPC call is made.
- Custom font support was dropped.
- TimeZoneBinary missing message is now an error and not a warning.
* Address comments
* Update to LibHac 0.6.0
* Create an IFileSystemProxy object from LibHac
* Rename rc -> result
* Alignment and spacing
* Result formatting
* Spacing
* Sort usings
* Move InvalidSystemResourceException with the other
`InvalidSystemResourceException.cs` was in `Ryujinx.HLE/Resource` who didn't make sense since it's the only file in the folder, and other exceptions class are in `Ryujinx.HLE/Exceptions`.
* Fix empty lines
* Fix TimeZoneBinary dispose issues
THis fix a regression on Pokémon Let's Go Eevee! (and
probably other games) caused by #783.
* Address Moosehunter's comment
* Fix 9.0.0 related services bindings
This was wrong because of a mistake on switchbrew.
* Fix wronog cmdid for ISteadyClock::GetTestOffset/SetTestOffset
* Update ClockCore logics to 9.0.0
Also apply 9.0.0 permissions and comment time:u, and time:a (as those
are going to be moved)
* Move every clocks instances + timezone to a global manager
* Start implementing time:m
Also prepare the skeleton of the shared memory
* Implement SystemClockContextUpdateCallback and co
* Update StaticService to 9.0.0
* Update ISystemClock to 9.0.0
* Rename IStaticService and add glue's IStaticService
* Implement psc's ITimeZoneService
* Integrate psc layer into glue for TimeZoneService
* Rename TimeZoneManagerForPsc => TimeZoneManager
* Use correct TimeZoneService interface for both StaticService implementations
* Accurately implement time shared memory operations
* Fix two critical flaws in TimeZone logic
The first one was the month range being different fron Nintendo one
(0-11 instead of 1-12)
The other flaw was a bad incrementation order during days & months
computation.
* Follow Nintendo's abort logic for TimeManager
* Avoid crashing when timezone sysarchive isn't present
* Update Readme
* Address comments
* Correctly align fields in ISystemClock
* Fix code style and some typos
* Improve timezone system archive warning/error messages
* Rearrange using definitions in Horizon.cs
* Address comments