Commit Graph

592 Commits

Author SHA1 Message Date
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
Subv 6d2734a074 Kernel/Memory: Give each Process its own page table.
The loader is in charge of setting the newly created process's page table as the main one during the loading process.
2017-09-10 15:13:41 -05:00
James Rowe 61442d6afb Merge pull request #2839 from Subv/global_kernel_lock
Kernel/HLE: Use a mutex  to synchronize access to the HLE kernel state between the cpu thread and any other possible threads that might touch the kernel (network thread, etc).
2017-08-23 18:17:44 -06:00
bunnei 2bbff9fa96 Merge pull request #2893 from Subv/not_schedule_main_thread
Kernel/Threads: Don't immediately switch to the new main thread when loading a new process.
2017-08-22 17:45:47 -04:00
Subv bca8916cea Kernel/HLE: Use a mutex to synchronize access to the HLE kernel state between the cpu thread and any other possible threads that might touch the kernel (network thread, etc).
This mutex is acquired in SVC::CallSVC, ie, as soon as the guest application enters the HLE kernel, and should be acquired by the aforementioned threads before modifying kernel structures.
2017-08-22 09:30:55 -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
Subv 65f19b51c4 Warnings: Add UNREACHABLE macros to switches that contemplate all possible values. 2017-08-21 08:34:28 -05:00
Weiyi Wang 045d0b5bbd Merge pull request #2799 from yuriks/virtual-cached-range-flush
Add address conversion functions returning optional, Add function to flush virtual region from rasterizer cache
2017-07-22 10:15:52 +03: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 b53fa9514f Kernel/SVC: Pass the current thread as a parameter to ClientSession::SendSyncRequest. 2017-06-29 12:30:34 -05:00
Subv c3c9175a1c Kernel/Sessions: Clean up the list of pending request threads of a session when the client endpoint is closed. 2017-06-25 23:38:29 -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 e192d417ec Kernel: Implement AcceptSession SVC 2017-06-23 11:26:37 -07:00
Yuri Kunde Schlesner 326e7c7020 Memory: Make PhysicalToVirtualAddress return a boost::optional
And fix a few places in the code to take advantage of that.
2017-06-21 22:55:17 -07:00
Yuri Kunde Schlesner f64d0b3f26 Kernel/IPC: Support translation of null handles
Missed this in my first implementation. Thanks to @wwylele for pointing
out that this was missing.
2017-06-21 14:27:03 -07:00
Weiyi Wang c4f0927a62 Merge pull request #2789 from yuriks/misc-kernel
Trivial no-op additions
2017-06-21 20:34:12 +03:00
Yuri Kunde Schlesner b21dfbb295 Merge pull request #2790 from yuriks/remove-movefrom
Remove ResultVal::MoveFrom
2017-06-20 22:04:09 -07: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 90b8d4dd36 Kernel: Add comment about the extended linear heap area 2017-06-18 18:38:40 -07:00
Yuri Kunde Schlesner 0dfafdbe59 Kernel/IPC: Make HLERequestContext usable from outside kernel 2017-06-18 16:05:12 -07:00
Yuri Kunde Schlesner d8f6000f54 Kernel/IPC: Use boost::small_vector for HLE context objects 2017-06-11 16:34:13 -07:00
Yuri Kunde Schlesner 92ca422088 Kernel: Allow clearing request_objects to re-use buffer space
Reduces the necessary allocation to max(in_handles, out_handles) rather
than (in_handles + out_handles).
2017-06-11 13:10:21 -07:00
Yuri Kunde Schlesner 8cb65fe65a Kernel: Basic support for IPC translation for HLE services 2017-06-11 13:10:21 -07:00
Yuri Kunde Schlesner 05fee70211 Kernel: Add methods in HLERequestContext abstracting handle creation 2017-06-11 13:07:33 -07:00
Yuri Kunde Schlesner 20e5abb308 ServiceFramework: Use separate copy of command buffer
Copy the IPC command buffer to/from the request context before/after the
handler is invoked. This is part of a move away from using global data
for handling IPC requests.
2017-06-11 13:07:33 -07:00
Yuri Kunde Schlesner 78398d0978 Merge pull request #2756 from yuriks/service-framework
New service framework
2017-06-08 21:03:03 -07:00
Yuri Kunde Schlesner 838faf147e Session: Remove/add some forward declarations 2017-06-08 00:33:57 -07:00
Yuri Kunde Schlesner d666e01cdf Kernel: Ensure objects are kept alive during ClientSession disconnection
Fixes #2760
2017-06-08 00:33:24 -07:00
Yuri Kunde Schlesner 84c497292a Service: Add new ServiceFramework framework for writing HLE services
The old "Interface" class had a few problems such as using free
functions (Which didn't allow you to write the service handler as if it
were a regular class.) which weren't very extensible. (Only received one
parameter with a pointer to the Interface object.)

The new ServiceFramework aims to solve these problems by working with
member functions and passing a generic context struct as parameter. This
struct can be extended in the future without having to update all
existing service implementations.
2017-06-08 00:11:37 -07:00
Yuri Kunde Schlesner 6dc133c24a Kernel: Remove some unnecessary namespace qualifications 2017-06-06 14:51:42 -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
Yuri Kunde Schlesner be031989ee Kernel: Move HandleTable to a separate file 2017-05-29 17:34:39 -07:00
Yuri Kunde Schlesner 64ecf81a3c Kernel: Move WaitObject to a separate file
Now that HandleTable doesn't directly depend on WaitObject anymore, this
can be separated from the main kernel.h header.
2017-05-29 16:16:46 -07:00
Yuri Kunde Schlesner 9453223075 Kernel: Removed HandleTable::GetWaitObject
This isn't necessary anymore since plain Get works correctly for
WaitObjects.
2017-05-29 15:10:06 -07:00
Yuri Kunde Schlesner b17754f998 Kernel: Extract dynamic Object pointer cast into its own function 2017-05-29 14:42:27 -07:00
Yuri Kunde Schlesner 2cdb40d709 Kernel: Centralize error definitions in errors.h 2017-05-24 21:06:00 -07:00
Yuri Kunde Schlesner cc566dadd8 Merge pull request #2406 from Subv/session_disconnect
Kernel: Properly update port counters on session disconnection.
2017-05-21 17:18:16 -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 ce5bc477ca Kernel: Remove a now unused enum and variable regarding a session's status. 2017-05-15 11:22:16 -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
Yuri Kunde Schlesner f18d454eb6 Kernel: Map special regions according to ExHeader
This replaces the hardcoded VRAM/DSP mappings with ones made based on
the ExHeader ARM11 Kernel caps list. While this has no visible effect
for most applications (since they use a standard set of mappings) it
does improve support for system modules and n3DS exclusives.
2017-05-09 21:44:00 -07:00
Yuri Kunde Schlesner b4a93cfdde DSP: Create backing memory for entire DSP RAM
Also move address space mapping out of video_core.
2017-05-09 21:44:00 -07:00
wwylele 85ba60d5ec Timer: restore missing signaled=true from #2421 2017-02-27 22:49:46 +02:00
B3n30 dcf115778a Fix log entry in timer::signal (#2600) 2017-02-27 11:04:03 -05:00
Mat M 0cb52ee74a Doxygen: Amend minor issues (#2593)
Corrects a few issues with regards to Doxygen documentation, for example:

- Incorrect parameter referencing.
- Missing @param tags.
- Typos in @param tags.

and a few minor other issues.
2017-02-26 17:58:51 -08:00
Yuri Kunde Schlesner b250ce21b9 Merge pull request #2587 from yuriks/status-bar
Replace built-in Profiler with indicators in status bar
2017-02-26 17:51:15 -08:00
Yuri Kunde Schlesner 441f8b5a4b Core: Remove unnecessary include in thread.h 2017-02-26 17:22:01 -08:00
Subv 029a11030e Timers: Immediately signal the timer if it was started with an initial value of 0. 2017-02-21 20:51:54 -05: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 84d72fd92f Merge pull request #2397 from Subv/pulse
Kernel: Implemented Pulse event and timers.
2017-01-10 10:45:00 -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 59f4f1d7ff Merge pull request #2396 from Subv/sema_acquire
Kernel/Semaphore: Fixed a regression in semaphore waits.
2017-01-06 22:00:12 -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 e52ca85711 Kernel: Implemented Pulse event and timers.
Closes #1904
2017-01-05 13:06:17 -05:00
Subv 4251eb26ec Kernel/Semaphore: Fixed a regression in semaphore waits.
The regression was caused by a missing check in #2260.

The new behavior is consistent with the real kernel.
2017-01-05 13:00:05 -05:00
Subv dda4ec93be Kernel: Add some asserts to enforce the invariants in the scheduler. 2017-01-05 09:40:18 -05:00
Subv 7f1dca8cd2 Kernel: Remove a thread from all of its waiting objects' waiting_threads list when it is awoken.
This fixes a potential bug where threads would not get removed from said list if they awoke after waiting with WaitSynchronizationN with wait_all = false
2017-01-05 09:40:15 -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 b6a0355568 Kernel/Mutex: Update a mutex priority when a thread stops waiting on it. 2017-01-04 15:58:47 -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
Subv 38a90882a4 Kernel/Synch: Do not attempt a reschedule on every syscall.
Not all syscalls should cause reschedules, this commit attempts to remedy that, however, it still does not cover all cases.
2017-01-04 15:58:44 -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
wwylele 4c9b80cee3 Kernel: remove object's waiting thread if it is dead 2016-12-16 12:33:18 +02:00
bunnei cda7210fad Merge pull request #2260 from Subv/scheduling
Threading: Reworked the way our scheduler works.
2016-12-16 00:41:22 -05:00
Subv 016307ae65 Fixed the codestyle to match our clang-format rules. 2016-12-14 12:45:36 -05:00
Subv 5b1edc6ae7 Fixed the codestyle to match our clang-format rules. 2016-12-14 12:35:01 -05: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 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 17b29d8865 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 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 7cde5b83bc Use boost remove_erase_if instead of the erase-remove idiom 2016-12-06 19:31:53 -05:00
Subv 1f286b72a1 Improved the algorithm for GetHighestPriorityReadyThread. 2016-12-06 19:15:32 -05:00
Subv c93c5a72bb 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 00f0c77570 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 29d809b6e1 Kernel: Remove the Redirection handle type. 2016-12-05 11:13:22 -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 bdad00c73f Threading: Added some utility functions and const correctness. 2016-12-04 09:58:36 -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
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 c5e7e0fa26 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 c19afd2118 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 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
Yuri Kunde Schlesner 3174bfd50c 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 1323ab2f5f 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 4ab8692475 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 13d46f6820 Fix typos 2016-10-20 12:26:59 -02:00
wwylele 85a83158fb move ResetType to kernel.h 2016-09-22 13:52:52 +08: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
Lectem a94fb932ff fix #1942 and adds a few IPC functions for descriptors 2016-08-02 16:45:15 +02: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
bunnei 87c07643ff Merge pull request #1867 from mailwl/srv-update
srv: Update according 3dbrew
2016-06-28 18:53:10 -04:00
bunnei 8f86cc4df9 Merge pull request #1877 from wwylele/wait-fix-timeout
Thread: update timeout when reruning WaitSynch
2016-06-18 01:08:22 -04:00
Subv 7b445ddff0 Kernel/SVC: Implemented svcCreatePort. 2016-06-11 08:37:37 -05:00
Subv 3d9fbffbab 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 7d56e88369 Thread: update timeout when rerunning WaitSynch 2016-06-04 09:27:16 +03:00
mailwl e85b22320a Fix parameter name in EnableNotification 2016-05-31 10:06:00 +03:00
wwylele 81d3462a19 Switch context on the same thread if necessary 2016-05-30 07:34:53 +03:00
bunnei ab4b27f0f5 Merge pull request #1692 from Subv/rm_getpointer2
Memory: Remove most usages of GetPointer
2016-05-29 21:57:07 -04:00
MerryMage 80abe6eb08 Memory: Added necessary headers and removed unnecessary header 2016-05-26 18:55:37 +01:00
MerryMage 1ebaaf9bb1 Kernel/Thread: Remove use of Memory::GetPointer 2016-05-21 11:14:11 -05:00
bunnei a39144050b Merge pull request #1800 from JayFoxRox/set-fpscr
Set fpscr for new threads
2016-05-17 21:24:57 -04:00
Jannik Vogel af37dd0d52 Set fpscr for new threads 2016-05-17 08:59:52 +02:00
Subv 64da2bf0cd 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 18b517e236 Merge pull request #1689 from Subv/shmem
Kernel: Implemented shared memory.
2016-05-13 15:33:44 -04: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 ac2de12ed8 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 d261984f54 Kernel: Account for automatically-allocated shared memories in the amount of used linear heap memory. 2016-05-12 20:01:59 -05:00
Subv 5679d066b5 Kernel/SharedMemory: Log an error when Map fails. 2016-05-12 20:01:27 -05:00
Subv 0fb6d2a247 Kernel: Implemented shared memory permissions. 2016-05-12 20:01:26 -05:00
Subv f72bd57212 Kernel/Memory: Remove the Shared Memory region from the legacy memory map. 2016-05-12 20:00:33 -05:00
Subv 1bd0cf542f 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 42a50da76b 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 282a2ad539 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
Subv 5b7f86708c Kernel/Threading: Warn when a thread can be scheduled in the Syscore (Core 1).
We do not currently implement any cores other than the AppCore (Core 0).
2016-05-07 10:23:03 -05: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
bunnei 75cbfeee58 Merge pull request #1762 from bunnei/global
hle: Get rid of direct global access to g_reschedule
2016-05-05 21:45:57 -04:00
Mathew Maidment aa6380e5bc Merge pull request #1643 from MerryMage/make_unique
Common: Remove Common::make_unique, use std::make_unique
2016-04-05 20:10:11 -04:00
MerryMage a06dcfeb61 Common: Remove Common::make_unique, use std::make_unique 2016-04-05 13:31:17 +01:00
Lioncash 04f8d39a96 session: Make helper functions constexpr 2016-03-21 04:07:03 -04: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
Lioncash 856a1d0386 svc: Move ResetType enum to the kernel event header 2016-03-12 21:47:41 -05:00
Lioncash 12e92f17de svc: Make ResetType an enum class 2016-03-12 15:06:31 -05:00
Yuri Kunde Schlesner 6aa90e13f9 Memory: Do correct Phys->Virt address translation for non-APP linheap 2016-03-05 22:09:59 -08:00
MerryMage 8b00954ec7 AudioCore: Skeleton Implementation
This commit:
* Adds a new subproject, audio_core.
* Defines structures that exist in DSP shared memory.
* Hooks up various other parts of the emulator into audio core.

This sets the foundation for a later HLE DSP implementation.
2016-02-21 13:13:52 +00:00
MerryMage 6c71858c5c BitField: Make trivially copyable and remove assignment operator 2016-02-12 19:51:16 +00:00
MerryMage 2b93313348 Memory: Implement MMIO 2016-01-30 18:41:04 +00:00
Subv d90d5a0ee6 HLE/SVC: Implement UnmapMemoryBlock.
This implementation will need to be (almost completely) changed when we implement multiprocess support.
2016-01-14 11:29:19 -05:00
Subv 6cccc36505 HLE/Timers: Reset OneShot timers when they are acquired instead of when they're triggered.
Closes #1139
2015-12-29 20:35:25 -05: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
Lioncash 751fbfdcc3 general: Silence some warnings when using clang 2015-09-16 08:51:53 -04:00
Lioncash d3efa637b4 General: Fix up doxygen comments 2015-09-10 11:20:21 -04:00
Yuri Kunde Schlesner 0ee3e2c25e Kernel: Fix wrong linear heap base on titles using newer kernels
Typo which sneaked in through review on #1025
2015-08-27 23:52:40 -03:00
Yuri Kunde Schlesner 12390eb155 Kernel: Fix assertion failure when ControlMemory is called with size=0 2015-08-26 21:29:05 -03:00
Yuri Kunde Schlesner 687d973980 Core: Improve APT Shared Font hack
Should fix invalid read loops in some games
2015-08-26 21:28:58 -03:00
Yuri Kunde Schlesner 840b85690b Kernel: Remove unused legacy heap MapBlock_* functions 2015-08-16 01:03:49 -03: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
Yuri Kunde Schlesner 74d4bc0af1 Kernel: Add more infrastructure to support different memory layouts
This adds some structures necessary to support multiple memory regions
in the future. It also adds support for different system memory types
and the new linear heap mapping at 0x30000000.
2015-08-16 01:03:47 -03:00
Yuri Kunde Schlesner 69c3021a8d Move core/mem_map.{cpp,h} => core/hle/kernel/memory.{cpp,h} 2015-08-16 01:03:46 -03:00
Yuri Kunde Schlesner e2c7954be5 Memory: Move address type conversion routines to memory.cpp/h
These helpers aren't really part of the kernel, and mem_map.cpp/h is
going to be moved there next.
2015-08-16 01:03:46 -03:00
Yuri Kunde Schlesner a12a30c9e0 Process: Store kernel compatibility version during loading 2015-08-16 01:03:45 -03:00
Yuri Kunde Schlesner cdeeecf080 Kernel: Properly implement ControlMemory FREE and COMMIT 2015-08-16 01:03:45 -03:00
Yuri Kunde Schlesner 306408d174 VMManager: Introduce names for used ResultCodes 2015-08-16 01:03:44 -03:00
Yuri Kunde Schlesner b9a9ad9742 VMManager: Make LogLayout log level configurable as a parameter 2015-08-16 01:03:43 -03:00
Yuri Kunde Schlesner 785407d06f VMManager: Change block offsets to size_t 2015-08-16 01:03:43 -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 b6719ec922 Merge pull request #921 from linkmauve/fix-applet
Fix applet includes using iwyu
2015-07-12 17:25:55 -04:00
Yuri Kunde Schlesner d4f35fd989 Kernel: Add CodeSet case to Object::IsWaitable 2015-07-12 18:15:16 -03:00
Emmanuel Gil Peyrot fe909b3b5a Core: Fix applet includes using iwyu. 2015-07-12 22:10:37 +01:00
Yuri Kunde Schlesner 5c5cf2f8e0 Core: Properly configure address space when loading a binary
The code now properly configures the process image to match the loaded
binary segments (code, rodata, data) instead of just blindly allocating
a large chunk of dummy memory.
2015-07-11 23:54:42 -03:00
Yuri Kunde Schlesner d9556912b4 Kernel: Remove unused member from Event 2015-07-11 23:49:51 -03:00
Emmanuel Gil Peyrot e5fcabdd69 Core: Cleanup file_sys includes. 2015-06-28 00:36:54 +01:00
Emmanuel Gil Peyrot aea15f5c73 Core: Cleanup core includes. 2015-06-28 00:36:54 +01:00
Emmanuel Gil Peyrot 596b7c4f63 Common: Cleanup key_map includes. 2015-06-28 00:36:54 +01:00
Yuri Kunde Schlesner 81488d7a6a Add helpers to create IPC command buffer headers and descriptors 2015-06-22 19:24:19 -03:00
bunnei 71e8822d23 kernel: Fix svcWaitSynch to always acquire requested wait objects. 2015-06-16 22:34:39 -04:00
Yuri Kunde Schlesner 8a04c65e20 Merge pull request #810 from yuriks/memmap
Kernel: Add VMManager to manage process address spaces
2015-05-29 18:00:17 -07:00
Emmanuel Gil Peyrot b1503b2020 Remove every trailing whitespace from the project (but externals). 2015-05-29 21:59:29 +01:00
Yuri Kunde Schlesner 0a60aa75c2 Kernel: Add VMManager to manage process address spaces
This enables more dynamic management of the process address space,
compared to just directly configuring the page table for major areas.

This will serve as the foundation upon which the rest of the Kernel
memory management functions will be built.
2015-05-27 03:24:12 -03:00
Emmanuel Gil Peyrot b8f93e6b18 Kernel: Fix a warning introduced with ResourceLimit, and remove the fallback code to prevent it from happening again. 2015-05-21 20:54:49 +02:00
bunnei 0b7d2941cf Kernel: Move reschedules from SVCs to actual mechanisms that reschedule. 2015-05-20 18:05:47 -04:00
bunnei f0365f28c2 Merge pull request #772 from lioncash/warn
core/video_core: Fix a few warnings when compiling on MSVC.
2015-05-18 08:08:49 -04:00
Subv d3634d4bf4 Core/ResourceLimits: Implemented the basic structure of ResourceLimits.
Implemented svcs GetResourceLimit, GetResourceLimitCurrentValues and GetResourceLimitLimitValues.

Note that the resource limits do not currently keep track of used objects, since we have no way to distinguish between an object created by the application, and an object created by some HLE module once we're inside Kernel::T::Create.
2015-05-14 22:50:13 -05: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 150e700729 process: Get rid of warnings
Sign mismatches and "forcing value to bool" warnings.
2015-05-14 12:59:14 -04: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 25c010dc7d fixup! 2015-05-11 18:23:45 -05:00
Subv 41f74a16fd Core/HLE: Implemented the SVCs GetProcessId and GetProcessIdOfThread 2015-05-11 09:15:10 -05:00