Commit graph

110 commits

Author SHA1 Message Date
Lioncash
d1c7aa8c6c kernel/process: Make CodeSet a regular non-inherited object
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.
2018-10-12 12:07:32 -04:00
Zach Hilman
8a0accfec0 nso/nro: Use default allocation size for arg_data 2018-10-07 14:32:33 -04:00
Zach Hilman
26559da99e cmd: Support passing game arguments from command line
Uses -p (--program) and following string as args.
2018-10-07 14:32:32 -04:00
Zach Hilman
19203e1dc0 nso/nro: Add NSO arguments structure to data section
Only added if arguments string is non-empty and a pass is requested by loader.
2018-10-07 14:30:15 -04:00
Zach Hilman
fc1574a4de nso: Optimize loading of IPS patches
Avoid resource-heavy classes and remove quasi-duplicated code.
2018-10-02 17:03:38 -04:00
Zach Hilman
0b69a38532 nso: Add framework to support patching of uncompressed NSOs 2018-10-01 16:02:50 -04:00
Zach Hilman
6d26c40ebb nso: Replace NSOHeader padding bytes with build ID 2018-10-01 16:01:46 -04:00
Lioncash
9d8f4d934b kernel/process: Make data member variables private
Makes the public interface consistent in terms of how accesses are done
on a process object. It also makes it slightly nicer to reason about the
logic of the process class, as we don't want to expose everything to
external code.
2018-09-30 02:30:01 -04:00
Lioncash
06b47d8e6f loader: Make the Load() function take a process as a regular reference, not a SharedPtr
A process should never require being reference counted in this
situation. If the handle to a process is freed before this function is
called, it's definitely a bug with our lifetime management, so we can
put the requirement in place for the API that the process must be a
valid instance.
2018-09-29 16:00:03 -04:00
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
David
fb0cc94d02 Added support for uncompressed NSOs (#1374)
* Added support for uncompressed NSOs

* Moved compressed section check to NsoHeader
2018-09-21 00:39:30 -04:00
Lioncash
2300f0b951 kernel/thread: Include thread-related enums within the kernel namespace
Previously, these were sitting outside of the Kernel namespace, which
doesn't really make sense, given they're related to the Thread class
which is within the Kernel namespace.
2018-09-13 16:05:57 -04:00
Lioncash
84f855a61d core/core: Replace includes with forward declarations where applicable
The follow-up to 88597535d6, which
replaces most of the includes in the core header with forward declarations.

This makes it so that if any of the headers the core header was
previously including change, then no one will need to rebuild the bulk
of the core, due to core.h being quite a prevalent inclusion.

This should make turnaround for changes much faster for developers.
2018-08-31 16:30:14 -04: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
ea9c1deb5e loader: Remove address mapping remnants from citra
These mappings are leftovers from citra and don't apply to the Switch.
2018-08-14 21:37:03 -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
3bc310cb92 nso: Silence implicit sign conversion warnings 2018-07-19 20:51:15 -04:00
Lioncash
d0dd836d53 nso: Remove unused function ReadSegment() 2018-07-19 20:49:27 -04:00
bunnei
b4e1375e78 Merge pull request #718 from lioncash/read
loader/nso: Check if read succeeded in IdentifyFile() before checking magic value
2018-07-19 16:10:29 -07:00
Lioncash
71dc75b71e loader/nso: Check if read succeeded in IdentifyFile() before checking magic value
We should always assume the filesystem is volatile and check each IO
operation. While we're at it reorganize checks so that early-out errors
are near one another.
2018-07-19 12:43:21 -04:00
Lioncash
b20bac710d loader/nso: Remove unnecessary vector resizes
We can just initialize these vectors directly via their constructor.
2018-07-18 22:26:41 -04:00
Lioncash
0a48b45954 loader/nso: Resolve sign mismatch warnings 2018-07-18 22:26:37 -04:00
Zach Hilman
82150bd5c1 Virtual Filesystem 2: Electric Boogaloo (#676)
* Virtual Filesystem

* Fix delete bug and documentate

* Review fixes + other stuff

* Fix puyo regression
2018-07-18 18:07:11 -07:00
Zach Hilman
753d85fb0c General Filesystem and Save Data Fixes (#670) 2018-07-17 12:42:15 -07:00
Hedges
d8d8be6ac0 More improvements to GDBStub (#653)
* More improvements to GDBStub
- Debugging of threads should work correctly with source and assembly level stepping and modifying registers and memory, meaning threads and callstacks are fully clickable in VS.
- List of modules is available to the client, with assumption that .nro and .nso are backed up by an .elf with symbols, while deconstructed ROMs keep N names.
- Initial support for floating point registers.

* Tidy up as requested in PR feedback

* Tidy up as requested in PR feedback
2018-07-12 20:22:59 -07:00
bunnei
0c22a8d514 Revert "Virtual Filesystem (#597)"
This reverts commit 12e9522b32.
2018-07-07 20:24:51 -07:00
Zach Hilman
12e9522b32 Virtual Filesystem (#597)
* Add VfsFile and VfsDirectory classes

* Finish abstract Vfs classes

* Implement RealVfsFile (computer fs backend)

* Finish RealVfsFile and RealVfsDirectory

* Finished OffsetVfsFile

* More changes

* Fix import paths

* Major refactor

* Remove double const

* Use experimental/filesystem or filesystem depending on compiler

* Port partition_filesystem

* More changes

* More Overhaul

* FSP_SRV fixes

* Fixes and testing

* Try to get filesystem to compile

* Filesystem on linux

* Remove std::filesystem and document/test

* Compile fixes

* Missing include

* Bug fixes

* Fixes

* Rename v_file and v_dir

* clang-format fix

* Rename NGLOG_* to LOG_*

* Most review changes

* Fix TODO

* Guess 'main' to be Directory by filename
2018-07-06 10:51:32 -04:00
James Rowe
e159c550d8 Rename logging macro back to LOG_* 2018-07-02 21:45:47 -04:00
Zach Hilman
a47f36da7b Add support for decrypted NCA files (#567)
* Start to add NCA support in loader

* More nca stuff

* More changes to nca.cpp

* Now identifies decrypted NCA cont.

* Game list fixes and more structs and stuff

* More updates to Nca class

* Now reads ExeFs (i think)

* ACTUALLY LOADS EXEFS!

* RomFS loads and games execute

* Cleanup and Finalize

* plumbing, cleanup and testing

* fix some things that i didnt think of before

* Preliminary Review Changes

* Review changes for bunnei and subv
2018-06-21 11:16:23 -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
324ee31fc3 general: Convert assertion macros over to be fmt-compatible 2018-04-27 10:04:02 -04:00
Lioncash
ff63e4d3fc loader: Move old logging macros over to new fmt-capable ones 2018-04-24 20:22:32 -04:00
Subv
4be07d1090 Kernel: Use 0x2C as default main thread priority for homebrew and lone NRO/NSOs 2018-04-20 21:04:35 -05:00
bunnei
36cdd5a39c memory: Fix stack region. 2018-03-31 16:06:45 -04:00
bunnei
a26561ce20 kernel: Move stack region outside of application heap. 2018-03-16 18:32:23 -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
shinyquagsire23
d5e38de1ec loader: Check error on NPDM load, use TID for CodeSet 2018-02-25 07:41:36 -07:00
Lioncash
0dc7699bf2 nso: Silence formatting specifier warnings 2018-02-14 01:52:55 -05:00
bunnei
9b7e8a2e2b loader: Clean up ctors and includes. 2018-01-20 15:54:17 -05:00
bunnei
f2d6ec1404 loader: Refactor to also pass filepath into IdentifyType. 2018-01-20 14:59:44 -05:00
bunnei
965c2bddb2 nso: Remove code specific to directory loading. 2018-01-20 14:59:42 -05:00
gdkchan
1402e97994 Remove relocation on NSO/NRO 2018-01-17 17:01:10 -03:00
bunnei
64eccfb72b Merge pull request #44 from Rozelette/master
nso: Modify .bss size calculation logic
2018-01-16 17:24:49 -05:00
MerryMage
41bfd994f6 clang-format 2018-01-16 18:05:21 +00:00
Rozlette
2e5806922f nso: Modify .bss size calculation logic 2018-01-16 11:14:36 -06:00
bunnei
7fe337b38d nso: Load subsdk4 if available. 2018-01-15 17:18:24 -05:00
bunnei
182548ec86 yuzu: Update license text to be consistent across project. 2018-01-13 16:22:39 -05:00
bunnei
02dba7283f nso: Always load the filepath specified by the user. 2018-01-07 12:44:36 -05:00