* Sockets: Properly convert error codes on MacOS
The error codes for MacOS are very different to how they are on windows or linux. An alternate mapping is used when the host operating system is MacOS.
This PR also defaults IsDhcpEnabled to true when interfaceProperties.DhcpServerAddresses is not available.
This change was already in `macos1`.
* Address feedback
* bsd::RecvFrom: Ryujinx does not verify output buffer size before writing socket address
* Calculate the size of BsdSockAddr
* use bsdSockAddr variable
* Update Ryujinx.HLE/HOS/Services/Sockets/Bsd/IClient.cs
Co-authored-by: Mary-nyan <thog@protonmail.com>
* Update Ryujinx.HLE/HOS/Services/Sockets/Bsd/Types/BsdSockAddr.cs
Co-authored-by: Mary-nyan <thog@protonmail.com>
* set errno to ENOMEM in case we can't write the address to memory
* Update Ryujinx.HLE/HOS/Services/Sockets/Bsd/IClient.cs
Co-authored-by: Ac_K <Acoustik666@gmail.com>
* Update Ryujinx.HLE/HOS/Services/Sockets/Bsd/IClient.cs
Co-authored-by: Mary-nyan <thog@protonmail.com>
Co-authored-by: Ac_K <Acoustik666@gmail.com>
* bsd: Add gdkchan's Select implementation
Co-authored-by: TSRBerry <20988865+tsrberry@users.noreply.github.com>
* bsd: Fix Select() causing a crash with an ArgumentException
.NET Sockets have to be used for the Select() call
* bsd: Make Select more generic
* bsd: Adjust namespaces and remove unused imports
* bsd: Fix NullReferenceException in Select
Co-authored-by: gdkchan <gab.dark.100@gmail.com>
* bsd: Fix eventfd broken logic
This commit fix eventfd logic being broken.
The following changes were made:
- EventFd IPC definition had argument inverted
- EventFd events weren't fired correctly
- Poll logic was wrong and unfinished for eventfd
- Reintroduce workaround from #3385 but in a safer way, and spawn 4
threads.
* ipc: Rework a bit for multithreads
* Clean up debug logs
* Make server thread yield when managed lock isn't availaible
* Fix replyTargetHandle not being added in the proper locking scope
* Simplify some scopes
* Address gdkchan's comments
* Revert IPC workaround for now
* Reintroduce the EventFileDescriptor workaround
We should report errors even when not requested.
This also ensure we only clear the bits that were requested on the output.
Finally, this fix when input events is 0.
* Bsd: Fix NullReferenceException in BsdSockAddr.FromIPEndPoint()
Allows "Victor Vran Overkill Edition" to boot with guest internet access enabled.
Thanks to EmulationFanatic for testing this for me!
* Bsd: Return proper error code if RemoteEndPoint is null
* Remove whitespace from empty line
Co-authored-by: gdkchan <gab.dark.100@gmail.com>
Co-authored-by: gdkchan <gab.dark.100@gmail.com>
This is a very old oversight on our Poll implementation.
This worked so far reliably because games and homebrews pass the same
buffer as input and output.
Some games and the Mario Odyssey Multiplayer mod do this.
The SMO multiplayer mod also needs you to revert #3394 as it uses a blocking socket to receive (otherwise it hangs), and it doesn't seem to like being forced as non-blocking.
* bsd: Revamp API and make socket abstract
This part of the code was really ancient and needed some love.
As such this commit aims at separating the socket core logic from the IClient class and make it uses more modern APIs to read/write/parse data.
* Address gdkchan's comment
* Move TryConvertSocketOption to WinSockHelper
* Allow reusing old fds and add missing locks around SocketInternal and ShutdownAllSockets
* bsd: ton of changes
- Make sockets per process
- Implement eventfds
- Rework Poll for support of eventfds
- Handle protocol auto selection by type (used by gRPC)
- Handle IPv6 socket creation
* Address most of gdkchan comments
* Fix inverted read logic for BSD socket read
* bsd: Make Poll abstract via IBsdSocketPollManager
* bsd: Improve naming of everything
* Fix build issue from last commit (missed to save on VC)
* Switch BsdContext registry to a concurrent dictionary
* bsd: Implement socket creation flags logic and the non blocking flag
* Remove unused enum from previous commit
* bsd: Fix poll logic when 0 fds are present for a given poll manager and when timeout is very small (or 0)
* 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
* 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
* 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>
* Changes to allow explicit management of service threads
* Remove now unused code
* Remove ThreadCounter, its no longer needed
* Allow and use separate server per service, also fix exit issues
* New policy change: PTC version now uses PR number
* 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
* 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
This add some code to handle usage of poll without any fds.
This is required by Dark Souls Remastered main loop logic as it's
calling it without any fds during initialization.
===
General system stability improvements to enhance the user's experience.
This PR remove the `EndianSwap` class who isn't needed anymore since .NET Core 3.0 got a buildin method `BinaryPrimitives.ReverseEndianness` who did the same thing.
* Fix hwopus DecodeInterleaved implementation
Also implement new variants of this api.
This should fix#763
* Sample rate shouldn't be hardcoded
This fix issues while opening Pokémon Let's Go pause menu.
* Apply Ac_K's suggestion about EndianSwap
* Address gdkchan's comment
* Address Ac_k's comment
* Refactoring HOS folder structure
Refactoring HOS folder structure:
- Added some subfolders when needed (Following structure decided in private).
- Added some `Types` folders when needed.
- Little cleanup here and there.
- Add services placeholders for every HOS services (close#766 and #753).
* Remove Types namespaces