Commit Graph

372 Commits

Author SHA1 Message Date
bunnei 0805a50670 ThreadContext: Move from "core" to "arm_interface". 2016-12-22 00:27:49 -05:00
bunnei 8070c3ea85 core: Replace "AppCore" nomenclature with just "CPU". 2016-12-22 00:27:46 -05:00
bunnei c5f21efe18 core: Remove HLE module, consolidate code & various cleanups. 2016-12-21 23:48:13 -05:00
bunnei d4f9119dba core: Consolidate core and system state, remove system module & cleanups. 2016-12-21 23:29:13 -05:00
wwylele 32f85927c7 Thread: remove the thread from the thread list when exiting 2016-12-17 19:23:52 +02:00
wwylele 2ef902fb1e Kernel: remove object's waiting thread if it is dead 2016-12-16 12:33:18 +02:00
bunnei 1e01fd893e Merge pull request #2260 from Subv/scheduling
Threading: Reworked the way our scheduler works.
2016-12-16 00:41:22 -05:00
Subv 517a16acb8 Fixed the codestyle to match our clang-format rules. 2016-12-14 12:45:36 -05:00
Subv c6a9bce77a Fixed the codestyle to match our clang-format rules. 2016-12-14 12:35:01 -05:00
Subv 42fcf27f5c 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 9196e713f4 Moved the HLE command buffer translation task to ServerSession instead of the HLE handler superclass. 2016-12-09 12:52:12 -05:00
Subv 93c592f312 WaitSynch: Removed unused variables and reduced SharedPtr copies.
Define a variable with the value of the sync timeout error code.

Use a boost::flat_map instead of an unordered_map to hold the equivalence of objects and wait indices in a WaitSynchN call.
2016-12-09 12:23:09 -05:00
Subv ee6c03dfc6 Added a framework for partially handling Session disconnections.
Further implementation will happen in a future commit.

Fixes a regression.
2016-12-08 15:01:10 -05:00
Subv 41e5e714d5 Use std::move where appropriate. 2016-12-08 11:06:19 -05:00
Subv 0076acc3a9 Use boost remove_erase_if instead of the erase-remove idiom 2016-12-06 19:31:53 -05:00
Subv 415f13987e Improved the algorithm for GetHighestPriorityReadyThread. 2016-12-06 19:15:32 -05:00
Subv eb8b765178 Return an error code when connecting to a saturated port.
The error code was taken from the 3DS kernel.
2016-12-05 13:59:57 -05:00
Subv 7214f4986e Split SessionRequestHandler::HandleSyncRequest into HandleSyncRequest, TranslateRequest and HandleSyncRequestImpl.
HandleSyncRequest now takes care of calling the command buffer translate function before actually invoking the command handler for HLE services.
2016-12-05 12:05:00 -05:00
Subv 824692849b Kernel: Remove the Redirection handle type. 2016-12-05 11:13:22 -05:00
Subv 7a18725662 KServerPorts now have an HLE handler "template", which is inherited by all ServerSessions created from it. 2016-12-05 11:02:08 -05:00
Subv 7e5b90a04b Threading: Added some utility functions and const correctness. 2016-12-04 09:58:36 -05:00
Subv e3486361fd 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
Subv 039c8a8fc5 Declare empty ServerSession and ClientSession constructors as default. 2016-12-02 22:58:02 -05:00
Subv 694df935a6 Fixed the rebase mistakes. 2016-11-30 23:28:31 -05:00
Subv 20f90896af A bit of a redesign.
Sessions and Ports are now detached from each other.
HLE services are handled by means of a SessionRequestHandler class, Interface now inherits from this class.
The File and Directory classes are no longer kernel objects, but SessionRequestHandlers instead, bound to a ServerSession when requested.
File::OpenLinkFile now creates a new session pair and binds the File instance to it.
2016-11-30 23:12:35 -05:00
Subv 856f8029d7 IPC/HLE: Associate the ClientSessions with their parent port's HLE interface if it exists.
Pass the triggering ServerSession to the HLE command handler to differentiate which session caused the request.
2016-11-30 23:04:00 -05:00
Subv 11daab060a Kernel/HLE: Service::Interface no longer inherits from any Kernel object, and is now its own standalone class.
Interface is now used by aggregation in ClientPort, to forward service commands to their HLE implementation if needed.
2016-11-30 23:03:59 -05:00
Subv d0093a8b40 fixup! Kernel/IPC: Use Ports and Sessions as the fundamental building block of Inter Process Communication. 2016-11-30 23:02:06 -05:00
Subv 0d2f2880b9 Kernel/IPC: Use Ports and Sessions as the fundamental building block of Inter Process Communication.
All handles obtained via srv::GetServiceHandle or svcConnectToPort are references to ClientSessions.
Service modules will wait on the counterpart of those ClientSessions (Called ServerSessions) using svcReplyAndReceive or svcWaitSynchronization[1|N], and will be awoken when a SyncRequest is performed.

HLE Interfaces are now ClientPorts which override the HandleSyncRequest virtual member function to perform command handling immediately.
2016-11-30 23:02:05 -05:00
Yuri Kunde Schlesner 20333d468d Merge pull request #2196 from Subv/system_mode
Kernel/Loader: Grab the system mode from the NCCH ExHeader.
2016-11-27 17:04:11 -08:00
Subv 8369e7b59f Kernel/Loader: Grab the system mode from the NCCH ExHeader.
3dsx and elf files default to system mode 2 (96MB allocated to the application).

This allows Home Menu to boot without modifications.
Closes #1849
2016-11-19 20:40:04 -05:00
Subv 3841d6807a Kernel/Events: Log an error when trying to create Pulse events and timers.
Related to #1904
2016-11-19 14:00:08 -05:00
Ricardo de Almeida Gonzaga 5331d83994 Fix typos 2016-10-20 12:26:59 -02:00
wwylele cc4681da73 move ResetType to kernel.h 2016-09-22 13:52:52 +08:00
wwylele 7a4bb69d51 implement wait tree widget 2016-09-22 13:52:52 +08:00
Yuri Kunde Schlesner 45751915a0 Use negative priorities to avoid special-casing the self-include 2016-09-21 00:15:56 -07:00
Emmanuel Gil Peyrot e4393f7ff2 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 0e23caf9fd Manually tweak source formatting and then re-run clang-format 2016-09-18 21:14:25 -07:00
Emmanuel Gil Peyrot 7e8d205414 Sources: Run clang-format on everything. 2016-09-18 09:38:01 +09:00
bunnei 50e94d6194 arm: ResetContext shouldn't be part of ARM_Interface. 2016-09-15 17:49:30 -04:00
Lectem fa6b8cccf3 fix #1942 and adds a few IPC functions for descriptors 2016-08-02 16:45:15 +02:00
Yuri Kunde Schlesner 38d210a375 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
bunnei 163cafd9cd Merge pull request #1867 from mailwl/srv-update
srv: Update according 3dbrew
2016-06-28 18:53:10 -04:00
bunnei 1c61c74aeb Merge pull request #1877 from wwylele/wait-fix-timeout
Thread: update timeout when reruning WaitSynch
2016-06-18 01:08:22 -04:00
Subv c25dc87890 Kernel/SVC: Implemented svcCreatePort. 2016-06-11 08:37:37 -05:00
Subv e717d569af Kernel: Added ClientPort and ServerPort classes.
This is part of an ongoing effort to implement support for multiple processes.
2016-06-05 09:35:31 -05:00
wwylele 2aa3198a9e Thread: update timeout when rerunning WaitSynch 2016-06-04 09:27:16 +03:00
mailwl e2bd7807c0 Fix parameter name in EnableNotification 2016-05-31 10:06:00 +03:00
wwylele 900cb65509 Switch context on the same thread if necessary 2016-05-30 07:34:53 +03:00
bunnei 424e89def4 Merge pull request #1692 from Subv/rm_getpointer2
Memory: Remove most usages of GetPointer
2016-05-29 21:57:07 -04:00