Commit Graph

65 Commits

Author SHA1 Message Date
Lioncash 577bde60b5 memory: Dehardcode the use of fixed memory range constants
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.
2018-09-24 22:16:03 -04:00
Lioncash 149d3e546a process/vm_manager: Amend API to allow reading parameters from NPDM metadata
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.
2018-09-24 17:24:50 -04:00
Lioncash 6ac6054b7a svc: Move most process termination code to its own function within Process
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.
2018-09-21 06:07:41 -04:00
Lioncash ded89694f7 thread/process: Move TLS slot marking/freeing to the process class
Allows making several members of the process class private, it also
avoids going through Core::CurrentProcess() just to retrieve the owning
process.
2018-09-21 03:50:12 -04:00
Lioncash 018c7cbbe0 kernel/thread: Use owner_process when setting the page table in SetupMainThread()
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.
2018-09-20 21:10:00 -04:00
fearlessTobi 1190ea6ddb Port #4182 from Citra: "Prefix all size_t with std::" 2018-09-15 15:21:06 +02:00
Lioncash 4913549d6b kernel: Eliminate kernel global state
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.
2018-08-28 22:31:51 -04:00
Lioncash 73f162a5b0 kernel/process: Use accessors instead of class members for referencing segment array
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.
2018-08-03 14:45:45 -04:00
Lioncash 3bcf090d37 core/memory: Get rid of 3DS leftovers
Removes leftover code from citra that isn't needed.
2018-08-03 11:22:47 -04:00
James Rowe e159c550d8 Rename logging macro back to LOG_* 2018-07-02 21:45:47 -04:00
Lioncash 1b310cbb3a general: Make formatting of logged hex values more straightforward
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).
2018-05-02 09:49:36 -04:00
Lioncash 44d2f427d4 core: Replace usages of LOG_GENERIC with new fmt-capable equivalents 2018-04-27 11:57:52 -04:00
Lioncash bd9414dd31 kernel: Migrate logging macros to fmt-compatible ones 2018-04-25 20:32:09 -04:00
bunnei 36cdd5a39c memory: Fix stack region. 2018-03-31 16:06:45 -04:00
bunnei dd2e72f1aa process: MirrorMemory should use MemoryState::Mapped. 2018-03-16 19:24:54 -04:00
bunnei d7bb09afe7 process: Unmap previously allocated heap. 2018-03-16 18:32:25 -04:00
bunnei a26561ce20 kernel: Move stack region outside of application heap. 2018-03-16 18:32:23 -04:00
bunnei 67bac363d8 process: Fix stack memory state. 2018-03-16 18:32:21 -04:00
bunnei 29bda49fc0 MemoryState: Add additional memory states and improve naming. 2018-03-16 18:32:21 -04:00
bunnei f16763ed52 core: Move process creation out of global state. 2018-03-14 18:42:19 -04:00
Subv a9c51be95e Kernel: Store the program id in the Process class instead of the CodeSet class.
There may be many CodeSets per Process, so it's wasteful and overcomplicated to store the program id in each of them.
2018-03-01 19:03:53 -05:00
bunnei 37d55a0317 svc: Implement svcExitProcess. 2018-01-01 14:38:34 -05:00
bunnei 3af6ad6bb9 svc: Implement svcUnmapMemory. 2017-12-31 15:22:49 -05:00
bunnei 78531342a4 kernel: Various 64-bit fixes in memory/process/thread 2017-12-29 13:27:58 -05:00
bunnei e74563e0d0 process: Add method to mirror a memory region. 2017-12-28 21:35:49 -05:00
bunnei bf69f3d1eb hle: Fix QueryMemory response for MemoryInfo. 2017-10-19 23:00:46 -04:00
bunnei 775cf60729 Merge remote-tracking branch 'upstream/master' into nx
# 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
2017-10-09 23:56:20 -04:00
bunnei e36ccd5ff1 loader: Various improvements for NSO/NRO loaders. 2017-10-09 21:39:32 -04:00
bunnei 6d3b6e0041 nso: Refactor and allocate .bss section. 2017-09-30 14:33:58 -04:00
bunnei 39308848e3 process: Support loading multiple codesets. 2017-09-30 14:33:11 -04:00
Subv 2e78c05d91 Kernel/Thread: Allow specifying which process a thread belongs to when creating it.
Don't automatically assume that Thread::Create will only be called when the parent process is currently scheduled. This assumption will be broken when applets or system modules are loaded.
2017-09-26 17:40:49 -05:00
Yuri Kunde Schlesner 41376f050a Kernel: Add comment about the extended linear heap area 2017-06-18 18:38:40 -07:00
Yuri Kunde Schlesner 467545ed48 Kernel: Centralize error definitions in errors.h 2017-05-24 21:06:00 -07:00
Yuri Kunde Schlesner 2668c26a68 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 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
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
MerryMage 9f9c987924 Common: Remove Common::make_unique, use std::make_unique 2016-04-05 13:31:17 +01:00
Yuri Kunde Schlesner 46dc35ae20 Memory: Do correct Phys->Virt address translation for non-APP linheap 2016-03-05 22:09:59 -08:00
MerryMage 867c111e99 BitField: Make trivially copyable and remove assignment operator 2016-02-12 19:51:16 +00:00
Yuri Kunde Schlesner 5bed732b03 Kernel: Implement svcGetSystemInfo
This makes smealum/ctrulib@b96dd51d33 work
with Citra.
2015-11-30 19:49:44 -08:00
Yuri Kunde Schlesner 6bef26d764 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 990ff3f241 Kernel: Fix assertion failure when ControlMemory is called with size=0 2015-08-26 21:29:05 -03:00
Yuri Kunde Schlesner 00e9d19f28 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 e34643a3e4 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 6bb23baf0a Move core/mem_map.{cpp,h} => core/hle/kernel/memory.{cpp,h} 2015-08-16 01:03:46 -03:00
Yuri Kunde Schlesner 521cb56792 Process: Store kernel compatibility version during loading 2015-08-16 01:03:45 -03:00
Yuri Kunde Schlesner 8850ade24d Kernel: Properly implement ControlMemory FREE and COMMIT 2015-08-16 01:03:45 -03:00