Commit graph

23 commits

Author SHA1 Message Date
Subv 98e3872353 Kernel/IPC: Use 39 microseconds for the SendSyncRequest delay approximation.
As measured by the time it takes for to return when performing the SetLcdForceBlack IPC request to the GSP:GPU service in a n3DS with firmware 11.6

See https://gist.github.com/ds84182/ecdbbd25b56a29bd4e5b32a7544b8e92 for the source code of the test.
2017-12-10 13:00:05 -05:00
Subv e90daa6a4f Kernel/IPC: Add a small delay after each SyncRequest to prevent thread starvation.
In a real 3DS, threads that call svcSyncRequest are put to sleep until the server responds via svcReplyAndReceive. Our HLE services don't implement this mechanism and are effectively immediate from the 3DS's point of view. This commit makes it so that we at least simulate the IPC delay.

Specific HLE handlers might need to put their callers to sleep for a longer period of time to simulate IO timings. This is their responsibility but doing so is currently not implemented.

See https://gist.github.com/ds84182/4a7690c5376e045cab9129ca4185bbeb for a test that was not passing before this commit.
2017-12-07 22:40:15 -05:00
Subv 06a2e0b591 Kernel/Sessions: Wake up any threads waiting on a ServerSession when its client is closed
The error code 0xC920181A will be returned by svcReplyAndReceive when the wakeup callback runs.
This lets LLE services be properly notified of clients closing the connection so they can end their handler threads instead of letting them linger indefinitely, taking up connection slots in their parent port.
2017-11-06 23:07:08 -05:00
Subv 8f108367c9 Kernel/IPC: Put a thread to sleep when performing an LLE IPC request.
It will be awoken when the server replies to the request via svcReplyAndReceive.
2017-11-06 10:46:19 -05:00
Subv 8e2d9f48f5 Kernel/IPC: Remove dead buffer translation code.
This is all implemented elsewhere, HLERequestContext for HLE requests, and svcReplyAndReceive for LLE requests.
2017-11-06 10:46:18 -05:00
Sebastian Valle 56d718b2a1 Merge pull request #2793 from Subv/replyandreceive
Kernel/SVC: Partially implemented svcReplyAndReceive
2017-06-29 17:05:22 -05:00
Subv 8feeb81af2 Kernel/ServerSession: Keep track of which threads have issued sync requests. 2017-06-25 14:47:25 -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 6354d08359 Kernel: Add a dedicated SetHleHandler method to ServerPort/ServerSession
This allows attaching a HLE handle to a ServerPort at any point after it
is created, allowing port/session creation to be generic between HLE and
regular services.
2017-06-06 02:56:32 -07:00
Yuri Kunde Schlesner e626a520ca HLE: Move SessionRequestHandler from Service:: to Kernel::
Most of the code that works with this is or will be in the kernel, so
it's a more appropriate place for it to be.
2017-06-05 23:40:11 -07:00
Subv 37347bfa38 Kernel/Sessions: Remove the ClientSession::Create function.
It is not meant to be used by anything other than CreateSessionPair.
2017-05-21 18:52:42 -05:00
Subv ddfabf3133 Kernel: Use a Session object to keep track of the status of a Client/Server session pair.
Reduce the associated port's connection count when a ServerSession is destroyed.
2017-05-15 11:22:15 -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
Subv 016307ae65 Fixed the codestyle to match our clang-format rules. 2016-12-14 12:45:36 -05:00
Subv ebbb55ec8f Moved the HLE command buffer translation task to ServerSession instead of the HLE handler superclass. 2016-12-09 12:52:12 -05:00
Subv 386112da32 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 f9bcf89510 Use std::move where appropriate. 2016-12-08 11:06:19 -05:00
Subv dd8887c8cf 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 2ce61344d6 Declare empty ServerSession and ClientSession constructors as default. 2016-12-02 22:58:02 -05:00
Subv 2eceee3a4c Fixed the rebase mistakes. 2016-11-30 23:28:31 -05:00
Subv 009b15b3aa 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 0a33d915f8 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 073653e858 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