Commit graph

222 commits

Author SHA1 Message Date
Lioncash e72928762f 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 d74d2a77cb Update clang format 2018-07-02 21:45:47 -04:00
James Rowe e159c550d8 Rename logging macro back to LOG_* 2018-07-02 21:45:47 -04:00
Michael Scire 3119b64d86 Kernel/Arbiters: Implement WaitForAddress 2018-06-21 01:40:29 -06:00
Subv dd9a1fd943 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 2a690458b5 Kernel/Thread: Corrected a typo that caused the affinity mask to never be changed. 2018-05-30 21:36:29 -05:00
Subv bcae826522 Kernel/Thread: Corrected a typo in an assert about the processor id. 2018-05-30 11:32:46 -05:00
bunnei ce7d89cb0e thread: Rename mask to affinity_masks. 2018-05-10 19:34:53 -04:00
bunnei d96be9b56b thread: Support core change on ResumeFromWait and improve ChangeCore. 2018-05-10 19:34:53 -04:00
bunnei 82bb8701ea thread: Initialize ideal_core and mask members. 2018-05-10 19:34:52 -04:00
bunnei 5a5850af69 threading: Reschedule only on cores that are necessary. 2018-05-10 19:34:52 -04:00
bunnei 922b5c326e thread: Implement ChangeCore function. 2018-05-10 19:34:50 -04:00
bunnei 44c565aeca core: Implement multicore support. 2018-05-10 19:34:46 -04:00
Lioncash 3873211738 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 324ee31fc3 general: Convert assertion macros over to be fmt-compatible 2018-04-27 10:04:02 -04:00
Lioncash bd9414dd31 kernel: Migrate logging macros to fmt-compatible ones 2018-04-25 20:32:09 -04:00
Subv 329bec6dbd 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 f5a2b1920b Kernel: Remove unused ConditionVariable class. 2018-04-20 21:04:33 -05:00
Subv e499b48f97 Kernel: Remove old and unused Mutex code. 2018-04-20 21:04:32 -05:00
Subv 4e47dd5b59 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 36cdd5a39c memory: Fix stack region. 2018-03-31 16:06:45 -04:00
bunnei d6c27e6b28 thread: Add THREADSTATUS_WAIT_HLE_EVENT, remove THREADSTATUS_WAIT_ARB. 2018-03-18 20:56:32 -04:00
bunnei a26561ce20 kernel: Move stack region outside of application heap. 2018-03-16 18:32:23 -04:00
bunnei 29bda49fc0 MemoryState: Add additional memory states and improve naming. 2018-03-16 18:32:21 -04:00
bunnei f16763ed52 core: Move process creation out of global state. 2018-03-14 18:42:19 -04:00
Jules Blok 29a5203a2a thread: Clear the process list on shutdown. 2018-02-27 17:13:39 +01:00
bunnei 539977f39b kernel: Use Scheduler class for threading. 2018-02-18 15:17:16 -05:00
bunnei 0b8907958f kernel: Remove unused address_arbiter code. 2018-02-18 14:46:11 -05:00
Subv fbb0ef851c 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 321765d0b4 thread: Silence formatting specifier warnings 2018-02-14 01:50:14 -05:00
Subv ac8f05943b Kernel: Allow chaining WaitSynchronization calls inside a wakeup callback. 2018-01-08 21:12:49 -05:00
B3n30 1b2aa3780d CoreTiming: Reworked CoreTiming (cherry-picked from Citra #3119)
* CoreTiming: New CoreTiming; Add Test for CoreTiming
2018-01-08 19:10:25 -05:00
bunnei b055ea2699 arm: Remove SkyEye/Dyncom code that is ARMv6-only. 2018-01-02 22:24:12 -05:00
bunnei 57d3544f96 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 3fc608b040 thread: Main thread should set thread handle to reg 1. 2017-12-30 12:10:58 -05:00
bunnei da4bd90980 thread: Remove THUMB mode flag. 2017-12-30 12:08:26 -05:00
bunnei d8a3de102e thread: Main thread should be ready by default, all others dormant. 2017-12-30 12:05:10 -05:00
bunnei 78531342a4 kernel: Various 64-bit fixes in memory/process/thread 2017-12-29 13:27:58 -05:00
bunnei 714dd3da6d hle: Use Switch formatted result codes. 2017-10-31 19:26:11 -04:00
bunnei bf69f3d1eb hle: Fix QueryMemory response for MemoryInfo. 2017-10-19 23:00:46 -04:00
bunnei 775cf60729 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 e36ccd5ff1 loader: Various improvements for NSO/NRO loaders. 2017-10-09 21:39:32 -04:00
Sebastian Valle cbf57de4e5 Merge pull request #2971 from Subv/per_process_memops
Memory: Add overloads for ReadBlock and WriteBlock that operate on a specific process.
2017-10-01 14:44:06 -05:00
Subv 141da6b667 Kernel/Thread: Added a helper function to get a thread's command buffer VAddr. 2017-10-01 14:18:35 -05:00
bunnei 6cfc867d93 kernel: Various threading fixes to support 64-bit addressing. 2017-09-30 14:28:54 -04:00
Sebastian Valle 2e30398e7a Merge pull request #2967 from Subv/thread_wakeup_callbacks
Kernel/Threads: When putting a thread to wait, specify a function to execute when it is awoken
2017-09-30 09:12:18 -05:00
Huw Pascoe da1c8d1522 Fixed type conversion ambiguity 2017-09-30 09:34:35 +01:00
Subv a0054d695e Kernel/Threads: When putting a thread to wait, specify a function to execute when it is awoken.
This change makes for a clearer (less confusing) path of execution in the scheduler, now the code to execute when a thread awakes is closer to the code that puts the thread to sleep (WaitSynch1, WaitSynchN). It also allows us to implement the special wake up behavior of ReplyAndReceive without hacking up WaitObject::WakeupAllWaitingThreads.

If savestates are desired in the future, we can change this implementation to one similar to the CoreTiming event system, where we first register the callback functions at startup and assign their identifiers to the Thread callback variable instead of directly assigning a lambda to the wake up callback variable.
2017-09-28 11:53:32 -05:00
Subv 2e78c05d91 Kernel/Thread: Allow specifying which process a thread belongs to when creating it.
Don't automatically assume that Thread::Create will only be called when the parent process is currently scheduled. This assumption will be broken when applets or system modules are loaded.
2017-09-26 17:40:49 -05:00
MerryMage 6b8ad273fc memory: Add GetCurrentPageTable/SetCurrentPageTable
Don't expose Memory::current_page_table as a global.
2017-09-24 22:42:42 +01:00