Commit graph

657 commits

Author SHA1 Message Date
Subv
bf232b89f3 Improved the algorithm for GetHighestPriorityReadyThread. 2016-12-06 19:15:32 -05:00
Subv
06b2b80d31 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
708ece3fff 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
728bb5f40b Kernel: Remove the Redirection handle type. 2016-12-05 11:13:22 -05:00
Subv
977039e722 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
44c59feca6 Threading: Added some utility functions and const correctness. 2016-12-04 09:58:36 -05:00
Subv
5bc10a74f6 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
4703561c9e Declare empty ServerSession and ClientSession constructors as default. 2016-12-02 22:58:02 -05:00
Subv
4c4f50dfaf Fixed the rebase mistakes. 2016-11-30 23:28:31 -05:00
Subv
4f2326c8a9 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
d2305d375f 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
edcacd7cdd 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
96df92e98f 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
302ef594a6 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
e8dec36ad5 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
d00d0d61e0 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
bb93931096 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
07fdcf150d Fix typos 2016-10-20 12:26:59 -02:00
wwylele
1dedb87851 move ResetType to kernel.h 2016-09-22 13:52:52 +08:00
wwylele
8b25c12ce8 implement wait tree widget 2016-09-22 13:52:52 +08:00
Yuri Kunde Schlesner
fa5d9d8266 Use negative priorities to avoid special-casing the self-include 2016-09-21 00:15:56 -07:00
Emmanuel Gil Peyrot
1138ec0d49 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
1e4a5da9f4 Manually tweak source formatting and then re-run clang-format 2016-09-18 21:14:25 -07:00
Emmanuel Gil Peyrot
628ed4376a Sources: Run clang-format on everything. 2016-09-18 09:38:01 +09:00
bunnei
acdc361fc0 arm: ResetContext shouldn't be part of ARM_Interface. 2016-09-15 17:49:30 -04:00
Lectem
7df4925923 fix #1942 and adds a few IPC functions for descriptors 2016-08-02 16:45:15 +02:00
Yuri Kunde Schlesner
6bc2f3e2a8 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
2270d7b0f0 Merge pull request #1867 from mailwl/srv-update
srv: Update according 3dbrew
2016-06-28 18:53:10 -04:00
bunnei
198562daa9 Merge pull request #1877 from wwylele/wait-fix-timeout
Thread: update timeout when reruning WaitSynch
2016-06-18 01:08:22 -04:00
Subv
a350b5274f Kernel/SVC: Implemented svcCreatePort. 2016-06-11 08:37:37 -05:00
Subv
d5f8d90e34 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
1cef298ca9 Thread: update timeout when rerunning WaitSynch 2016-06-04 09:27:16 +03:00
mailwl
1aceb1b912 Fix parameter name in EnableNotification 2016-05-31 10:06:00 +03:00
wwylele
5e5f9b099a Switch context on the same thread if necessary 2016-05-30 07:34:53 +03:00
bunnei
ea512df6da Merge pull request #1692 from Subv/rm_getpointer2
Memory: Remove most usages of GetPointer
2016-05-29 21:57:07 -04:00
MerryMage
1d3892255d Memory: Added necessary headers and removed unnecessary header 2016-05-26 18:55:37 +01:00
MerryMage
0352176f4c Kernel/Thread: Remove use of Memory::GetPointer 2016-05-21 11:14:11 -05:00
bunnei
79da3c3d83 Merge pull request #1800 from JayFoxRox/set-fpscr
Set fpscr for new threads
2016-05-17 21:24:57 -04:00
Jannik Vogel
f39adfffe7 Set fpscr for new threads 2016-05-17 08:59:52 +02:00
Subv
057cc2f94f Memory: Fixed a regression caused by #1695 and #1689.
Reserve enough space in the vector that holds the linear heap memory to prevent relocations of the backing memory when growing too much.

Closes #1790
2016-05-14 11:24:19 -05:00
bunnei
8ac23ace82 Merge pull request #1689 from Subv/shmem
Kernel: Implemented shared memory.
2016-05-13 15:33:44 -04:00
bunnei
1302ffa822 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
3421ea5445 HLE/Applets: Give each applet its own block of heap memory, and use that when creating the framebuffer shared memory block. 2016-05-12 20:01:59 -05:00
Subv
d6c25acc6e Kernel: Account for automatically-allocated shared memories in the amount of used linear heap memory. 2016-05-12 20:01:59 -05:00
Subv
d6223cfecd Kernel/SharedMemory: Log an error when Map fails. 2016-05-12 20:01:27 -05:00
Subv
54871800a9 Kernel: Implemented shared memory permissions. 2016-05-12 20:01:26 -05:00
Subv
6e4ff1a857 Kernel/Memory: Remove the Shared Memory region from the legacy memory map. 2016-05-12 20:00:33 -05:00
Subv
b53900a6ab Kernel/SharedMemory: Properly implemented shared memory support.
Applications can request the kernel to allocate a piece of the linear heap for them when creating a shared memory object.
Shared memory areas are now properly mapped into the target processes when calling svcMapMemoryBlock.

Removed the APT Shared Font hack as it is no longer needed.
2016-05-12 20:00:32 -05:00
Subv
b2c771eed7 Kernel/SVC: Fixed the register order for svcCreateMemoryBlock.
R0 is used as the last parameter instead of R4.
2016-05-12 20:00:29 -05:00
bunnei
fe04d0f1cc Merge pull request #1766 from Subv/log_cpu
Kernel/Threading: Warn when a thread can be scheduled in the Syscore (Core 1)
2016-05-08 15:03:08 -04:00