Commit Graph

277 Commits

Author SHA1 Message Date
Sebastian Valle db752b52e8 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 a13ab958cb Fixed type conversion ambiguity 2017-09-30 09:34:35 +01:00
Subv 8432749db7 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 3165466b66 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 c02bbb7030 memory: Add GetCurrentPageTable/SetCurrentPageTable
Don't expose Memory::current_page_table as a global.
2017-09-24 22:42:42 +01:00
B3n30 813837c5cf Merge pull request #2842 from Subv/switchable_page_table
Kernel/Memory: Give each process its own page table and allow switching the current page table upon reschedule
2017-09-15 22:41:45 +02:00
Subv b178089251 Kernel/Threads: Don't clear the CPU instruction cache when performing a context switch from an idle thread into a thread in the same process.
We were unnecessarily clearing the cache when going from Process A -> Idle -> Process A, this caused extreme performance regressions.
2017-09-15 14:26:15 -05:00
Subv c34ec5e77c Kernel/Memory: Switch the current page table when a new process is scheduled. 2017-09-10 15:14:31 -05:00
Subv fa228ca637 Kernel/Threads: Don't immediately switch to the new main thread when loading a new process.
This is necessary for loading multiple processes at the same time.
The main thread will be automatically scheduled when necessary once the scheduler runs.
2017-08-21 20:54:29 -05:00
Yuri Kunde Schlesner 723dc644fa ResultVal: Remove MoveFrom()
Replace it with std::move(result_val).Unwrap(), or Foo().Unwrap() in
case you already have an rvalue.
2017-06-18 19:03:15 -07:00
Yuri Kunde Schlesner be031989ee Kernel: Move HandleTable to a separate file 2017-05-29 17:34:39 -07:00
Yuri Kunde Schlesner 2cdb40d709 Kernel: Centralize error definitions in errors.h 2017-05-24 21:06:00 -07:00
Subv 1ddff14511 Threads: Check the process' resource limit for the max allowed priority when creating a thread and remove the priority clamping code. 2017-01-11 16:38:05 -05:00
Subv f2f2572fed Thread: Added priority range checking to svcSetThreadPriority and removed priority clamping code from Thread::SetPriority. 2017-01-11 16:38:04 -05:00
bunnei b5eac78b43 Merge pull request #2410 from Subv/sleepthread
Don't yield execution in SleepThread(0) if there are no available threads to run
2017-01-06 22:01:33 -05:00
bunnei 1c792389e6 Merge pull request #2408 from Subv/priority_boosting
Kernel: Removed the priority boost code for starved threads.
2017-01-06 00:40:39 -05:00
Subv fc2266130b Kernel: Don't attempt to yield execution in SleepThread(0) if there are no available threads to run.
With this we avoid an useless temporary deschedule of the current thread.
2017-01-05 19:11:34 -05:00
Subv 5e2a8ebabf Kernel: Remove some unused functions. 2017-01-05 13:17:06 -05:00
Subv 933df2606a Kernel: Removed the priority boost code for starved threads.
After hwtesting and reverse engineering the kernel, it was found that the CTROS scheduler performs no priority boosting for threads like this, although some other forms of scheduling priority-starved threads might take place.

For example, it was found that hardware interrupts might cause low-priority threads to run if the CPU is preempted in the middle of an SVC handler that deschedules the current (high priority) thread before scheduling it again.
2017-01-05 13:12:39 -05:00
Subv dda4ec93be Kernel: Add some asserts to enforce the invariants in the scheduler. 2017-01-05 09:40:18 -05:00
Subv fd95b6ee26 Kernel: Remove Thread::wait_objects_index and use wait_objects to hold all the objects that a thread is waiting on. 2017-01-05 09:40:14 -05:00
Subv cef5f45de2 Kernel: Use different thread statuses when a thread calls WaitSynchronization1 and WaitSynchronizationN with wait_all = true.
This commit removes the overly general THREADSTATUS_WAIT_SYNCH and replaces it with two more granular statuses:

THREADSTATUS_WAIT_SYNCH_ANY when a thread waits on objects via WaitSynchronization1 or WaitSynchronizationN with wait_all = false.

THREADSTATUS_WAIT_SYNCH_ALL when a thread waits on objects via WaitSynchronizationN with wait_all = true.
2017-01-04 15:58:50 -05:00
Subv d3ff5b91e1 Kernel/Mutex: Propagate thread priority changes to other threads inheriting the priority via mutexes 2017-01-04 15:58:48 -05:00
Subv 7abf185390 Kernel/Mutex: Implemented priority inheritance.
The implementation is based on reverse engineering of the 3DS's kernel.

A mutex holder's priority will be temporarily boosted to the best priority among any threads that want to acquire any of its held mutexes.
When the holder releases the mutex, it's priority will be boosted to the best priority among the threads that want to acquire any of its remaining held mutexes.
2017-01-04 15:58:46 -05:00
Subv e6a7723f2f Kernel: Object ShouldWait and Acquire calls now take a thread as a parameter.
This will be useful when implementing mutex priority inheritance.
2017-01-04 15:58:45 -05:00
bunnei 8b1e269e58 ThreadContext: Move from "core" to "arm_interface". 2016-12-22 00:27:49 -05:00
bunnei e26fbfd1d7 core: Replace "AppCore" nomenclature with just "CPU". 2016-12-22 00:27:46 -05:00
bunnei 4fc8b8229e core: Remove HLE module, consolidate code & various cleanups. 2016-12-21 23:48:13 -05:00
bunnei 232ef55c1a core: Consolidate core and system state, remove system module & cleanups. 2016-12-21 23:29:13 -05:00
wwylele 5728e42634 Thread: remove the thread from the thread list when exiting 2016-12-17 19:23:52 +02:00
Subv 406907d570 Properly remove a thread from its wait_objects' waitlist when it is awoken by a timeout. 2016-12-10 13:29:31 -05:00
Subv 8634b8cb83 Threading: Reworked the way our scheduler works.
Threads will now be awakened when the objects they're waiting on are signaled, instead of repeating the WaitSynchronization call every now and then.

The scheduler is now called once after every SVC call, and once after a thread is awakened from sleep by its timeout callback.

This new implementation is based off reverse-engineering of the real kernel.

See https://gist.github.com/Subv/02f29bd9f1e5deb7aceea1e8f019c8f4 for a more detailed description of how the real kernel handles rescheduling.
2016-12-03 22:38:14 -05:00
Ricardo de Almeida Gonzaga 13d46f6820 Fix typos 2016-10-20 12:26:59 -02:00
wwylele f69a543110 implement wait tree widget 2016-09-22 13:52:52 +08:00
Yuri Kunde Schlesner 84fbbe2629 Use negative priorities to avoid special-casing the self-include 2016-09-21 00:15:56 -07:00
Emmanuel Gil Peyrot ebdae19fd2 Remove empty newlines in #include blocks.
This makes clang-format useful on those.

Also add a bunch of forgotten transitive includes, which otherwise
prevented compilation.
2016-09-21 11:15:47 +09:00
Yuri Kunde Schlesner 396a8d91a4 Manually tweak source formatting and then re-run clang-format 2016-09-18 21:14:25 -07:00
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
bunnei 4255f25647 Thread: Use std::find in CheckWait_WaitObject. 2015-01-21 20:48:46 -05:00
bunnei 2f3020a102 Mutex: Cleanup and remove redundant code. 2015-01-21 20:48:36 -05:00
bunnei f09806aed2 Kernel: Renamed some functions for clarity.
- ReleaseNextThread->WakeupNextThread
- ReleaseAllWaitingThreads->WakeupAllWaitingThreads.
2015-01-21 20:48:30 -05:00
bunnei 15b6a4d9ad Kernel: Changed "ShouldWait" to return bool and "Acquire" to return void. 2015-01-21 20:47:49 -05:00
bunnei c68eb15695 WaitObject: Renamed "Wait" to "ShouldWait", made "ShouldWait" and "Acquire" pure virtual. 2015-01-21 20:47:49 -05:00
bunnei 9412996c8f Kernel: Moved Wait and Acquire to WaitObject, added way to retrieve a WaitObject safely. 2015-01-21 20:47:46 -05:00
bunnei 254e4ebd58 AddressArbiter: Changed to Kernel::Object, big cleanup, removed code that made no sense. 2015-01-21 20:47:45 -05:00
bunnei e5a9f1c644 Kernel: Get rid of WaitTypes and simplify lots of code, removing hacks. 2015-01-21 20:47:38 -05:00
bunnei 6643673f28 WaitSynchronizationN: Refactor to fix several bugs
- Separate wait checking from waiting the current thread
- Resume thread when wait_all=true only if all objects are available at once
- Set output to correct wait object index when there are duplicate handles
2015-01-21 19:11:47 -05:00
bunnei aa01c57ae9 Kernel: Separate WaitSynchronization into Wait and Acquire methods. 2015-01-21 19:10:24 -05:00
bunnei 7faf2d8e06 WaitSynchronizationN: Implement return values 2015-01-21 19:09:03 -05:00
bunnei 1f7a04f05a Thread: Keep track of multiple wait objects. 2015-01-21 18:42:04 -05:00
bunnei c22bac6398 Kernel: Added WaitObject and changed "waitable" objects inherit from it. 2015-01-21 18:41:00 -05:00
bunnei 542b0b0057 Merge pull request #466 from Subv/wake
Thread: Prevent waking a thread multiple times.
2015-01-11 13:39:23 -05:00
Subv b68d51ed30 Thread: Prevent waking a thread multiple times.
If a thread was woken up by something, cancel the wakeup timeout.
2015-01-11 13:18:52 -05:00
Yuri Kunde Schlesner 8ad41775cc Kernel: Start using boost::intrusive_ptr for lifetime management 2015-01-09 19:43:52 -02:00
Yuri Kunde Schlesner 78ea76e12f Thread: Fix nullptr access in a logging function 2015-01-09 04:02:28 -02:00
Yuri Kunde Schlesner 7f1557fbbd Thread: Rename thread_queue => thread_list 2015-01-09 04:02:17 -02:00
Yuri Kunde Schlesner 9bf8462b96 Thread: Reduce use of Handles and move some funcs to inside the class. 2015-01-09 04:02:15 -02:00
Yuri Kunde Schlesner ba72208cd4 Kernel: Move Thread's definition to the header file 2015-01-09 03:51:55 -02:00
Yuri Kunde Schlesner 7b3452c730 Move ThreadContext to core/core.h and deal with the fallout 2015-01-09 03:51:55 -02:00
Subv dfc440785a SVC: Fixed SleepThread.
It will now properly wait the specified number of nanoseconds and then wake up the thread.
2015-01-08 18:39:12 -05:00
Subv 60a373a786 Threads: Use a dummy idle thread when no other are ready.
This thread will not actually execute instructions, it will only advance the timing/events and try to yield immediately to the next ready thread, if there aren't any ready threads then it will be rescheduled and start its job again.
2015-01-07 20:31:31 -05:00
Yuri Kunde Schlesner 122c2bb324 Common: Clean up ThreadQueueList
Replace all the C-style complicated buffer management with a std::deque.
In addition to making the code easier to understand it also adds support
for non-POD IdTypes.

Also clean the rest of the code to follow our code style.
2015-01-07 18:38:25 -02:00
Yuri Kunde Schlesner 7e2903cb74 Kernel: New handle manager
This handle manager more closely mirrors the behaviour of the CTR-OS
one. In addition object ref-counts and support for DuplicateHandle have
been added.

Note that support for DuplicateHandle is still experimental, since parts
of the kernel still use Handles internally, which will likely cause
troubles if two different handles to the same object are used to e.g.
wait on a synchronization primitive.
2014-12-28 11:52:55 -02:00
Yuri Kunde Schlesner 23f2142009 Kernel: Replace GetStaticHandleType by HANDLE_TYPE constants 2014-12-28 11:52:53 -02:00
Yuri Kunde Schlesner 73fba22c01 Rename ObjectPool to HandleTable 2014-12-28 11:52:52 -02:00
bunnei 0de6a08d75 Merge pull request #291 from purpasmart96/license
License change
2014-12-21 16:05:44 -05:00
purpasmart96 ebfd831ccb License change 2014-12-20 21:20:24 -08:00
bunnei 4fcdbed9f6 Thread: Wait current thread on svc_SleepThread
- Removed unused VBLANK sleep mode
- Added error log for bad context switch
- Renamed VerifyWait to CheckWaitType to be more clear
2014-12-20 23:20:19 -05:00
Yuri Kunde Schlesner adee775f44 Kernel: Implement support for current thread pseudo-handle
This boots a few (mostly Nintendo 1st party) games further.
2014-12-20 03:27:47 -02:00
Yuri Kunde Schlesner 0600e2d8b5 Convert old logging calls to new logging macros 2014-12-13 02:08:02 -02:00
bunnei 3a75c8069e Merge pull request #256 from Subv/mutex
Kernel/Mutex: Properly lock the mutex when a thread enters it
2014-12-10 22:52:55 -05:00
bunnei dd203f7068 Thread: Fixed to wait on address when in arbitration. 2014-12-08 19:44:10 -05:00
Subv 64128aa61a Mutex: Release all held mutexes when a thread exits. 2014-12-07 15:44:21 -05:00
Subv 6fac2bf0ab Threads: Remove a redundant function.
Use the next_thread_id variable directly.
2014-12-04 14:59:56 -05:00
Subv ef1d5cda06 Threads: Implemented a sequential thread id 2014-12-04 08:13:53 -05:00
Subv 029ff9f1fd SVC: Implemented GetThreadId.
For now threads are using their Handle value as their Id, it should not really cause any problems because Handle values are unique in Citra, but it should be changed. I left a ToDo there because this is not correct behavior as per hardware.
2014-12-04 00:25:35 -05:00
bunnei de851ba1a1 Thread: Check that thread is actually in "wait state" when verifying wait. 2014-11-26 15:04:08 -05:00
Yuri Kunde Schlesner 8189593255 Use pointers instead of passing handles around in some functions. 2014-11-24 17:08:37 -02:00
Yuri Kunde Schlesner 22c86824a4 Remove duplicated docs/update them for changed parameters. 2014-11-24 17:08:36 -02:00
Yuri Kunde Schlesner c2588403c0 HLE: Revamp error handling throrough the HLE code
All service calls in the CTR OS return result codes indicating the
success or failure of the call. Previous to this commit, Citra's HLE
emulation of services and the kernel universally either ignored errors
or returned dummy -1 error codes.

This commit makes an initial effort to provide an infrastructure for
error reporting and propagation which can be use going forward to make
HLE calls accurately return errors as the original system. A few parts
of the code have been updated to use the new system where applicable.

One part of this effort is the definition of the `ResultCode` type,
which provides facilities for constructing and parsing error codes in
the structured format used by the CTR.

The `ResultVal` type builds on `ResultCode` by providing a container for
values returned by function that can report errors. It enforces that
correct error checking will be done on function returns by preventing
the use of the return value if the function returned an error code.

Currently this change is mostly internal since errors are still
suppressed on the ARM<->HLE border, as a temporary compatibility hack.
As functionality is implemented and tested this hack can be eventually
removed.
2014-11-24 17:08:36 -02:00
bunnei c0cd0fa78e Merge pull request #211 from linkmauve/master
Remove trailing spaces from the entire project
2014-11-19 15:24:46 -05:00
Emmanuel Gil Peyrot f5d38649c7 Remove trailing spaces in every file but the ones imported from SkyEye, AOSP or generated 2014-11-19 09:03:07 +00:00
Lioncash 7cbecde2ca Add static to some variables 2014-11-18 20:04:00 -05:00
Yuri Kunde Schlesner d72708c1f5 Add `override` keyword through the code.
This was automated using `clang-modernize`.
2014-10-26 16:18:05 -02:00
archshift 6e606c515f core: Prune redundant includes 2014-09-08 17:54:14 -07:00
bunnei 304999dfeb Threading: Fix thread starting to execute first instruction correctly. 2014-08-28 17:51:49 -04:00
Lioncash 98fa3f7cba Core: Alter the kernel string functions to use std::string instead of const char*.
Most functions already operate on std::strings. This also removes the need to manually null terminate thread names.
2014-08-17 23:12:20 -04:00
bunnei d4bd2f2e5d Thread: Added more descriptive comment to WaitCurrentThread. 2014-08-06 18:19:59 -04:00
bunnei ba840d3200 Thread: Added functions to resume threads from address arbitration.
Thread: Cleaned up arbitrate address functions.

Thread: Cleaned up ArbitrateAllThreads function.
2014-07-08 18:46:15 -04:00
bunnei b62ef4bbd2 Thread: Renamed occurrences of "t" to "thread" to improve readability. 2014-06-13 09:51:17 -04:00
bunnei 5b7cf50a77 Thread: Cleaned up VerifyWait, fixed issue where nullptr msg could unnecessarily be logged. 2014-06-13 09:51:16 -04:00
bunnei 4620e2a741 HLE: Removed usnused EatCycles function. 2014-06-13 09:51:16 -04:00
bunnei bfdd874b1f Thread: Moved position of * in arguments. 2014-06-13 09:51:14 -04:00
bunnei 12e2a59565 Thread: Updated VerifyWait to be more readable (but functionally the same). 2014-06-13 09:51:14 -04:00
bunnei c95972275e HLE: Updated all uses of NULL to nullptr (to be C++11 compliant) 2014-06-13 09:51:13 -04:00
bunnei d7363322c7 HLE: Updated various handle debug assertions to be more clear. 2014-06-13 09:51:11 -04:00
bunnei 8cac527c94 Kernel: Updated several member functions to be const 2014-06-13 09:51:10 -04:00
bunnei b774b8b04e Thread: Fixed bug with ResetThread where cpu_registers[15] was being incorrectly set 2014-06-13 09:51:08 -04:00
bunnei aae9fcf4a4 Kernel: Made SyncRequest not pure virtual, with a default implementation of error (as this is not required for all kernel objects) 2014-06-13 09:51:08 -04:00
bunnei f5c7c15434 Kernel: Added real support for thread and event blocking
- SVC: Added ExitThread support
- SVC: Added SignalEvent support
- Thread: Added WAITTYPE_EVENT for waiting threads for event signals
- Thread: Added support for blocking on other threads to finish (e.g. Thread::Join)
- Thread: Added debug function for printing current threads ready for execution
- Thread: Removed hack/broken thread ready state code from Kernel::Reschedule
- Mutex: Moved WaitCurrentThread from SVC to Mutex::WaitSynchronization
- Event: Added support for blocking threads on event signalling

Kernel: Added missing algorithm #include for use of std::find on non-Windows platforms.
2014-06-13 09:51:02 -04:00
bunnei 3fb31fbc57 svc: added GetThreadPriority and SetThreadPriority, added (incomplete) DuplicateHandle support 2014-06-01 22:12:54 -04:00