Commit graph

414 commits

Author SHA1 Message Date
gdkchan
20774dab14
Improve kernel WaitSynchronization syscall implementation (#1362) 2020-07-17 14:22:13 +10:00
gdkchan
9f6b24edfd
Improve kernel IPC related syscalls (#1379)
* Implement session count decrement when the handle is closed

* Remove unused field

* Implement SendSyncRequestWithUserBuffer, SendAsyncRequestWithUserBuffer and ReplyAndReceiveWithUserBuffer syscalls

* Nits

* Fix swapped copy dst/src

* Add missing pointer buffer descriptor write on reply

* Fix IPC unaligned buffer copy and restoring client attributes on reply

* Oops

* Fix SetIpcMappingPermission

* Fix unaligned copy bugs

* Free memory used for temporary IPC buffers
2020-07-17 14:19:07 +10:00
gdkchan
46f8cef6a9
Fix resource limit reserve taking too long (#1391) 2020-07-17 14:18:31 +10:00
mageven
16dafe6316
mods: Fix crash when loading via LoadCart (#1388) 2020-07-15 09:40:17 +10:00
gdkchan
4d02a2d2c0
New NVDEC and VIC implementation (#1384)
* Initial NVDEC and VIC implementation

* Update FFmpeg.AutoGen to 4.3.0

* Add nvdec dependencies for Windows

* Unify some VP9 structures

* Rename VP9 structure fields

* Improvements to Video API

* XML docs for Common.Memory

* Remove now unused or redundant overloads from MemoryAccessor

* NVDEC UV surface read/write scalar paths

* Add FIXME comments about hacky things/stuff that will need to be fixed in the future

* Cleaned up VP9 memory allocation

* Remove some debug logs

* Rename some VP9 structs

* Remove unused struct

* No need to compile Ryujinx.Graphics.Host1x with unsafe anymore

* Name AsyncWorkQueue threads to make debugging easier

* Make Vp9PictureInfo a ref struct

* LayoutConverter no longer needs the depth argument (broken by rebase)

* Pooling of VP9 buffers, plus fix a memory leak on VP9

* Really wish VS could rename projects properly...

* Address feedback

* Remove using

* Catch OperationCanceledException

* Add licensing informations

* Add THIRDPARTY.md to release too

Co-authored-by: Thog <me@thog.eu>
2020-07-12 05:07:01 +02:00
mageven
189c0c9c72
Implement modding support (#1249)
* Implement Modding Support

* Executables: Rewrite to use contiguous mem and Spans

* Reorder ExeFs, Npdm, ControlData and SaveData calls

After discussion with gdkchan, it was decided it's best to call
LoadExeFs after all other loads are done as it starts the guest process.

* Build RomFs manually instead of Layering FS

Layered FS approach has considerable latency when building the final
romfs. So, we manually replace files in a single romfs instance.

* Add RomFs modding via storage file

* Fix and cleanup MemPatch

* Add dynamically loaded NRO patching

* Support exefs file replacement

* Rewrite ModLoader to use mods-search architecture

* Disable PPTC when exefs patches are detected

Disable PPTC on exefs replacements too

* Rewrite ModLoader, again

* Increased maintainability and matches Atmosphere closely
* Creates base mods structure if it doesn't exist
* Add Exefs partition replacement
* IPSwitch: Fix nsobid parsing

* Move mod logs to new LogClass

* Allow custom suffixes to title dirs again

* Address nits

* Add a per-App "Open Mods Directory" context menu item

Creates the path if not present.

* Normalize tooltips verbiage

* Use LocalStorage and remove unused namespaces
2020-07-09 14:31:15 +10:00
Mary
43b78ae157
prepo: Update implementation for 10.x changes (#1361)
* prepo: Update implementation for 10.x changes

On 10.x, Nintendo changed yet another time the prepo SaveReport &
SaveReportWithUser command ids.

This PR add support for command 10104 & 10105 and update naming of the
old variants to match switchbrew.

* Fix misalign and remove a ToString

* Address jD's comment
2020-07-05 10:58:11 +10:00
Mary
2c48750ff0
Fix compilation warnings and use new LibHac APIs for executable loading (#1350)
* Fix compilation warnings and use new LibHac APIs for executable loading

* Migrate NSO loader to the new reader and fix kip loader

* Fix CS0162 restore

* Remove extra return lines

* Address Moose's comment
2020-07-04 01:58:01 +02:00
mageven
5644780e6e
Stub nifm IRequest GetAppletInfo (#1326)
* Stub GetAppletInfo to be consistent with GetResult

* Fix formatting and enum

* Update and use ResultCode
2020-07-04 00:48:07 +02:00
Mary
c70056bc76
sockets: Make sure to write the receivedBuffer (#1346)
Fix #1341
2020-07-04 00:13:35 +02:00
Xpl0itR
4472196b48 Import DLC title key from ticket when loading into content manager (#1318) 2020-06-23 16:48:27 +02:00
Xpl0itR
2ed9db1fcd
Implement dlc management window (#1313)
* Implement dlc management window

* reduce repetition

* Implement per NCA toggling of DLC rather than per container
2020-06-23 10:32:07 +10:00
VolcaEM
a78a69a6e7
Update NRR structs (#1291)
* Update NRR structs

This was based on Switchbrew page: switchbrew.org/wiki/NRR

* Address review comments
2020-06-22 13:36:55 +02:00
mageven
1c2af7ce92
Implement aoc:u and support loading AddOnContent (#1221)
* Initial rebased AddOnContent support

* Fix bounds calculation
* Use existing GameCard in VFS per Xpl0itR's suggestion
+ Add dummy IPurchaseEventManager per AcK's suggestion

* Support multiple containers

* Add option to selectively disable addons

* Import tickets from AOC FS

* Load all nsps in base directory automatically

* Revert LoadNsp renaming

Removes conflicts with Mods PR. Not much is lost, old names were fine.

* Address AcK's comments

* Address Thog's comments

Dispose opened nsp files
Fix potential bug by clearing metadata on load
2020-06-20 19:38:14 +02:00
LDj3SNuD
5e724cf24e
Add Profiled Persistent Translation Cache. (#769)
* Delete DelegateTypes.cs

* Delete DelegateCache.cs

* Add files via upload

* Update Horizon.cs

* Update Program.cs

* Update MainWindow.cs

* Update Aot.cs

* Update RelocEntry.cs

* Update Translator.cs

* Update MemoryManager.cs

* Update InstEmitMemoryHelper.cs

* Update Delegates.cs

* Nit.

* Nit.

* Nit.

* 10 fewer MSIL bytes for us

* Add comment. Nits.

* Update Translator.cs

* Update Aot.cs

* Nits.

* Opt..

* Opt..

* Opt..

* Opt..

* Allow to change compression level.

* Update MemoryManager.cs

* Update Translator.cs

* Manage corner cases during the save phase. Nits.

* Update Aot.cs

* Translator response tweak for Aot disabled. Nit.

* Nit.

* Nits.

* Create DelegateHelpers.cs

* Update Delegates.cs

* Nit.

* Nit.

* Nits.

* Fix due to #784.

* Fixes due to #757 & #841.

* Fix due to #846.

* Fix due to #847.

* Use MethodInfo for managed method calls.

Use IR methods instead of managed methods about Max/Min (S/U).
Follow-ups & Nits.

* Add missing exception messages.

Reintroduce slow path for Fmov_Vi.
Implement slow path for Fmov_Si.

* Switch to the new folder structure.

Nits.

* Impl. index-based relocation information. Impl. cache file version field.

* Nit.

* Address gdkchan comments.

Mainly:
- fixed cache file corruption issue on exit; - exposed a way to disable AOT on the GUI.

* Address AcK77 comment.

* Address Thealexbarney, jduncanator & emmauss comments.

Header magic, CpuId (FI) & Aot -> Ptc.

* Adaptation to the new application reloading system.

Improvements to the call system of managed methods.
Follow-ups.
Nits.

* Get the same boot times as on master when PTC is disabled.

* Profiled Aot.

* A32 support (#897).

* #975 support (1 of 2).

* #975 support (2 of 2).

* Rebase fix & nits.

* Some fixes and nits (still one bug left).

* One fix & nits.

* Tests fix (by gdk) & nits.

* Support translations not only in high quality and rejit.

Nits.

* Added possibility to skip translations and continue execution, using `ESC` key.

* Update SettingsWindow.cs

* Update GLRenderer.cs

* Update Ptc.cs

* Disabled Profiled PTC by default as requested in the past by gdk.

* Fix rejit bug. Increased number of parallel translations. Add stack unwinding stuffs support (1 of 2).

Nits.

* Add stack unwinding stuffs support (2 of 2). Tuned number of parallel translations.

* Restored the ability to assemble jumps with 8-bit offset when Profiled PTC is disabled or during profiling.

Modifications due to rebase.
Nits.

* Limited profiling of the functions to be translated to the addresses belonging to the range of static objects only.

* Nits.

* Nits.

* Update Delegates.cs

* Nit.

* Update InstEmitSimdArithmetic.cs

* Address riperiperi comments.

* Fixed the issue of unjustifiably longer boot times at the second boot than at the first boot, measured at the same time or reference point and with the same number of translated functions.

* Implemented a simple redundant load/save mechanism.

Halved the value of Decoder.MaxInstsPerFunction more appropriate for the current performance of the Translator.
Replaced by Logger.PrintError to Logger.PrintDebug in TexturePool.cs about the supposed invalid texture format to avoid the spawn of the log.
Nits.

* Nit.

Improved Logger.PrintError in TexturePool.cs to avoid log spawn.
Added missing code for FZ handling (in output) for fp max/min instructions (slow paths).

* Add configuration migration for PTC

Co-authored-by: Thog <me@thog.eu>
2020-06-16 20:28:02 +02:00
Shrek5InTheatres2019
4ef689c67d
Stubbing ImportServerPki (#1281)
* Stubbed ImportServerPki

* thought it might be nice to name this variable properly

* i really need to name variables better

* Change Var

Co-authored-by: Thog <thog@protonmail.com>

* Change .ReadBytes(5) to IPC send buffer

Co-authored-by: Thog <thog@protonmail.com>

* Add description comment

Co-authored-by: Thog <thog@protonmail.com>

* fix build issue

* Resolve final suggestion

Co-authored-by: Thog <thog@protonmail.com>

* uhh

* it should work now shut up

* aligned variables just look so much nicer :)

* better variable alignment

* aligned

Co-authored-by: Thog <thog@protonmail.com>
2020-06-06 13:04:30 +02:00
Thog
bcb7761eac
SurfaceFlinger: fix some bugs (#1262)
* SurfaceFlinger: fix some bugs

This fixes some bugs in the current implementation and make it closer to
the real implementation.

* Fix align of some variables
2020-06-02 17:58:19 +02:00
mageven
b663cd22c8
Fix GetDesiredLanguage (#1275)
* Fix GetDesiredLanguage

* Correct tzcnt slip-up

* Address gdkchan's comments
2020-05-27 10:40:23 +02:00
mageven
6b55cedd73
Fix GetDisplayVersion (#1276) 2020-05-27 18:22:50 +10:00
Thog
cc8dbdd3fb
time: Make sure to initialize the network system clock with a valid system clock (#1259)
This should fix AC:NH events and probably other games.
2020-05-20 11:35:30 +02:00
Alex Barney
9544ed98b6
Update to LibHac 0.11.2 (#1240) 2020-05-16 12:12:13 +02:00
Thog
da3fd3f71b surfaceflinger: FreeBufferLocked doesn't reset the graphic buffer
That's the job of the user on Horizon (via SetPreallocatedBuffer).
2020-05-15 12:20:24 +02:00
mageven
ba4830293e
Refactor out Application details from Horizon (#1236)
* Initial Application refactor

* Misc typo and access modifier fixes

* Clean unused namespaces

* Address gdkchan's comments

* Move ticket reading to common method

* Change IParentalControlService to use ApplicationLoader.ControlData
2020-05-15 03:16:46 -03:00
Thog
0ff00bd6d3
am: Implement common web applets (#1188)
* am: Implemnet common web applets

This implement parsing of input and output of web applets while making
those close directly.

TODO for the future: Use and hook a web browser.

* Address Ac_K's comments
2020-05-15 03:56:14 +02:00
Thog
378259a40a
Surface Flinger: Implement GetBufferHistory (#1232)
* Surface Flinger: Implement GetBufferHistory

Also fix some bugs on the Surface Flinger implementation

* Address Ac_K's comment
2020-05-15 03:30:08 +02:00
Ac_K
b2e5855928
pctl: refactoring IParentalControlServiceFactory and IParentalControl… (#1219)
* pctl: refactoring IParentalControlServiceFactory and IParentalControlService call

Our previous implementation was totally guessed. Now it's implemented according to RE, even if it's stubbed because we will not support Parental Control for now.

* unknownFlag > permissionFlag
2020-05-15 03:14:38 +02:00
Ac_K
1f8e45c2ba
nvdrv: Partially implementation of GetStatus (#1215)
* nvdrv: Partially implementation of GetStatus

This implement GetStatus call according to RE.
Since we don't handle tranfert memory on the initialize of the service, it's fine sets fields at 0 for now.
Tested on Undertale.

Fix #635

* Fix struct
2020-05-13 15:29:16 +10:00
VolcaEM
b96aa7574f
Add missing error code to Time (#1237)
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)
2020-05-13 15:28:53 +10:00
Ac_K
76e1a162dd
am: Implement GetFriendInvitationStorageChannelEvent (#1220)
* am: Implement GetFriendInvitationStorageChannelEvent

This implement GetFriendInvitationStorageChannelEvent according to RE, needed by Streets of Rage 4

* Fix handle name

* add GetNotificationStorageChannelEvent
2020-05-12 16:52:27 +02:00
mageven
492bb6ee5f
Suppress CS0169 CS0649 warns from HID structs (#1222)
Also fix typo in a pragma restore in Logger
2020-05-10 16:02:41 +02:00
VolcaEM
be98a7a649
Add various error codes to Settings (#1229)
The error codes were taken from Switchbrew (https://switchbrew.org/wiki/Error_codes)
2020-05-10 13:33:15 +02:00
VolcaEM
1dd78142fa
Add two error codes to SDB PDM (#1230)
* Add two error codes to SDB PDM

The error codes were taken from Switchbrew (https://switchbrew.org/wiki/Error_codes)

* Remove empty line
2020-05-09 10:57:19 +02:00
VolcaEM
8b81819716
Add two error codes to Mii (#1224)
* Add two error codes to Mii

The two errors added are InvalidDatabaseSignatureValue and InvalidDatabaseEntryCount, which were taken from Switchbrew (https://switchbrew.org/wiki/Error_codes)

* Fix typo

* Remove unnecessary empty line
2020-05-08 16:23:26 +02:00
VolcaEM
fe72bc9274
Add various error codes to NCM LR (#1225)
The error codes were taken from Switchbrew (https://switchbrew.org/wiki/Error_codes)
2020-05-08 16:06:32 +02:00
gdkchan
1e687c4eea
Fix block iteration on kernel MemoryManager InsertBlock function (#1184) 2020-05-06 22:48:57 +10:00
plutoo
7f500e7cae
set: Quick implementation of GetKeyCodeMap/GetKeyCodeMap2 (#1210)
* set: Quick implementation of GetKeyCodeMap/GetKeyCodeMap2

This fixed USB keyboard access in official titles.

* hid: Stub SendKeyboardLockKeyEvent

* Update Ryujinx.HLE/HOS/Services/Settings/ISettingsServer.cs

Co-authored-by: Ac_K <Acoustik666@gmail.com>

* Update Ryujinx.HLE/HOS/Services/Hid/IHidServer.cs

Co-authored-by: Ac_K <Acoustik666@gmail.com>

* set: KeyboardLayout bringup

* set: Small bugfix

* Fix GetKeyCodeMapImpl

* Revert SystemRegion > RegionCode in Configuration

* Fix SendKeyboardLockKeyEvent

Co-authored-by: Ac_K <Acoustik666@gmail.com>
2020-05-05 20:50:53 +02:00
VolcaEM
f84fb20959
Add error code for denied internet request in Friends (#1207)
* Add error code for denied internet request in Friends

* Fix formatting from previous PR
2020-05-04 23:10:15 +10:00
VolcaEM
232d53a1ff
Add various error codes to Loader (#1208)
* Add various result codes to Loader

The error codes were taken from Switchbrew (switchbrew.org/wiki/Error_codes)

For the last 9 errors, Switchbrew says: ACID/ACI0 don't match for descriptor (descriptor)

* Fix typo
2020-05-04 13:22:28 +02:00
gdkchan
15d1cc806b
Move kernel state out of the Horizon class (#1107)
* Move kernel state from Horizon to KernelContext

* Merge syscalls partial classes, split 32 and 64-bit variants

* Sort usings
2020-05-04 13:41:29 +10:00
Ac_K
4c54f36c38
Upgrade projects to C#8 (#1193)
Some parts of our code needs C# 8 who isn't set as default in Visual Studio. To fix this we have to set the C# version correctly in the csproj files and then we are be able to build the project using Visual Studio.
2020-05-04 12:14:48 +10:00
gdkchan
f77694e4f7
Implement a new physical memory manager and replace DeviceMemory (#856)
* 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
2020-05-04 08:54:50 +10:00
VolcaEM
b0f0bd205d
Add various error codes to Audio (#1201)
The error codes were taken from Switchbrew (switchbrew.org/wiki/Error_codes)
2020-05-03 22:45:22 +02:00
VolcaEM
cf1ea4d155
Add various error codes to BCAT (#1202)
* Add various error codes to BCAT

The error codes were taken from Switchbrew (switchbrew.org/wiki/Error_codes)

As for InternetRequestDenied, it seems that this error is common for multiple services like Account for example
I already added this error code in Account in PR #1182

* Add some results codes from Libhac and keep names consistent
2020-05-03 17:06:30 +02:00
Xpl0itR
538fba826b
Improvements to input and input configuration in the GUI. (#849)
* Improvements to input and input configuration in the GUI

* Requested changes

* nits

* more nits
2020-05-03 04:00:53 +02:00
Thog
764891e670
nvservice: add a lock around NvHostEvent and remove release fence on SFv2 (#1197)
* nvservice: add a lock to NvHostEvent

* Disable surface flinger release fence and readd infinite timeout

* FenceAction: Add a timeout of 1 seconds as this shouldn't wait forever anyuway

* surfaceflinger: remove leftovers from the release fence

* Don't allow infinite timeout on syncpoint while printing all timeout for better debugging
2020-05-02 22:47:06 +02:00
VolcaEM
0a3b75ae2b
Add error code for denied internet request in Account (#1182)
InternetRequestDenied (I can't find a better name) was taken from Switchbrew (switchbrew.org/wiki/Error_codes)
Regarding this error, SwitchBrew notes: "IsAnyInternetRequestAccepted with the output from GetClientId returned false."
2020-05-02 14:12:11 +02:00
VolcaEM
8a7c00c39a
Add various error codes to AM (#1183)
* Add various error codes to AM

The error codes were taken from Switchbrew (https://switchbrew.org/wiki/Error_codes)

* TitleID -> TitleId
2020-05-02 13:45:45 +02:00
Thog
81cba3c3df
nvservices: mitigate abort with heavy load on the GPU processing thread (#1173)
* nvservices: mitigate abort with heavy load on the GPU processing thread.

This should fix Mario Tennis and LM3 regressions with syncpoints.

NOTE: Mario Tennis seems to have another issue related to the texture
cache that happens randomly when starting a match.

PS: Also add a debug logger for all known ioctl call to facilitate
debugging and add a missing UpdateMin in EventSignal.

* Address LDj3SNuD's comment

* Address gdkchan's comment
2020-05-01 23:18:42 +02:00
Thog
a0c06103c9
am: add IsVrModeEnabled (#1189)
* am: stub IsVrMode

Needed by SSBU 7.0.0

* Address Ac_K's comments
2020-05-01 18:51:00 +02:00
Alex Barney
ba7db8ccef
Update to LibHac 0.11.1 (#1186)
- Adds EnumerateDeliveryCacheDirectory to BCAT
2020-05-01 00:11:10 +02:00