Commit graph

490 commits

Author SHA1 Message Date
Subv daecd812b0 HLE/Services: Allow specifying a SessionData template parameter to ServiceFramework.
Some services can have multiple clients at the same time, and they identify the different clients using the server session as a key.
This parameter (if present) should be a structure that contains the per-session data for each service.
The data can be retrieved using ServiceFramework::GetSessionData(session)
2017-12-14 18:24:02 -05:00
Subv c9ddd5b0ae HLE/FS: Implemented FSFile::OpenSubFile.
The File class now holds a list of connected sessions along with data unique to each session.

A subfile is a window into an existing file. They have a few limitations compared to normal files:

* They can't be written to.
* They can't be flushed.
* Their size can not be changed.
* New subfiles can't be created from another subfile.
2017-12-12 13:34:02 -05:00
Lioncash c31f932afe common/core: Silence initialization order warnings 2017-12-10 19:50:45 -05:00
B3n30 2146311ad1
Merge pull request #3091 from Subv/hle_request_delat
Kernel/IPC: Add a small delay after each SyncRequest to prevent thread starvation.
2017-12-10 19:59:19 +01:00
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
Sebastian Valle 2859b98884
Merge pull request #3234 from Subv/dlp2
HLE/FS: Implemented FS::GetProgramLaunchInfo.
2017-12-10 08:58:08 -05:00
Yuri Kunde Schlesner 21188f5683 HLE: Move SVC handlers to the Kernel namespace 2017-12-09 20:32:58 -08:00
Yuri Kunde Schlesner ad71e23f23 HLE: Move svc.{cpp,h} to kernel/ 2017-12-09 18:10:47 -08:00
Subv 7d038b9bd8 HLE/FS: Implemented FS::GetProgramLaunchInfo.
This function is used by the DLP system module during the DLPSRVR initialization.
2017-12-09 18:46:34 -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 8c16b90eae HLE/AddressArbiter: Remove threads that were awoken by timeout from the arbiter's waitlist when using WaitIfLessThanWithTimeout and DecrementAndWaitIfLessThanWithTimeout.
Fixes a regression introduced in #3096
2017-12-06 09:06:45 -05:00
Weiyi Wang 14819d0b84
Merge pull request #3138 from wwylele/ipc-mapped-buffer
Kernel/IPC: Implement MappedBuffer translation for HLE services that use the HLERequestContext architecture.
2017-12-03 11:33:48 +02:00
wwylele 3ecf650bf9 Kernel/IPC: Implement MappedBuffer translation for HLE services that use the HLERequestContext architecture. 2017-12-03 00:05:20 +02:00
bunnei b2a99043e3
Merge pull request #2968 from Subv/hle_thread_pause
Kernel/Threads: Add a new thread status that will allow using a Kernel::Event to put a guest thread to sleep inside an HLE handler until said event is signaled
2017-11-29 10:45:48 -05:00
Subv 9543e1a1bf HLE/IPC: Don't assert in HLERequestContext::AddStaticBuffer when there's already a static buffer with the desired id.
This could happen if the guest application performs a request with static buffer id X, and the service module responds with another static buffer with the same id X.
2017-11-28 09:01:15 -05:00
B3n30 e9a95b2e7d
CoreTiming: Reworked CoreTiming (#3119)
* CoreTiming: New CoreTiming; Add Test for CoreTiming
2017-11-25 14:56:57 +01:00
Sebastian Valle 555c8ba7c1
Merge pull request #3077 from Subv/hle_static_buffer
Kernel/IPC: Implement StaticBuffer translation for HLE services that use the HLERequestContext architecture.
2017-11-19 11:34:02 -05:00
Sebastian Valle ff275ac1e1
Merge pull request #3083 from Subv/lle_staticbuffer_translation
Kernel/IPC: Handle the StaticBuffer descriptor in LLE command requests.
2017-11-19 11:31:49 -05:00
Sebastian Valle f0027e9996
Merge pull request #3096 from Subv/arbitrateaddress
Kernel/Arbiters: When doing ArbitrateAddress(Signal), always pick the highest priority thread, using the first one that was put to sleep if more than one thread with the same highest priority exists.
2017-11-15 09:16:16 -05:00
Sebastian Valle 93742ec510
Merge pull request #3088 from Subv/clientsession_closing
Kernel/Sessions: Wake up any threads waiting on a ServerSession when its client is closed
2017-11-15 09:15:34 -05:00
Subv c9c1ba0952 Kernel/IPC: Implement StaticBuffer translation for HLE services that use the HLERequestContext architecture.
The real kernel requires services to set up their static buffer targets ahead of time. This implementation does not require that and will simply create the storage for the buffers as they are processed in the incoming IPC request.

Static buffers are kept in an unordered_map keyed by their buffer id, and are written into the already-setup area of the request thread when responding an IPC request.

This fixes a regression (crash) introduced in #2992.

This PR introduces more warnings due to the [[deprecated]] attribute being added to void PushStaticBuffer(VAddr buffer_vaddr, size_t size, u8 buffer_id); and VAddr PopStaticBuffer(size_t* data_size);
2017-11-12 11:00:00 -05:00
Subv c68adb787b Kernel/Arbiters: When doing ArbitrateAddress(Signal), always pick the highest priority thread, using the first one that was put to sleep if more than one thread with the same highest priority exists.
This is consistent with hardware behavior as shown by this test https://gist.github.com/ds84182/40e46129bd38b46a5100f15f96ba5eaf
2017-11-08 18:47:08 -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 2d9e295e07 Kernel/IPC: Handle the StaticBuffer descriptor in LLE command requests.
This descriptor requires the target process to set up a "receive buffer" beforehand, where the input data will be written to when the descriptor is processed.
2017-11-06 13:30:31 -05:00
Subv 980df62397 Kernel/Thread: Run the main thread in the CPU specified by the process' exheader.
System services usually have Core1 in this field, but citra was running them in Core0 regardless.
2017-11-06 13:14:31 -05:00
Sebastian Valle d55a13c35d
Merge pull request #2981 from Subv/replyreceive
Kernel/SVC: Implement LLE command buffer translation in ReplyAndReceive
2017-11-06 13:02:30 -05:00
Subv 23deae4785 Debugging: Implement GetName for Kernel::ServerSession.
Fixes the "[UNKNOWN KERNEL OBJECT]" message in the wait tree when inspecting a server session.
2017-11-06 10:47:06 -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 33c5982f6d Kernel/Threads: Added a new thread status to identify threads waiting for an IPC reply from svcSendSyncRequest. 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
Subv 7cf7999e02 Kernel/IPC: Added a function to translate the IPC command buffer from one process to another.
Currently only CopyHandle, MoveHandle and CallingPid descriptors are implemented.
2017-11-06 10:46:12 -05:00
wwylele 4fdc877626 remove trailing spaces 2017-11-06 13:57:06 +02:00
Sebastian Valle ff17773c28
Kernel/Mutex: Add a missing return in Mutex::Release
Fixes a regression in #3042.
Closes #3079
2017-11-05 21:31:22 -05:00
Weiyi Wang 4fc0448093
Merge pull request #3064 from wwylele/printf-warnings
Clean all format warnings
2017-11-05 10:32:46 +02:00
Subv 68dba11805 Kernel/SVC: Don't let svcReleaseMutex release a mutex owned by another thread.
This behavior was reverse engineered from the 3DS kernel.
2017-11-04 10:05:18 -05:00
wwylele 499508389c core: clear format warnings 2017-11-01 12:35:32 +02:00
bunnei 15c7641bef Merge pull request #2977 from Subv/shmem_create
SharedMemory: Don't take over and unmap the source memory block when creating a shared memory, just reference it
2017-10-03 16:21:49 -04:00
Subv b18589ecf7 Kernel/SharedMemory: Don't take over and unmap the source memory block when creating a shared memory, just reference it.
Also reference the right offset into the backing block for the requested address.
2017-10-02 15:16:16 -05:00
Sebastian Valle 30fabc41c6 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 8217ed7acb Kernel/Thread: Added a helper function to get a thread's command buffer VAddr. 2017-10-01 14:18:35 -05:00
Subv 0a308e224c Kernel/Threads: Add a new thread status that will allow using a Kernel::Event to put a guest thread to sleep inside an HLE handler until said event is signaled. 2017-09-30 11:16:49 -05:00
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 214150f00c Kernel/Memory: Changed GetPhysicalPointer so that it doesn't go through the current process' page table to obtain a pointer. 2017-09-15 14:26:13 -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