Commit Graph

230 Commits

Author SHA1 Message Date
Lioncash
b8ee11a960 kernel/thread: Make GetFreeThreadLocalSlot() internally linked
This function isn't used outside of this translation unit, so we can
make it internally linked.
2018-08-02 11:54:23 -04:00
Lioncash
2811d57c6e kernel: Remove unnecessary includes
Removes unnecessary direct dependencies in some headers and also gets
rid of indirect dependencies that were being relied on to be included.
2018-07-31 10:15:17 -04:00
MerryMage
152b33eb33 core_timing: Split off utility functions into core_timing_util 2018-07-24 11:03:24 +01:00
bunnei
e732a782ac Merge pull request #751 from Subv/tpidr_el0
CPU: Save and restore the TPIDR_EL0 system register on every context switch
2018-07-21 10:48:30 -07:00
Subv
00f17a92ba CPU: Save and restore the TPIDR_EL0 system register on every context switch.
Note that there's currently a dynarmic bug preventing this register from being written.
2018-07-20 19:57:45 -05:00
Lioncash
ada731907a thread: Convert ThreadStatus into an enum class
Makes the thread status strongly typed, so implicit conversions can't
happen. It also makes it easier to catch mistakes at compile time.
2018-07-19 22:08:56 -04:00
bunnei
d1e52e2b4e Merge pull request #690 from lioncash/move
core/memory, core/hle/kernel: Use std::move where applicable
2018-07-18 20:55:55 -07:00
Lioncash
3bac924c46 core/memory, core/hle/kernel: Use std::move where applicable
Avoids pointless copies
2018-07-18 19:34:31 -04:00
Lioncash
8003f7d925 core: Don't construct instance of Core::System, just to access its live instance
This would result in a lot of allocations and related object
construction, just to toss it all away immediately after the call.

These are definitely not intentional, and it was intended that all of
these should have been accessing the static function GetInstance()
through the name itself, not constructed instances.
2018-07-18 18:18:27 -04:00
James Rowe
489e98954c Update clang format 2018-07-02 21:45:47 -04:00
James Rowe
847a518200 Rename logging macro back to LOG_* 2018-07-02 21:45:47 -04:00
Michael Scire
e86699a93f Kernel/Arbiters: Implement WaitForAddress 2018-06-21 01:40:29 -06:00
Subv
c5e21705f3 Kernel/Threads: A thread waking up by timeout from a WaitProcessWideKey may already have an assigned lock owner.
This situation may happen like so:
Thread 1 with low priority calls WaitProcessWideKey with timeout.
Thread 2 with high priority calls WaitProcessWideKey without timeout.
Thread 3 calls SignalProcessWideKey
- Thread 2 acquires the lock and awakens.
- Thread 1 can't acquire the lock and is put to sleep with the lock owner being Thread 2.
Thread 1's timeout expires, with the lock owner still being set to Thread 2.
2018-06-02 14:06:35 -05:00
Subv
9eaada7514 Kernel/Thread: Corrected a typo that caused the affinity mask to never be changed. 2018-05-30 21:36:29 -05:00
Subv
62fbbbf42d Kernel/Thread: Corrected a typo in an assert about the processor id. 2018-05-30 11:32:46 -05:00
bunnei
718a71843a thread: Rename mask to affinity_masks. 2018-05-10 19:34:53 -04:00
bunnei
b38cb3cf5b thread: Support core change on ResumeFromWait and improve ChangeCore. 2018-05-10 19:34:53 -04:00
bunnei
bb674c639b thread: Initialize ideal_core and mask members. 2018-05-10 19:34:52 -04:00
bunnei
9ae80d3328 threading: Reschedule only on cores that are necessary. 2018-05-10 19:34:52 -04:00
bunnei
8f08d3476c thread: Implement ChangeCore function. 2018-05-10 19:34:50 -04:00
bunnei
c5e0d82b9c core: Implement multicore support. 2018-05-10 19:34:46 -04:00
Lioncash
5d170ef55b core_timing: Namespace all functions and constants in core_timing's header
All of these variables and functions are related to timings and should be within the namespace.
2018-04-30 03:32:59 -04:00
Lioncash
39f224d92b general: Convert assertion macros over to be fmt-compatible 2018-04-27 10:04:02 -04:00
Lioncash
29210b602c kernel: Migrate logging macros to fmt-compatible ones 2018-04-25 20:32:09 -04:00
Subv
d891bdc4d1 Kernel: Implemented mutex priority inheritance.
Verified with a hwtest and implemented based on reverse engineering.

Thread A's priority will get bumped to the highest priority among all the threads that are waiting for a mutex that A holds.
Once A releases the mutex and ownership is transferred to B, A's priority will return to normal and B's priority will be bumped.
2018-04-23 11:23:44 -05:00
Subv
1313922fda Kernel: Remove unused ConditionVariable class. 2018-04-20 21:04:33 -05:00
Subv
9a51860eea Kernel: Remove old and unused Mutex code. 2018-04-20 21:04:32 -05:00
Subv
55a515d119 Kernel: Corrected the implementation of svcArbitrateLock and svcArbitrateUnlock.
Switch mutexes are no longer kernel objects, they are managed in userland and only use the kernel to handle the contention case.
Mutex addresses store a special flag value (0x40000000) to notify the guest code that there are still some threads waiting for the mutex to be released. This flag is updated when a thread calls ArbitrateUnlock.

TODO:
* Fix svcWaitProcessWideKey
* Fix svcSignalProcessWideKey
* Remove the Mutex class.
2018-04-20 21:04:25 -05:00
bunnei
db77ad437d memory: Fix stack region. 2018-03-31 16:06:45 -04:00
bunnei
c7fd2a37b8 thread: Add THREADSTATUS_WAIT_HLE_EVENT, remove THREADSTATUS_WAIT_ARB. 2018-03-18 20:56:32 -04:00
bunnei
79f5f5e4c7 kernel: Move stack region outside of application heap. 2018-03-16 18:32:23 -04:00
bunnei
33130a6652 MemoryState: Add additional memory states and improve naming. 2018-03-16 18:32:21 -04:00
bunnei
b95c68cc67 core: Move process creation out of global state. 2018-03-14 18:42:19 -04:00
Jules Blok
d52bed1e0d thread: Clear the process list on shutdown. 2018-02-27 17:13:39 +01:00
bunnei
1f3b456e6c kernel: Use Scheduler class for threading. 2018-02-18 15:17:16 -05:00
bunnei
cfc47f6ae6 kernel: Remove unused address_arbiter code. 2018-02-18 14:46:11 -05:00
Subv
ebc66a61b3 Kernel/IPC: Add a small delay after each SyncRequest to prevent thread starvation.
Ported from citra PR #3091

The delay specified here is from a Nintendo 3DS, and should be measured in a Nintendo Switch.

This change is enough to prevent Puyo Puyo Tetris's main thread starvation.
2018-02-18 13:25:48 -05:00
Lioncash
f6506859d2 thread: Silence formatting specifier warnings 2018-02-14 01:50:14 -05:00
Subv
a0e267af83 Kernel: Allow chaining WaitSynchronization calls inside a wakeup callback. 2018-01-08 21:12:49 -05:00
B3n30
51a9a51632 CoreTiming: Reworked CoreTiming (cherry-picked from Citra #3119)
* CoreTiming: New CoreTiming; Add Test for CoreTiming
2018-01-08 19:10:25 -05:00
bunnei
e9072e7381 arm: Remove SkyEye/Dyncom code that is ARMv6-only. 2018-01-02 22:24:12 -05:00
bunnei
3fd2fd2324 thread: Keep track of the initially created handle.
This is kinda crufty, but we need it for now to update guest state variables.
2017-12-31 17:23:36 -05:00
bunnei
c183aa67a3 thread: Main thread should set thread handle to reg 1. 2017-12-30 12:10:58 -05:00
bunnei
493047fb28 thread: Remove THUMB mode flag. 2017-12-30 12:08:26 -05:00
bunnei
c20010101b thread: Main thread should be ready by default, all others dormant. 2017-12-30 12:05:10 -05:00
bunnei
2d0f8daeef kernel: Various 64-bit fixes in memory/process/thread 2017-12-29 13:27:58 -05:00
bunnei
f4590f3137 hle: Use Switch formatted result codes. 2017-10-31 19:26:11 -04:00
bunnei
feabe21816 hle: Fix QueryMemory response for MemoryInfo. 2017-10-19 23:00:46 -04:00
bunnei
45b7723c75 Merge remote-tracking branch 'upstream/master' into nx
# Conflicts:
#	src/core/CMakeLists.txt
#	src/core/arm/dynarmic/arm_dynarmic.cpp
#	src/core/arm/dyncom/arm_dyncom.cpp
#	src/core/hle/kernel/process.cpp
#	src/core/hle/kernel/thread.cpp
#	src/core/hle/kernel/thread.h
#	src/core/hle/kernel/vm_manager.cpp
#	src/core/loader/3dsx.cpp
#	src/core/loader/elf.cpp
#	src/core/loader/ncch.cpp
#	src/core/memory.cpp
#	src/core/memory.h
#	src/core/memory_setup.h
2017-10-09 23:56:20 -04:00
bunnei
38016f790b loader: Various improvements for NSO/NRO loaders. 2017-10-09 21:39:32 -04:00