2139 Commits

Author SHA1 Message Date
lynxnb b0703d3cb2 Perform TLS page address translation for direct accesses
This allows the IPC code to work without modifications since `KThread::tlsRegion` now stores a host address that can be accessed directly.
2024-05-23 16:48:45 +02:00
lynxnb c252c0432b Translate guest virtual addresses on direct accesses from SVCs 2024-05-23 16:45:29 +02:00
lynxnb b8d498a19e Fix incorrect logging call in QueryMemory 2024-05-22 20:29:03 +02:00
lynxnb 1ccd353a20 Enable more JIT optimizations and log exceptions 2024-05-10 15:12:15 +02:00
lynxnb 2593429d45 Enable JIT fastmem 2024-05-10 15:12:15 +02:00
lynxnb 08d2c5dceb Implement exclusive memory writes and exclusive monitor 2024-05-10 15:12:15 +02:00
lynxnb 07216e3a16 Implement coprocessor 15 accesses 2024-05-10 15:12:15 +02:00
lynxnb cc585f968e Add a signal handler for JIT threads 2024-05-10 15:12:15 +02:00
lynxnb ec74ed6c3d Introduce a thread local pointer to the current guest thread
This also gives easier access to the current guest process structure via the thread structure, just like any kernel does for their internal structures.
2024-05-10 15:12:15 +02:00
lynxnb f7e199e02e Implement GetThreadContext3 SVC for 32bit processes 2024-05-10 15:12:15 +02:00
lynxnb ce5fb3f729 Support initializing VMM for 32bit address spaces 2024-05-10 15:12:15 +02:00
lynxnb 3c52d9e3c9 Introduce a preemption handler for scheduling with JIT
Scheduler initialization has been delayed until process information is available, as it needs to differentiate between 32bit and 64bit processes.
2024-05-10 15:12:13 +02:00
lynxnb 0d2e9de34e Introduce kernel objects for 32bit processes
This commit introduces two new kernel thread types, `KNceThread` and `Jit32Thread`.
`KNceThread`s behave like the previous kernel thread object by setting up thread state and jumping into guest code.
`KJit32Thread`s need to run guest code on a `JitCore32` object, so they perform the necessary state setup and then they also setup the jit core for executing guest code. A loop was introduced because jit execution might return when halted, either for an SVC or for preemption. In those cases the thread needs to wait to be scheduled before executing again.

The process object has also been updated to be able to create 32bit threads when running 32bit processes.

Additionally NCE's ThreadContext has been removed from DeviceState, since a thread is not an NCE thread only anymore, and IPC code has been changed to retrieve the tls region from the thread object.
2024-05-08 13:44:46 +02:00
lynxnb 537a103f16 Initialize JIT when launching 32bit executables 2024-05-08 13:44:46 +02:00
lynxnb 2777d1ee8f Introduce Jit32 and JitCore32 objects 2024-05-08 13:44:45 +02:00
lynxnb ab6400d745 Add Dynarmic as a submodule 2024-05-08 13:44:45 +02:00
TheASVigilante ae1566a482 Fix accidental recursion with trap handling 2024-04-28 20:04:22 +02:00
lynxnb 83111c2ae7 Move memory trapping infrastructure outside of NCE 2024-04-27 16:15:29 +02:00
lynxnb d5d6e677ca Rework CI to only upload artifacts for PR builds
CI now performs build checks on pushes to the master branch only.
For pull requests, the dev variant of the app is built and artifacts are uploaded for ease of testing and side-by-side installation. PR builds use autogenerated debug signing keys, resulting in different keys being used for each build on purpose to ensure they cannot be installed over each other, avoiding any possible conflict between two PRs.
2024-02-27 23:11:15 +01:00
lynxnb 686a25120b Move SvcTable definition out of header files 2024-02-23 15:06:40 +01:00
lynxnb 18626a4251 Introduce a generic register context for SVCs
`SvcContext` represents a common interface for accessing registers from SVCs, decoupling them from a particular thread context.
2024-02-23 15:06:40 +01:00
lynxnb 80b3b223c8 KProcess: correctly handle empty optional chunk 2024-02-22 08:53:45 +01:00
lynxnb b51c31dc72 memory: update KMemory to use guest addresses 2024-02-21 15:40:23 +01:00
lynxnb 8addba3273 memory: use guest addresses everywhere
The memory manager has been reworked to handle addresses in the guest address space, and applying an offset to get the address on the host whenever memory needs to be mapped/unmapped/reprotected.
2024-02-21 15:40:05 +01:00
lynxnb d693cac5da memory: fix insertion at the beginning of the chunks map
The memory manager was incorrectly inserting chunks when the new chunk was being inserted at the beginning of the chunks map (no previous chunk available). The existing chunk was resized to an empty chunk (correctly), but the new chunk was never inserted because of `std::map::insert` skipping insertion on an already existing key.
This resulted in an empty chunk being left at the beginning of the map, causing infinite loops for code that worked by scanning the chunks map.

Usages of `std::map::operator[]` have also been replaced with the safer `insert_or_assign`.
2024-02-21 15:39:48 +01:00