Commit Graph

140 Commits

Author SHA1 Message Date
Emmanuel Gil Peyrot dc8479928c Sources: Run clang-format on everything. 2016-09-18 09:38:01 +09:00
bunnei 05e120a4cc arm: ResetContext shouldn't be part of ARM_Interface. 2016-09-15 17:49:30 -04:00
Yuri Kunde Schlesner de79b6fc48 Merge pull request #1869 from wwylele/dont-be-lazy
Switch context to the same thread if necessary
2016-06-28 21:03:52 -07:00
wwylele 7d56e88369 Thread: update timeout when rerunning WaitSynch 2016-06-04 09:27:16 +03:00
wwylele 81d3462a19 Switch context on the same thread if necessary 2016-05-30 07:34:53 +03:00
MerryMage 1ebaaf9bb1 Kernel/Thread: Remove use of Memory::GetPointer 2016-05-21 11:14:11 -05:00
Jannik Vogel af37dd0d52 Set fpscr for new threads 2016-05-17 08:59:52 +02:00
bunnei 0d8bd3ba36 Merge pull request #1695 from Subv/tls_alloc
Kernel/Threads: Dynamically allocate the TLS region for threads.
2016-05-12 21:51:35 -04:00
Subv d192fb066d Kernel/Threads: Dynamically allocate the TLS region for threads in the BASE region of the linear heap.
Each thread gets a 0x200-byte area from the 0x1000-sized page, when all 8 thread slots in a single page are used up, the kernel allocates a new page to hold another 8 entries.

This is consistent with what the real kernel does.
2016-05-07 10:18:47 -05:00
Lioncash 6b7ebb3f82 hle: Get rid of global access to g_reschedule
This shouldn't be directly exposed if there's already a partial API that operates on it.
We can just provide the rest of that API.
2016-03-21 02:57:12 -04:00
Subv 29032ce9b6 SVC: Fixed ArbitrateAddress to behave as it does on hardware.
This was verified with hwtests that i plan to upload later on.
2015-12-27 18:44:42 -05:00
Yuri Kunde Schlesner 84a22cb594 Kernel: Implement svcGetSystemInfo
This makes smealum/ctrulib@b96dd51d33 work
with Citra.
2015-11-30 19:49:44 -08:00
Rohit Nirmal 32391cffdd Silence -Wsign-compare warnings. 2015-10-06 22:16:15 -05:00
Yuri Kunde Schlesner 14eca982f4 Kernel: Implement svcGetProcessInfo in a basic way
This also adds some basic memory usage accounting. These two types are
used by Super Smash Bros. during startup.
2015-08-16 01:03:48 -03:00
Lioncash dfb424b6d1 dyncom: Rename armdefs.h to armstate.h 2015-07-25 22:10:44 -04:00
Subv 275aaeef9c Kernel/Scheduling: Clean up a thread's wait_objects when its scheduled.
They'll be reset if needed during the next svcWaitSynchronization call (if there's any pending)
2015-07-20 17:15:54 -05:00
Yuri Kunde Schlesner dc39d06950 Ensure all kernel objects are released during shutdown
This commit fixes several kernel object leaks. The most severe of them
was threads not being removed from the private handle table used for
CoreTiming events. This resulted in Threads never being released, which
in turn held references to Process, causing CodeSets to never be freed
when loading other applications.
2015-07-17 02:24:13 -03:00
bunnei 71e8822d23 kernel: Fix svcWaitSynch to always acquire requested wait objects. 2015-06-16 22:34:39 -04:00
Emmanuel Gil Peyrot b1503b2020 Remove every trailing whitespace from the project (but externals). 2015-05-29 21:59:29 +01:00
bunnei 0b7d2941cf Kernel: Move reschedules from SVCs to actual mechanisms that reschedule. 2015-05-20 18:05:47 -04:00
Yuri Kunde Schlesner 7ada357b2d Memmap: Re-organize memory function in two files
memory.cpp/h contains definitions related to acessing memory and
configuring the address space
mem_map.cpp/h contains higher-level definitions related to configuring
the address space accoording to the kernel and allocating memory.
2015-05-15 00:04:38 -03:00
Lioncash 207087c856 thread: Fix a conditional check in Reschedule 2015-05-14 11:10:04 -04:00
bunnei cb2b2071a8 Merge pull request #748 from Subv/tls_max
Core/Memory: Add TLS support for creating up to 300 threads
2015-05-11 23:32:28 -04:00
bunnei ee8da4c356 Merge pull request #751 from yuriks/idle-thread
Thread: Remove the idle thread
2015-05-11 23:22:47 -04:00
bunnei 6e26d063a5 Merge pull request #757 from Subv/scheduling
Core/Scheduling: Prepare the new priority in the thread queue when svcSetPriority is called
2015-05-11 22:54:00 -04:00
Yuri Kunde Schlesner 4f7a055081 Thread: Remove the idle thread
Instead just use nullptr to represent no thread is active.
2015-05-11 22:39:39 -03:00
Subv dda94e56dd Core/Memory: Add TLS support for creating up to 300 threads 2015-05-11 20:09:23 -05:00
Yuri Kunde Schlesner 820b97787c Merge pull request #750 from Subv/process_svc
Core/HLE: Implemented the SVCs GetProcessId and GetProcessIdOfThread
2015-05-11 17:44:26 -07:00
Subv dbc1320923 Core/Scheduling: Prepare the new priority in the thread queue when svcSetPriority is called 2015-05-11 19:38:10 -05:00
Subv 41f74a16fd Core/HLE: Implemented the SVCs GetProcessId and GetProcessIdOfThread 2015-05-11 09:15:10 -05:00
Yuri Kunde Schlesner d16c2bd956 Thread: Correctly set main thread initial stack position 2015-05-11 05:08:47 -03:00
Subv 115ad8e16a fixup! Set the TLS address in the scheduler 2015-05-10 18:43:59 -05:00
Subv 000876858d Core/Memory: Give every emulated thread it's own TLS area.
The TLS area for thread T with id Ti is located at TLS_AREA_VADDR + (Ti - 1) * 0x200.
This allows some games like Mario Kart 7 to continue further.
2015-05-10 18:35:37 -05:00
Yuri Kunde Schlesner 1c0b87edc2 Memory: Re-organize and rename memory area address constants 2015-05-09 01:29:52 -03:00
Yuri Kunde Schlesner e1fbac3ca1 Common: Remove common.h 2015-05-07 15:45:22 -03:00
bunnei c7dc799e19 Kernel: Properly initialize and shutdown all modules. 2015-05-01 18:27:03 -04:00
bunnei 9c3419ebcc Kernel: Implemented priority inheritance for mutexes. 2015-04-09 19:06:39 -04:00
bunnei 7b9f428b23 Thread: Implement priority boost for starved threads.
SVC: Return correct error code on invalid CreateThread processor ID.

SVC: Assert when creating a thread with an invalid userland priority.
2015-04-09 19:05:21 -04:00
archshift 4fb75d220a Misc cleanup of common and related functions 2015-02-19 22:26:25 -08:00
archshift ef24e72b26 Asserts: break/crash program, fit to style guide; log.h->assert.h
Involves making asserts use printf instead of the log functions (log functions are asynchronous and, as such, the log won't be printed in time)
As such, the log type argument was removed (printf obviously can't use it, and it's made obsolete by the file and line printing)

Also removed some GEKKO cruft.
2015-02-10 18:30:31 -08:00
Kevin Hartman 5fcbfc06eb Scheduler refactor Pt. 1
* Simplifies scheduling logic, specifically regarding thread status. It should be much clearer which statuses are valid
for a thread at any given point in the system.
* Removes dead code from thread.cpp.
* Moves the implementation of resetting a ThreadContext to the corresponding core's implementation.

Other changes:
* Fixed comments in arm interfaces.
* Updated comments in thread.cpp
* Removed confusing, useless, functions like MakeReady() and ChangeStatus() from thread.cpp.
* Removed stack_size from Thread. In the CTR kernel, the thread's stack would be allocated before thread creation.
2015-02-09 21:47:12 -08:00
Yuri Kunde Schlesner 88a4a808c6 Kernel: Stop creating useless Handles during object creation
They're finally unnecessary, and will stop cluttering the application's
handle table.
2015-02-02 15:37:09 -02:00
Yuri Kunde Schlesner 52f58e64ef Kernel: Make WaitObjects share ownership of Threads waiting on them
During normal operation, a thread waiting on an WaitObject and the
object hold mutual references to each other for the duration of the
wait.

If a process is forcefully terminated (The CTR kernel has a SVC to do
this, TerminateProcess, though no equivalent exists for threads.) its
threads would also be stopped and destroyed, leaving dangling pointers
in the WaitObjects.

The solution is to simply have the Thread remove itself from WaitObjects
when it is stopped. The vector of Threads in WaitObject has also been
changed to hold SharedPtrs, just in case. (Better to have a reference
cycle than a crash.)
2015-02-02 15:37:08 -02:00
Yuri Kunde Schlesner 7725256f64 Explicitly instantiate constructors/destructors for Kernel objects
This should speed up compile times a bit, as well as enable more liberal
use of forward declarations. (Due to SharedPtr not trying to emit the
destructor anymore.)
2015-02-02 15:37:07 -02:00
Yuri Kunde Schlesner 4e84df8be3 Mutex: Replace g_mutex_held_locks with a set inside Thread 2015-02-02 15:37:06 -02:00
Yuri Kunde Schlesner 869ec46683 Kernel: Introduce unique Object ids for debugging 2015-02-02 15:37:03 -02:00
Yuri Kunde Schlesner a9b86db3cf Kernel: Use separate Handle tables for CoreTiming userdata
This is to support the removal of GetHandle soon
2015-02-02 15:37:03 -02:00
Yuri Kunde Schlesner 664c79ff47 Thread: Modernize two functions that slipped through previous rebases 2015-02-02 15:37:01 -02:00
Lioncash 3f00dd9117 arm: Clean up ARMul_State
Remove unnecessary/unused struct variables.
2015-01-31 21:55:34 -05:00
bunnei 68ddaaa2f5 Thread: Fix WaitSynchronization1 to not set register 1 on thread wakeup. 2015-01-21 20:48:46 -05:00