summaryrefslogtreecommitdiffstats
path: root/src/core/hle/kernel/process.cpp (follow)
Commit message (Collapse)AuthorAgeFilesLines
* Merge pull request #6196 from bunnei/asserts-settingbunnei2021-04-151-1/+1
|\ | | | | core: settings: Add setting for debug assertions and disable by default.
| * common: Move settings to common from core.bunnei2021-04-151-1/+1
| | | | | | | | - Removes a dependency on core and input_common from common.
* | kernel/process: Replace process resource limit instance with the kernel's resource limitameerj2021-04-121-22/+2
|/ | | | This commit addresses the inaccurate behavior of kernel processes creating their own resource limit, rather than utilizing the kernel's system-wide resource limit instance.
* hle: kernel: KThread: Rework dummy threads & fix memory leak.bunnei2021-03-061-2/+3
| | | | | - Dummy threads are created on thread local storage for all host threads. - Fixes a leak by removing creation of fibers, which are not applicable here.
* hle: kernel: Migrate PageHeap/PageTable to KPageHeap/KPageTable.bunnei2021-02-191-4/+4
|
* hle: kernel: Migrate MemoryManager to KMemoryManager.bunnei2021-02-191-2/+7
|
* hle: kernel: Migrate to KMemoryBlock, KMemoryBlockManager, and others.bunnei2021-02-191-21/+20
|
* kernel: More accurately reserve and release resourcesameerj2021-02-131-1/+2
|
* kernel: KScopedReservation implementationameerj2021-02-131-7/+26
| | | | This implements KScopedReservation, allowing resource limit reservations to be more HW accurate, and release upon failure without requiring too many conditionals.
* kernel: Unify result codes (#5890)Chloe2021-02-131-3/+2
| | | | | | | | | * kernel: Unify result codes Drop the usage of ERR_NAME convention in kernel for ResultName. Removed seperation between svc_results.h & errors.h as we mainly include both most of the time anyways. * oops * rename errors to svc_results
* hle: kernel: svc: Cleanup KEvent/KReadableEvent/KWritableEvent SVCs.bunnei2021-02-051-10/+9
|
* Simplify limitableresource namesChloe Marcec2021-02-031-9/+9
|
* Move to GetGlobalTimeNs, fix GetTotalPhysicalMemoryAvailableChloe Marcec2021-01-301-1/+1
|
* kernel: Rewrite resource limit to be more accurateChloe Marcec2021-01-301-12/+12
| | | | Matches closer to hardware
* hle: kernel: process: Add state lock.bunnei2021-01-291-2/+2
|
* hle: kernel: Recode implementation of KThread to be more accurate.bunnei2021-01-291-1/+73
|
* hle: kernel: KThread: Clean up thread priorities.bunnei2021-01-291-1/+1
|
* hle: kernel: KThread: Fix ThreadType definition.bunnei2021-01-291-2/+1
|
* core: hle: kernel: Rename Thread to KThread.bunnei2021-01-291-7/+7
|
* core: hle: Integrate new KConditionVariable and KAddressArbiter implementations.bunnei2021-01-111-45/+3
|
* hle: kernel: thread: Replace ThreadStatus/ThreadSchedStatus with a single ThreadState.bunnei2021-01-111-2/+2
| | | | - This is how the real kernel works, and is more accurate and simpler.
* core: hle: kernel: Update KSynchronizationObject.bunnei2021-01-111-12/+9
|
* hle: kernel: Migrate to KScopedSchedulerLock.bunnei2020-12-061-4/+4
|
* hle: kernel: Rewrite scheduler implementation based on Mesopshere.bunnei2020-12-061-3/+3
|
* kernel/process: Add missing <ctime> includeMorph2020-10-291-0/+1
| | | | Fixes compilation on MSVC
* kernel: Use the current time as the default RNG seedlat9nq2020-10-271-1/+1
| | | | Use the current time, not zero, as the default RNG seed.
* Revert "core: Fix clang build"bunnei2020-10-211-9/+8
|
* core: Fix clang buildLioncash2020-10-181-8/+9
| | | | | | | Recent changes to the build system that made more warnings be flagged as errors caused building via clang to break. Fixes #4795
* kernel/handle_table: Remove usages of the global system instanceLioncash2020-07-151-1/+1
| | | | | | Removes even more usages of the global system instance, trimming away more dependencies on global variables and making them explicit in the interface.
* configuration: implement per-game configurations (#4098)lat9nq2020-07-101-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * Switch game settings to use a pointer In order to add full per-game settings, we need to be able to tell yuzu to switch to using either the global or game configuration. Using a pointer makes it easier to switch. * configuration: add new UI without changing existing funcitonality The new UI also adds General, System, Graphics, Advanced Graphics, and Audio tabs, but as yet they do nothing. This commit keeps yuzu to the same functionality as originally branched. * configuration: Rename files These weren't included in the last commit. Now they are. * configuration: setup global configuration checkbox Global config checkbox now enables/disables the appropriate tabs in the game properties dialog. The use global configuration setting is now saved to the config, defaulting to true. This also addresses some changes requested in the PR. * configuration: swap to per-game config memory for properties dialog Does not set memory going in-game. Swaps to game values when opening the properties dialog, then swaps back when closing it. Uses a `memcpy` to swap. Also implements saving config files, limited to certain groups of configurations so as to not risk setting unsafe configurations. * configuration: change config interfaces to use config-specific pointers When a game is booted, we need to be able to open the configuration dialogs without changing the settings pointer in the game's emualtion. A new pointer specific to just the configuration dialogs can be used to separate changes to just those config dialogs without affecting the emulation. * configuration: boot a game using per-game settings Swaps values where needed to boot a game. * configuration: user correct config during emulation Creates a new pointer specifically for modifying the configuration while emulation is in progress. Both the regular configuration dialog and the game properties dialog now use the pointer Settings::config_values to focus edits to the correct struct. * settings: split Settings::values into two different structs By splitting the settings into two mutually exclusive structs, it becomes easier, as a developer, to determine how to use the Settings structs after per-game configurations is merged. Other benefits include only duplicating the required settings in memory. * settings: move use_docked_mode to Controls group `use_docked_mode` is set in the input settings and cannot be accessed from the system settings. Grouping it with system settings causes it to be saved with per-game settings, which may make transferring configs more difficult later on, especially since docked mode cannot be set from within the game properties dialog. * configuration: Fix the other yuzu executables and a regression In main.cpp, we have to get the title ID before the ROM is loaded, else the renderer will reflect only the global settings and now the user's game specific settings. * settings: use a template to duplicate memory for each setting Replaces the type of each variable in the Settings::Values struct with a new class that allows basic data reading and writing. The new struct Settings::Setting duplicates the data in memory and can manage global overrides per each setting. * configuration: correct add-ons config and swap settings when apropriate Any add-ons interaction happens directly through the global values struct. Swapping bewteen structs now also includes copying the necessary global configs that cannot be changed nor saved in per-game settings. General and System config menus now update based on whether it is viewing the global or per-game settings. * settings: restore old values struct No longer needed with the Settings::Setting class template. * configuration: implement hierarchical game properties dialog This sets the apropriate global or local data in each setting. * clang format * clang format take 2 can the docker container save this? * address comments and style issues * config: read and write settings with global awareness Adds new functions to read and write settings while keeping the global state in focus. Files now generated per-game are much smaller since often they only need address the global state. * settings: restore global state when necessary Upon closing a game or the game properties dialog, we need to restore all global settings to the original global state so that we can properly open the configuration dialog or boot a different game. * configuration: guard setting values incorrectly This disables setting values while a game is running if the setting is overwritten by a per game setting. * config: don't write local settings in the global config Simple guards to prevent writing the wrong settings in the wrong files. * configuration: add comments, assume less, and clang format No longer assumes that a disabled UI element means the global state is turned off, instead opting to directly answer that question. Still however assumes a game is running if it is in that state. * configuration: fix a logic error Should not be negated * restore settings' global state regardless of accept/cancel Fixes loading a properties dialog and causing the global config dialog to show local settings. * fix more logic errors Fixed the frame limit would set the global setting from the game properties dialog. Also strengthened the Settings::Setting member variables and simplified the logic in config reading (ReadSettingGlobal). * fix another logic error In my efforts to guard RestoreGlobalState, I accidentally negated the IsPowered condition. * configure_audio: set toggle_stretched_audio to tristate * fixed custom rtc and rng seed overwriting the global value * clang format * rebased * clang format take 4 * address my own review Basically revert unintended changes * settings: literal instead of casting "No need to cast, use 1U instead" Thanks, Morph! Co-authored-by: Morph <39850852+Morph1984@users.noreply.github.com> * Revert "settings: literal instead of casting " This reverts commit 95e992a87c898f3e882ffdb415bb0ef9f80f613f. * main: fix status buttons reporting wrong settings after stop emulation * settings: Log UseDockedMode in the Controls group This should have happened when use_docked_mode was moved over to the controls group internally. This just reflects this in the log. * main: load settings if the file has a title id In other words, don't exit if the loader has trouble getting a title id. * use a zero * settings: initalize resolution factor with constructor instead of casting * Revert "settings: initalize resolution factor with constructor instead of casting" This reverts commit 54c35ecb46a29953842614620f9b7de1aa9d5dc8. * configure_graphics: guard device selector when Vulkan is global Prevents the user from editing the device selector if Vulkan is the global renderer backend. Also resets the vulkan_device variable when the users switches back-and-forth between global and Vulkan. * address reviewer concerns Changes function variables to const wherever they don't need to be changed. Sets Settings::Setting to final as it should not be inherited from. Sets ConfigurationShared::use_global_text to static. Co-Authored-By: VolcaEM <volcaem@users.noreply.github.com> * main: load per-game settings after LoadROM This prevents `Restart Emulation` from restoring the global settings *after* the per-game settings were applied. Thanks to BSoDGamingYT for finding this bug. * Revert "main: load per-game settings after LoadROM" This reverts commit 9d0d48c52d2dcf3bfb1806cc8fa7d5a271a8a804. * main: only restore global settings when necessary Loading the per-game settings cannot happen after the ROM is loaded, so we have to specify when to restore the global state. Again thanks to BSoD for finding the bug. * configuration_shared: address reviewer concerns except operator overrides Dropping operator override usage in next commit. Co-Authored-By: LC <lioncash@users.noreply.github.com> * settings: Drop operator overrides from Setting template Requires using GetValue and SetValue explicitly. Also reverts a change that broke title ID formatting in the game properties dialog. * complete rebase * configuration_shared: translate "Use global configuration" Uses ConfigurePerGame to do so, since its usage, at least as of now, corresponds with ConfigurationShared. * configure_per_game: address reviewer concern As far as I understand, it prevents the program from unnecessarily copying strings. Co-Authored-By: LC <lioncash@users.noreply.github.com> Co-authored-by: Morph <39850852+Morph1984@users.noreply.github.com> Co-authored-by: VolcaEM <volcaem@users.noreply.github.com> Co-authored-by: LC <lioncash@users.noreply.github.com>
* Process: Protect TLS region and Modules.Fernando Sahmkow2020-06-271-0/+4
|
* SVC: Correct WaitSynchronization, WaitProcessWideKey, SignalProcessWideKey.Fernando Sahmkow2020-06-271-1/+0
|
* SVC: Correct SignalEvent, ClearEvent, ResetSignal, WaitSynchronization, CancelSynchronization, ArbitrateLockFernando Sahmkow2020-06-271-0/+1
|
* General: Recover Prometheus project from harddrive failure Fernando Sahmkow2020-06-271-6/+11
| | | | | | | This commit: Implements CPU Interrupts, Replaces Cycle Timing for Host Timing, Reworks the Kernel's Scheduler, Introduce Idle State and Suspended State, Recreates the bootmanager, Initializes Multicore system.
* kernel: Account for system resource size for memory usageDavid Marcec2020-06-101-2/+4
| | | | GetTotalPhysicalMemoryAvailableWithoutSystemResource & GetTotalPhysicalMemoryUsedWithoutSystemResource seem to subtract the resource size from the usage.
* kernel: process: Updates for new VMM.bunnei2020-04-171-61/+124
|
* core: memory: Move to Core::Memory namespace.bunnei2020-04-171-6/+7
| | | | - helpful to disambiguate Kernel::Memory namespace.
* process: SetupMainThread: Zero out argument on process start.bunnei2020-04-171-0/+2
|
* core: Implement separate A32/A64 ARM interfaces.bunnei2020-03-031-1/+2
|
* Kernel: Refactor synchronization to better match REFernando Sahmkow2020-02-111-1/+1
|
* Kernel: Change WaitObject to Synchronization object. In order to better reflect RE.Fernando Sahmkow2020-02-111-1/+1
|
* core/kernel: Fix GetTotalPhysicalMemoryUsed.Markus Wick2020-01-111-2/+2
| | | | | | | | | module._memory was already moved over to a new shared_ptr. So code_memory_size was not increased at all. This lowers the heap space and so saves a bit of memory, usually between 50 to 100 MB. This fixes a regression of c0a01f3adc466d07fc27020048e82cca60988970
* kernel: Replace usage of boost::intrusive_ptr with std::shared_ptr for kernel objects. (#3154)bunnei2019-11-251-16/+17
| | | | | | * kernel: Replace usage of boost::intrusive_ptr with std::shared_ptr for kernel objects. - See https://github.com/citra-emu/citra/pull/4710 for details.
* Kernel: Optimize condition variable threads management.Fernando Sahmkow2019-11-211-21/+17
|
* Kernel: Correct behavior of Condition Variables to be more similar to real hardware.Fernando Sahmkow2019-11-211-0/+46
| | | | | | | This commit ensures cond var threads act exactly as they do in the real console. The original implementation uses an RBTree and the behavior of cond var threads is that at the same priority level they act like a FIFO.
* Correct compiling errors and addapt to the new interface.Fernando Sahmkow2019-10-151-4/+1
|
* VM_Manager: Align allocated memory to 256bytesFernando Sahmkow2019-07-191-3/+3
| | | | | | This commit ensures that all backing memory allocated for the Guest CPU is aligned to 256 bytes. This due to how gpu memory works and the heavy constraints it has in the alignment of physical memory.
* Merge pull request #2687 from lioncash/tls-processbunnei2019-07-181-11/+18
|\ | | | | kernel/process: Allocate the process' TLS region during initialization
| * kernel/process: Allocate the process' TLS region during initializationLioncash2019-07-071-0/+5
| | | | | | | | | | | | | | | | | | | | | | Prior to execution within a process beginning, the process establishes its own TLS region for uses (as far as I can tell) related to exception handling. Now that TLS creation was decoupled from threads themselves, we can add this behavior to our Process class. This is also good, as it allows us to remove a stub within svcGetInfo, namely querying the address of that region.
| * kernel/process: Move main thread stack allocation to its own functionLioncash2019-07-071-12/+14
| | | | | | | | Keeps this particular set of behavior isolated to its own function.
* | clang-format fixesMichael Scire2019-07-071-1/+2
| |
* | address review commentaryMichael Scire2019-07-071-9/+5
| |
* | Implement MapPhysicalMemory/UnmapPhysicalMemoryMichael Scire2019-07-071-0/+1
|/ | | | | | | | | | | | | | | | | | | | | | | | | | This implements svcMapPhysicalMemory/svcUnmapPhysicalMemory for Yuzu, which can be used to map memory at a desired address by games since 3.0.0. It also properly parses SystemResourceSize from NPDM, and makes information available via svcGetInfo. This is needed for games like Super Smash Bros. and Diablo 3 -- this PR's implementation does not run into the "ASCII reads" issue mentioned in the comments of #2626, which was caused by the following bugs in Yuzu's memory management that this PR also addresses: * Yuzu's memory coalescing does not properly merge blocks. This results in a polluted address space/svcQueryMemory results that would be impossible to replicate on hardware, which can lead to game code making the wrong assumptions about memory layout. * This implements better merging for AllocatedMemoryBlocks. * Yuzu's implementation of svcMirrorMemory unprotected the entire virtual memory range containing the range being mirrored. This could lead to games attempting to map data at that unprotected range/attempting to access that range after yuzu improperly unmapped it. * This PR fixes it by simply calling ReprotectRange instead of Reprotect.
* kernel/process: Decouple TLS handling from threadsLioncash2019-07-041-45/+90
| | | | | | | | | | | Extracts out all of the thread local storage management from thread instances themselves and makes the owning process handle the management of the memory. This brings the memory management slightly more in line with how the kernel handles these allocations. Furthermore, this also makes the TLS page management a little more readable compared to the lingering implementation that was carried over from Citra.
* kernel: Differentiate kernel and user processes when picking IDZach Hilman2019-06-101-2/+4
| | | | This allows kernel internal type processes to be assigned IDs in the KIP range while userland processes are assigned in the user range.
* Merge pull request #2571 from lioncash/refZach Hilman2019-06-101-1/+1
|\ | | | | kernel/process: Make Create()'s name parameter be taken by value
| * kernel/process: Make Create()'s name parameter be taken by valueLioncash2019-06-101-1/+1
| | | | | | | | | | Makes the interface more flexible in terms of how Create() may be called, while still allowing the parameter itself to be moved into.
* | kernel/svc: Implement TotalMemoryUsedWithoutMmHeap/TotalMemoryAvailableWithoutMmHeapLioncash2019-06-101-0/+16
|/ | | | | | | | | Given we don't currently implement the personal heap yet, the existing memory querying functions are essentially doing what the memory querying types introduced in 6.0.0 do. So, we can build the necessary machinery over the top of those and just use them as part of info types.
* Merge pull request #2412 from lioncash/systembunnei2019-04-291-1/+2
|\ | | | | kernel/vm_manager: Remove usages of global system accessors
| * kernel/vm_manager: Remove usages of global system accessorsLioncash2019-04-171-1/+2
| | | | | | | | | | Makes the dependency on the system instance explicit within VMManager's interface.
* | Merge pull request #2416 from lioncash/waitbunnei2019-04-251-2/+1
|\ \ | | | | | | kernel/svc: Clean up wait synchronization related functionality
| * | kernel/thread: Unify wait synchronization typesLioncash2019-04-171-2/+1
| |/ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This is a holdover from Citra, where the 3DS has both WaitSynchronization1 and WaitSynchronizationN. The switch only has one form of wait synchronizing (literally WaitSynchonization). This allows us to throw out code that doesn't apply at all to the Switch kernel. Because of this unnecessary dichotomy within the wait synchronization utilities, we were also neglecting to properly handle waiting on multiple objects. While we're at it, we can also scrub out any lingering references to WaitSynchronization1/WaitSynchronizationN in comments, and change them to WaitSynchronization (or remove them if the mention no longer applies).
* | Merge pull request #2374 from lioncash/pagetablebunnei2019-04-201-11/+6
|\ \ | | | | | | core: Reorganize boot order
| * | core/core: Move process execution start to System's Load()Lioncash2019-04-121-6/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | This gives us significantly more control over where in the initialization process we start execution of the main process. Previously we were running the main process before the CPU or GPU threads were initialized (not good). This amends execution to start after all of our threads are properly set up.
| * | core/process: Remove unideal page table setting from LoadFromMetadata()Lioncash2019-04-121-5/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Initially required due to the split codepath with how the initial main process instance was initialized. We used to initialize the process like: Init() { main_process = Process::Create(...); kernel.MakeCurrentProcess(main_process.get()); } Load() { const auto load_result = loader.Load(*kernel.GetCurrentProcess()); if (load_result != Loader::ResultStatus::Success) { // Handle error here. } ... } which presented a problem. Setting a created process as the main process would set the page table for that process as the main page table. This is fine... until we get to the part that the page table can have its size changed in the Load() function via NPDM metadata, which can dictate either a 32-bit, 36-bit, or 39-bit usable address space. Now that we have full control over the process' creation in load, we can simply set the initial process as the main process after all the loading is done, reflecting the potential page table changes without any special-casing behavior. We can also remove the cache flushing within LoadModule(), as execution wouldn't have even begun yet during all usages of this function, now that we have the initialization order cleaned up.
| * | core/cpu_core_manager: Create threads separately from initialization.Lioncash2019-04-121-1/+1
| |/ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Our initialization process is a little wonky than one would expect when it comes to code flow. We initialize the CPU last, as opposed to hardware, where the CPU obviously needs to be first, otherwise nothing else would work, and we have code that adds checks to get around this. For example, in the page table setting code, we check to see if the system is turned on before we even notify the CPU instances of a page table switch. This results in dead code (at the moment), because the only time a page table switch will occur is when the system is *not* running, preventing the emulated CPU instances from being notified of a page table switch in a convenient manner (technically the code path could be taken, but we don't emulate the process creation svc handlers yet). This moves the threads creation into its own member function of the core manager and restores a little order (and predictability) to our initialization process. Previously, in the multi-threaded cases, we'd kick off several threads before even the main kernel process was created and ready to execute (gross!). Now the initialization process is like so: Initialization: 1. Timers 2. CPU 3. Kernel 4. Filesystem stuff (kind of gross, but can be amended trivially) 5. Applet stuff (ditto in terms of being kind of gross) 6. Main process (will be moved into the loading step in a following change) 7. Telemetry (this should be initialized last in the future). 8. Services (4 and 5 should ideally be alongside this). 9. GDB (gross. Uses namespace scope state. Needs to be refactored into a class or booted altogether). 10. Renderer 11. GPU (will also have its threads created in a separate step in a following change). Which... isn't *ideal* per-se, however getting rid of the wonky intertwining of CPU state initialization out of this mix gets rid of most of the footguns when it comes to our initialization process.
* / kernel/thread: Remove unused guest_handle member variableLioncash2019-04-141-3/+2
|/ | | | | | This member variable is entirely unused. It was only set but never actually utilized. Given that, we can remove it to get rid of noise in the thread interface.
* kernel/process: Set page table when page table resizes occur.Lioncash2019-04-091-0/+2
| | | | | | | | | We need to ensure dynarmic gets a valid pointer if the page table is resized (the relevant pointers would be invalidated in this scenario). In this scenario, the page table can be resized depending on what kind of address space is specified within the NPDM metadata (if it's present).
* kernel: Handle page table switching within MakeCurrentProcess()Lioncash2019-04-071-3/+0
| | | | | Centralizes the page table switching to one spot, rather than making calling code deal with it everywhere.
* Merge pull request #2314 from lioncash/constbunnei2019-04-031-1/+1
|\ | | | | kernel/thread: Minor interface cleanup
| * kernel/wait_object: Make ShouldWait() take thread members by pointer-to-constLioncash2019-04-021-1/+1
| | | | | | | | | | Given this is intended as a querying function, it doesn't make sense to allow the implementer to modify the state of the given thread.
* | kernel/svc: Implement svcGetThreadListLioncash2019-04-021-0/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | Similarly like svcGetProcessList, this retrieves the list of threads from the current process. In the kernel itself, a process instance maintains a list of threads, which are used within this function. Threads are registered to a process' thread list at thread initialization, and unregistered from the list upon thread destruction (if said thread has a non-null owning process). We assert on the debug event case, as we currently don't implement kernel debug objects.
* | process: Fix up compilationReinUsesLisp2019-04-021-1/+1
| |
* | Merge pull request #2281 from lioncash/memorybunnei2019-04-021-2/+4
|\ \ | |/ |/| kernel/codeset: Make CodeSet's memory data member a regular std::vector
| * kernel/codeset: Make CodeSet's memory data member a regular std::vectorLioncash2019-03-221-2/+4
| | | | | | | | | | | | | | | | | | | | | | The use of a shared_ptr is an implementation detail of the VMManager itself when mapping memory. Because of that, we shouldn't require all users of the CodeSet to have to allocate the shared_ptr ahead of time. It's intended that CodeSet simply pass in the required direct data, and that the memory manager takes care of it from that point on. This means we just do the shared pointer allocation in a single place, when loading modules, as opposed to in each loader.
* | kernel/process: Report total physical memory used to svcGetInfoLioncash2019-03-291-0/+4
| | | | | | | | | | | | | | Reports the (mostly) correct size through svcGetInfo now for queries to total used physical memory. This still doesn't correctly handle memory allocated via svcMapPhysicalMemory, however, we don't currently handle that case anyways.
* | kernel/process: Store the total size of the code memory loadedLioncash2019-03-291-0/+2
| | | | | | | | | | This will be necessary to properly report the used memory size in svcGetInfo.
* | kernel/process: Store the main thread stack size to a data memberLioncash2019-03-281-4/+4
| | | | | | | | | | This will be necessary in order to properly report memory usage within svcGetInfo.
* | kernel/process: Make Run's stack size parameter a u64Lioncash2019-03-281-1/+1
| | | | | | | | | | | | This will make operating with the process-related SVC commands much nicer in the future (the parameter representing the stack size in svcStartProcess is a 64-bit value).
* | kernel/process: Ensure that given stack size is always page-alignedLioncash2019-03-281-0/+4
|/ | | | | The kernel always makes sure that the given stack size is aligned to page boundaries.
* Merge pull request #2234 from lioncash/mutexbunnei2019-03-221-1/+2
|\ | | | | core/hle/kernel: Make Mutex a per-process class.
| * core/hle/kernel: Make Mutex a per-process class.Lioncash2019-03-151-1/+2
| | | | | | | | | | | | | | Makes it an instantiable class like it is in the actual kernel. This will also allow removing reliance on global accessors in a following change, now that we can encapsulate a reference to the system instance in the class.
* | kernel/vm_manager: Rename CodeStatic/CodeMutable to Code and CodeData respectivelyLioncash2019-03-211-3/+3
| | | | | | | | | | | | | | Makes it more evident that one is for actual code and one is for actual data. Mutable and static are less than ideal terms here, because read-only data is technically not mutable, but we were mapping it with that label.
* | kernel/process: Make MapSegment lambda reference parameter constLioncash2019-03-201-1/+1
| | | | | | | | The segment itself isn't actually modified.
* | kernel: Move CodeSet structure to its own source filesLioncash2019-03-201-3/+1
| | | | | | | | | | | | | | | | Given this is utilized by the loaders, this allows avoiding inclusion of the kernel process definitions where avoidable. This also keeps the loading format for all executable data separate from the kernel objects.
* | core: Move PageTable struct into Common.bunnei2019-03-171-1/+1
|/
* kernel/process: Remove use of global system accessorsLioncash2019-03-131-7/+4
| | | | | Now that we pass in a reference to the system instance, we can utilize it to eliminate the global accessors in Process-related code.
* kernel: Make the address arbiter instance per-processLioncash2019-03-081-4/+5
| | | | | | | | | | Now that we have the address arbiter extracted to its own class, we can fix an innaccuracy with the kernel. Said inaccuracy being that there isn't only one address arbiter. Each process instance contains its own AddressArbiter instance in the actual kernel. This fixes that and gets rid of another long-standing issue that could arise when attempting to create more than one process.
* kernel/handle_table: Allow process capabilities to limit the handle table sizeLioncash2019-02-251-1/+7
| | | | | | | | | | The kernel allows restricting the total size of the handle table through the process capability descriptors. Until now, this functionality wasn't hooked up. With this, the process handle tables become properly restricted. In the case of metadata-less executables, the handle table will assume the maximum size is requested, preserving the behavior that existed before these changes.
* Merge pull request #1956 from lioncash/process-threadSebastian Valle2018-12-311-2/+31
|\ | | | | kernel/process: Start the main thread using the specified ideal core
| * kernel/process: Start the main thread using the specified ideal coreLioncash2018-12-281-2/+2
| | | | | | | | | | This matches kernel behavior in that processes are started using their specified ideal core, rather than always starting on core 0.
| * kernel: Rename 'default' CPU core to 'ideal' coreLioncash2018-12-281-1/+1
| | | | | | | | | | | | This makes the naming more closely match its meaning. It's just a preferred core, not a required default core. This also makes the usages of this term consistent across the thread and process implementations.
| * kernel/thread: Move process thread initialization into process.cppLioncash2018-12-281-1/+30
| | | | | | | | | | | | | | | | | | | | This function isn't a general purpose function that should be exposed to everything, given it's specific to initializing the main thread for a Process instance. Given that, it's a tad bit more sensible to place this within process.cpp, which keeps it visible only to the code that actually needs it.
* | kernel/process: Remove most allocation functions from Process' interfaceLioncash2018-12-281-16/+0
|/ | | | | | | | | | | | | | | In all cases that these functions are needed, the VMManager can just be retrieved and used instead of providing the same functions in Process' interface. This also makes it a little nicer dependency-wise, since it gets rid of cases where the VMManager interface was being used, and then switched over to using the interface for a Process instance. Instead, it makes all accesses uniform and uses the VMManager instance for all necessary tasks. All the basic memory mapping functions did was forward to the Process' VMManager instance anyways.
* kernel/process: Hook up the process capability parser to the process itselfLioncash2018-12-211-75/+5
| | | | | While we're at it, we can also toss out the leftover capability parsing from Citra.
* vm_manager: Amend MemoryState enum membersLioncash2018-12-121-1/+1
| | | | | | | | Amends the MemoryState enum to use the same values like the actual kernel does. Also provides the necessary operators to operate on them. This will be necessary in the future for implementing svcSetMemoryAttribute, as memory block state is checked before applying the attribute.
* Merge pull request #1872 from lioncash/proc-infoHexagon122018-12-101-0/+1
|\ | | | | kernel/process: Set ideal core from metadata
| * kernel/process: Set ideal core from metadataLioncash2018-12-051-0/+1
| | | | | | | | | | A very trivial change. If metadata is available, the process should use it to retrieve the desired core for the process to run on.
* | kernel/process: Make Process a WaitObjectLioncash2018-12-051-3/+39
|/ | | | | | | Process instances can be waited upon for state changes. This is also utilized by svcResetSignal, which will be modified in an upcoming change. This simply puts all of the WaitObject related machinery in place.
* kernel/svc: Implement the resource limit svcGetInfo optionLioncash2018-12-041-0/+4
| | | | | Allows a process to register the resource limit as part of its handle table.
* kernel/process: Move <random> include to the cpp fileLioncash2018-11-201-0/+1
| | | | | | <random> isn't necesary directly within the header and can be placed in the cpp file where its needed. Avoids propagating random generation utilities via a header file.
* kernel/resource_limit: Clean up interfaceLioncash2018-11-201-1/+1
| | | | | | | | | | | | | Cleans out the citra/3DS-specific implementation details that don't apply to the Switch. Sets the stage for implementing ResourceLimit instances properly. While we're at it, remove the erroneous checks within CreateThread() and SetThreadPriority(). While these are indeed checked in some capacity, they are not checked via a ResourceLimit instance. In the process of moving out Citra-specifics, this also replaces the system ResourceLimit instance's values with ones from the Switch.
* ldr_ro: Add error check for memory allocation failureZach Hilman2018-11-181-2/+2
|
* Merge pull request #1679 from DarkLordZach/deterministic-rng-2bunnei2018-11-141-0/+6
|\ | | | | svc: Use proper random entropy generation algorithm
| * svc: Use proper random entropy generation algorithmZach Hilman2018-11-131-0/+6
| |
* | kernel/process: Migrate heap-related memory management out of the process class and into the vm managerLioncash2018-11-131-73/+3
|/ | | | | Avoids a breach of responsibilities in the interface and keeps the direct code for memory management within the VMManager class.
* process: LoadModule should clear JIT instruction cache.bunnei2018-10-261-0/+6
|
* core_cpu: Make Cpu scheduler instances unique_ptrs instead of shared_ptrsLioncash2018-10-151-5/+5
|
* kernel/process: Make CodeSet a regular non-inherited objectLioncash2018-10-121-15/+9
| | | | | | | | These only exist to ferry data into a Process instance and end up going out of scope quite early. Because of this, we can just make it a plain struct for holding things and just std::move it into the relevant function. There's no need to make this inherit from the kernel's Object type.
* kernel/thread: Make all instance variables privateLioncash2018-10-041-3/+3
| | | | | | | | | | | | | | | | | | | | Many of the member variables of the thread class aren't even used outside of the class itself, so there's no need to make those variables public. This change follows in the steps of the previous changes that made other kernel types' members private. The main motivation behind this is that the Thread class will likely change in the future as emulation becomes more accurate, and letting random bits of the emulator access data members of the Thread class directly makes it a pain to shuffle around and/or modify internals. Having all data members public like this also makes it difficult to reason about certain bits of behavior without first verifying what parts of the core actually use them. Everything being public also generally follows the tendency for changes to be introduced in completely different translation units that would otherwise be better introduced as an addition to the Thread class' public interface.
* kernel/process: Add a data member to determine if a process is 64-bit or not.Lioncash2018-09-301-0/+1
| | | | | | | | | | | This will be necessary for the implementation of svcGetThreadContext(), as the kernel checks whether or not the process that owns the thread that has it context being retrieved is a 64-bit or 32-bit process. If the process is 32-bit, then the upper 15 general-purpose registers and upper 16 vector registers are cleared to zero (as AArch32 only has 15 GPRs and 16 128-bit vector registers. not 31 general-purpose registers and 32 128-bit vector registers like AArch64).
* memory: Dehardcode the use of fixed memory range constantsLioncash2018-09-251-10/+10
| | | | | | | | The locations of these can actually vary depending on the address space layout, so we shouldn't be using these when determining where to map memory or be using them as offsets for calculations. This keeps all the memory ranges flexible and malleable based off of the virtual memory manager instance state.
* process/vm_manager: Amend API to allow reading parameters from NPDM metadataLioncash2018-09-241-0/+8
| | | | | | | | | Rather than hard-code the address range to be 36-bit, we can derive the parameters from supplied NPDM metadata if the supplied exectuable supports it. This is the bare minimum necessary for this to be possible. The following commits will rework the memory code further to adjust to this.
* svc: Move most process termination code to its own function within ProcessLioncash2018-09-211-0/+29
| | | | | Reduces the use of Process class members externally and keeps most code related to tearing down a process with the rest of the process code.
* thread/process: Move TLS slot marking/freeing to the process classLioncash2018-09-211-0/+58
| | | | | | Allows making several members of the process class private, it also avoids going through Core::CurrentProcess() just to retrieve the owning process.
* kernel/thread: Use owner_process when setting the page table in SetupMainThread()Lioncash2018-09-211-1/+1
| | | | | | | The owning process of a thread is required to exist before the thread, so we can enforce this API-wise by using a reference. We can also avoid the reliance on the system instance by using that parameter to access the page table that needs to be set.
* Port #4182 from Citra: "Prefix all size_t with std::"fearlessTobi2018-09-151-3/+3
|
* kernel: Eliminate kernel global stateLioncash2018-08-291-29/+11
| | | | | | | | | | | | | | | | | | | | | | As means to pave the way for getting rid of global state within core, This eliminates kernel global state by removing all globals. Instead this introduces a KernelCore class which acts as a kernel instance. This instance lives in the System class, which keeps its lifetime contained to the lifetime of the System class. This also forces the kernel types to actually interact with the main kernel instance itself instead of having transient kernel state placed all over several translation units, keeping everything together. It also has a nice consequence of making dependencies much more explicit. This also makes our initialization a tad bit more correct. Previously we were creating a kernel process before the actual kernel was initialized, which doesn't really make much sense. The KernelCore class itself follows the PImpl idiom, which allows keeping all the implementation details sealed away from everything else, which forces the use of the exposed API and allows us to avoid any unnecessary inclusions within the main kernel header.
* kernel/process: Use accessors instead of class members for referencing segment arrayLioncash2018-08-031-3/+3
| | | | | | | Using member variables for referencing the segments array increases the size of the class in memory for little benefit. The same behavior can be achieved through the use of accessors that just return the relevant segment.
* core/memory: Get rid of 3DS leftoversLioncash2018-08-031-76/+2
| | | | Removes leftover code from citra that isn't needed.
* Rename logging macro back to LOG_*James Rowe2018-07-031-4/+4
|
* general: Make formatting of logged hex values more straightforwardLioncash2018-05-021-1/+1
| | | | | | This makes the formatting expectations more obvious (e.g. any zero padding specified is padding that's entirely dedicated to the value being printed, not any pretty-printing that also gets tacked on).
* core: Replace usages of LOG_GENERIC with new fmt-capable equivalentsLioncash2018-04-271-1/+1
|
* kernel: Migrate logging macros to fmt-compatible onesLioncash2018-04-261-4/+4
|
* memory: Fix stack region.bunnei2018-03-311-2/+3
|
* process: MirrorMemory should use MemoryState::Mapped.bunnei2018-03-171-1/+1
|
* process: Unmap previously allocated heap.bunnei2018-03-161-1/+3
|
* kernel: Move stack region outside of application heap.bunnei2018-03-161-3/+2
|
* process: Fix stack memory state.bunnei2018-03-161-2/+4
|
* MemoryState: Add additional memory states and improve naming.bunnei2018-03-161-3/+3
|
* core: Move process creation out of global state.bunnei2018-03-141-3/+2
|
* Kernel: Store the program id in the Process class instead of the CodeSet class.Subv2018-03-021-5/+3
| | | | There may be many CodeSets per Process, so it's wasteful and overcomplicated to store the program id in each of them.
* svc: Implement svcExitProcess.bunnei2018-01-011-5/+27
|
* svc: Implement svcUnmapMemory.bunnei2017-12-311-0/+4
|
* kernel: Various 64-bit fixes in memory/process/threadbunnei2017-12-291-1/+1
|
* process: Add method to mirror a memory region.bunnei2017-12-291-0/+25
|
* hle: Fix QueryMemory response for MemoryInfo.bunnei2017-10-201-37/+5
|
* Merge remote-tracking branch 'upstream/master' into nxbunnei2017-10-101-1/+2
|\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | # Conflicts: # src/core/CMakeLists.txt # src/core/arm/dynarmic/arm_dynarmic.cpp # src/core/arm/dyncom/arm_dyncom.cpp # src/core/hle/kernel/process.cpp # src/core/hle/kernel/thread.cpp # src/core/hle/kernel/thread.h # src/core/hle/kernel/vm_manager.cpp # src/core/loader/3dsx.cpp # src/core/loader/elf.cpp # src/core/loader/ncch.cpp # src/core/memory.cpp # src/core/memory.h # src/core/memory_setup.h
| * Kernel/Thread: Allow specifying which process a thread belongs to when creating it.Subv2017-09-271-1/+1
| | | | | | | | 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.
* | loader: Various improvements for NSO/NRO loaders.bunnei2017-10-101-3/+3
| |
* | nso: Refactor and allocate .bss section.bunnei2017-09-301-4/+5
| |
* | process: Support loading multiple codesets.bunnei2017-09-301-19/+20
|/
* Kernel: Add comment about the extended linear heap areaYuri Kunde Schlesner2017-06-191-0/+2
|
* Kernel: Centralize error definitions in errors.hYuri Kunde Schlesner2017-05-251-0/+1
|
* Kernel: Map special regions according to ExHeaderYuri Kunde Schlesner2017-05-101-4/+19
| | | | | | | 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.
* Use negative priorities to avoid special-casing the self-includeYuri Kunde Schlesner2016-09-211-1/+1
|
* Remove empty newlines in #include blocks.Emmanuel Gil Peyrot2016-09-211-3/+1
| | | | | | | This makes clang-format useful on those. Also add a bunch of forgotten transitive includes, which otherwise prevented compilation.
* Manually tweak source formatting and then re-run clang-formatYuri Kunde Schlesner2016-09-191-8/+4
|
* Sources: Run clang-format on everything.Emmanuel Gil Peyrot2016-09-181-25/+40
|
* Kernel/SVC: Fixed the register order for svcCreateMemoryBlock.Subv2016-05-131-1/+1
| | | | R0 is used as the last parameter instead of R4.
* Common: Remove Common::make_unique, use std::make_uniqueMerryMage2016-04-051-1/+2
|
* Memory: Do correct Phys->Virt address translation for non-APP linheapYuri Kunde Schlesner2016-03-061-2/+4
|
* BitField: Make trivially copyable and remove assignment operatorMerryMage2016-02-121-1/+1
|
* Kernel: Implement svcGetSystemInfoYuri Kunde Schlesner2015-12-011-0/+6
| | | | | This makes smealum/ctrulib@b96dd51d3349961189d4ab1bc2a5c45deff21c09 work with Citra.
* Kernel: Fix wrong linear heap base on titles using newer kernelsYuri Kunde Schlesner2015-08-281-1/+1
| | | | Typo which sneaked in through review on #1025
* Kernel: Fix assertion failure when ControlMemory is called with size=0Yuri Kunde Schlesner2015-08-271-0/+8
|
* Kernel: Implement svcGetProcessInfo in a basic wayYuri Kunde Schlesner2015-08-161-0/+10
| | | | | This also adds some basic memory usage accounting. These two types are used by Super Smash Bros. during startup.
* Kernel: Add more infrastructure to support different memory layoutsYuri Kunde Schlesner2015-08-161-16/+28
| | | | | | 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.
* Move core/mem_map.{cpp,h} => core/hle/kernel/memory.{cpp,h}Yuri Kunde Schlesner2015-08-161-1/+1
|
* Process: Store kernel compatibility version during loadingYuri Kunde Schlesner2015-08-161-3/+5
|
* Kernel: Properly implement ControlMemory FREE and COMMITYuri Kunde Schlesner2015-08-161-5/+115
|
* VMManager: Make LogLayout log level configurable as a parameterYuri Kunde Schlesner2015-08-161-1/+1
|
* Core: Properly configure address space when loading a binaryYuri Kunde Schlesner2015-07-121-6/+32
| | | | | | 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.
* Merge pull request #772 from lioncash/warnbunnei2015-05-181-3/+3
|\ | | | | core/video_core: Fix a few warnings when compiling on MSVC.
| * process: Get rid of warningsLioncash2015-05-141-3/+3
| | | | | | | | Sign mismatches and "forcing value to bool" warnings.
* | Core/ResourceLimits: Implemented the basic structure of ResourceLimits.Subv2015-05-151-0/+1
| | | | | | | | | | | | 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.
* | Memmap: Re-organize memory function in two filesYuri Kunde Schlesner2015-05-151-1/+1
|/ | | | | | | 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.
* Merge pull request #750 from Subv/process_svcYuri Kunde Schlesner2015-05-121-0/+2
|\ | | | | Core/HLE: Implemented the SVCs GetProcessId and GetProcessIdOfThread
| * Core/HLE: Implemented the SVCs GetProcessId and GetProcessIdOfThreadSubv2015-05-111-0/+2
| |
* | Thread: Correctly set main thread initial stack positionYuri Kunde Schlesner2015-05-111-1/+1
|/
* Common: Remove the BIT macroYuri Kunde Schlesner2015-05-091-2/+2
| | | | | | | When the macro was introduced in 326ec51261299e48de97592631c02523da9c8118 it wasn't noticed that it conflicted in name with a heavily used macro inside of dyncom. This causes some compiler warnings. Since it's only lightly used, it was opted to simply remove the new macro.
* Kernel: Remove unused g_main_thread variableYuri Kunde Schlesner2015-05-091-1/+1
|
* Process: Rename StaticAddressMapping => AddressMappingYuri Kunde Schlesner2015-05-091-3/+3
|
* Process: Use BitField to store process flagsYuri Kunde Schlesner2015-05-091-10/+4
|
* Process: Support parsing of exheader kernel capsYuri Kunde Schlesner2015-05-091-3/+70
|
* Kernel: Introduce skeleton Process class to hold process dataYuri Kunde Schlesner2015-05-091-0/+35