Commit Graph

5403 Commits

Author SHA1 Message Date
Lioncash f2331a804a core/cpu_core_manager: Create threads separately from initialization.
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.
2019-04-11 22:11:40 -04:00
bunnei 83a2fb3c3a
Merge pull request #2360 from lioncash/svc-global
kernel/svc: Deglobalize the supervisor call handlers
2019-04-11 21:50:05 -04:00
bunnei e2f2155dab
Merge pull request #2388 from lioncash/constexpr
kernel: Make handle type declarations constexpr
2019-04-11 21:49:45 -04:00
Lioncash 6300ccbc3c kernel: Make handle type declarations constexpr
Some objects declare their handle type as const, while others declare it
as constexpr. This makes the const ones constexpr for consistency, and
prevent unexpected compilation errors if these happen to be attempted to be
used within a constexpr context.
2019-04-11 16:34:53 -04:00
Lioncash ca96dc4676 service: Update service function tables
Updates function tables based off information from SwitchBrew.
2019-04-11 02:47:00 -04:00
Lioncash dae2449880 ldr: Mark IsValidNROHash() as a const member function
This doesn't modify instance state, so it can be made const.
2019-04-10 15:57:02 -04:00
Lioncash 0032cf3818 ldr: Amend parameters for LoadNro/UnloadNro LoadNrr/UnloadNrr
The initial two words indicate a process ID. Also UnloadNro only
specifies one address, not two.
2019-04-10 15:56:43 -04:00
Lioncash 8676832064 fsp_srv: Remove unnecessary parameter popping in IDirectory's Read()
IDirectory's Read() function doesn't take any input parameters. It only
uses the output parameters that we already provide.
2019-04-10 13:04:08 -04:00
Lioncash fc436bb09b fsp_srv: Log out option values in IFile's Read and Write functions
These indicate options that alter how a read/write is performed.

Currently we don't need to handle these, as the only one that seems to
be used is for writes, but all the custom options ever seem to do is
immediate flushing, which we already do by default.
2019-04-10 13:01:52 -04:00
Lioncash 08d507a196 kernel/server_session: Remove obsolete TODOs
These are holdovers from Citra.
2019-04-09 23:34:49 -04:00
bunnei 61f63bb994
Merge pull request #1957 from DarkLordZach/title-provider
file_sys: Provide generic interface for accessing game data
2019-04-09 19:16:37 -04:00
Lioncash 2abf979c35 kernel/process: Set page table when page table resizes occur.
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).
2019-04-09 13:00:56 -04:00
zarroboogs be6466d5c0 added a toggle to force 30fps mode 2019-04-09 02:14:03 +03:00
Lioncash b117ca5fce kernel/svc: Deglobalize the supervisor call handlers
Adjusts the interface of the wrappers to take a system reference, which
allows accessing a system instance without using the global accessors.

This also allows getting rid of all global accessors within the
supervisor call handling code. While this does make the wrappers
themselves slightly more noisy, this will be further cleaned up in a
follow-up. This eliminates the global system accessors in the current
code while preserving the existing interface.
2019-04-07 20:30:05 -04:00
bunnei 3c1ce290d0
Merge pull request #2361 from lioncash/pagetable
core/memory: Minor simplifications to page table management
2019-04-07 17:50:31 -04:00
bunnei 52ad5fa0e8
Merge pull request #2356 from lioncash/pair
kernel/{server_port, server_session}: Return pairs instead of tuples from pair creation functions
2019-04-07 17:48:00 -04:00
Lioncash 36a1e6a982 core/memory: Remove unused enum constants
These are holdovers from Citra and can be removed.
2019-04-07 03:04:55 -04:00
Lioncash abae7577d2 core/memory: Remove GetCurrentPageTable()
Now that nothing actually touches the internal page table aside from the
memory subsystem itself, we can remove the accessor to it.
2019-04-07 02:47:37 -04:00
Lioncash a6a82bb004 arm/arm_dynarmic: Remove unnecessary current_page_table member
Given the page table will always be guaranteed to be that of whatever
the current process is, we no longer need to keep this around.
2019-04-07 02:43:51 -04:00
Lioncash e779686a76 kernel: Handle page table switching within MakeCurrentProcess()
Centralizes the page table switching to one spot, rather than making
calling code deal with it everywhere.
2019-04-07 01:12:54 -04:00
Lioncash 7a7ffa602d kernel/server_session: Return a std::pair from CreateSessionPair()
Keeps the return type consistent with the function name. While we're at
it, we can also reduce the amount of boilerplate involved with handling
these by using structured bindings.
2019-04-06 01:42:03 -04:00
Lioncash 04d265562f kernel/server_port: Return a std::pair from CreatePortPair()
Returns the same type that the function name describes.
2019-04-06 01:36:53 -04:00
bunnei 7d1c0fd1ad
Merge pull request #2325 from lioncash/name
kernel/server_session: Provide a GetName() override
2019-04-05 23:48:13 -04:00
bunnei 54c7e8e40e
Merge pull request #2240 from FearlessTobi/port-4651
Port citra-emu/citra#4651: "gdbstub: Fix some bugs in IsMemoryBreak() and ServeBreak. Add workaround to let watchpoints break into GDB."
2019-04-05 23:46:37 -04:00
bunnei 00207cc965
Merge pull request #2340 from lioncash/view
file_sys/fsmitm_romfsbuild: Utilize a string_view in romfs_calc_path_hash
2019-04-05 23:40:16 -04:00
bunnei e86b26cd2b
Merge pull request #2334 from lioncash/override
core: Add missing override specifiers where applicable
2019-04-05 23:39:52 -04:00
bunnei 23d3cd7604
Merge pull request #2341 from lioncash/compare
file_sys/nca_metadata: Remove unnecessary comparison operators for TitleType
2019-04-05 23:38:37 -04:00
bunnei d6cddffb78
Merge pull request #2339 from lioncash/rank
service/fsp_srv: Update SaveDataInfo and SaveDataDescriptor structs
2019-04-05 23:36:46 -04:00
bunnei b8fbd125e6
Merge pull request #2343 from lioncash/todo
file_sys/program_metadata: Remove obsolete TODOs
2019-04-05 23:35:54 -04:00
bunnei 854ac468b9
Merge pull request #2329 from lioncash/sanitize
kernel/svc: Properly sanitize mutex address in WaitProcessWideKeyAtomic
2019-04-05 23:35:06 -04:00
bunnei 150a3c0890
Merge pull request #2344 from lioncash/result
hle/result: Remove unnecessary bitfield entry for ResultCode
2019-04-05 23:34:42 -04:00
Lioncash 5dfcf7cf26 hle/result: Remove unnecessary bitfield entry for ResultCode
This is a hold over from the 3DS error codes in Citra.
2019-04-05 16:34:34 -04:00
Lioncash 37b23efece file_sys/program_metadata: Remove obsolete TODOs
BitField has been trivially copyable since
e99a148628, so we can eliminate these
TODO comments and use ReadObject() directly instead of memcpying the
data.
2019-04-05 15:57:47 -04:00
Lioncash a1868286b0 file_sys/nca_metadata: Remove unnecessary comparison operators for TitleType
enum class elements from the same enum can already be compared against
one another without the need for explicitly defined comparison
operators.
2019-04-05 15:20:07 -04:00
Lioncash 28e36de56f file_sys/fsmitm_romfsbuild: Utilize a string_view in romfs_calc_path_hash()
The given string instance doesn't need to be copied entirely, we can
just use a view instead.
2019-04-05 15:12:20 -04:00
Lioncash c05c8a7a06 service/fsp_srv: Don't pass SaveDataDescriptor instances by value.
Passing around a 64 byte data struct by value is kind of wasteful,
instead pass a reference to the struct.
2019-04-05 11:04:01 -04:00
Lioncash d0ed3ff4b7 service/fsp_srv: Remove unnecessary unknown member in OpenSaveDataFileSystem
The unknown member here is actually padding due to being passed as a
struct. We can do the same, and remove the need to pop a padding word.
2019-04-05 11:04:01 -04:00
Lioncash d9ee58a3b5 service/fsp_srv: Update SaveDataInfo and SaveDataDescriptor structs
I realized that I updated the documentation on SwitchBrew a while ago,
but never actually updated the structs within yuzu.
2019-04-05 11:03:53 -04:00
bunnei d6b7195192
Merge pull request #2338 from lioncash/fs
filesystem: Use a std::string_view in OpenFile()
2019-04-05 10:52:54 -04:00
bunnei 7c1af3aa10
Merge pull request #2292 from lioncash/nacp
file_sys/control_metadata: Amend naming of members
2019-04-04 22:37:42 -04:00
Lioncash 15e0c4c4ec filesystem: Use a std::string_view in OpenFile()
Rather than make a full copy of the path, we can just use a string view
and truncate the viewed portion of the string instead of creating a totally
new truncated string.
2019-04-04 20:59:00 -04:00
Lioncash 7f506be2ee hle/service: Resolve unused variable warnings
In several places, we have request parsers where there's nothing to
really parse, simply because the HLE function in question operates on
buffers. In these cases we can just remove these instances altogether.

In the other cases, we can retrieve the relevant members from the parser
and at least log them out, giving them some use.
2019-04-04 13:18:09 -04:00
Lioncash 5b0a9f8ba8 core: Add missing override specifiers where applicable
Applies the override specifier where applicable. In the case of
destructors that are  defaulted in their definition, they can
simply be removed.

This also removes the unnecessary inclusions being done in audin_u and
audrec_u, given their close proximity.
2019-04-04 12:19:44 -04:00
bunnei acde8d3f68
Merge pull request #2328 from lioncash/transfer
service/am: Correct behavior of CreateTransferMemoryStorage()
2019-04-03 21:54:32 -04:00
bunnei d6374b2522
Merge pull request #2093 from FreddyFunk/disk-cache-better-compression
Better LZ4 compression utilization for the disk based shader cache and the yuzu build system
2019-04-03 21:50:29 -04:00
bunnei a655b59cef
Merge pull request #2324 from lioncash/enum-unused
kernel/object: Remove unused handle type entry
2019-04-03 21:47:09 -04:00
Lioncash a973271b8c file_sys/control_metadata: Amend naming of members
Quite a bit of these were out of sync with Switchbrew (and in some cases
entirely wrong). While we're at it, also expand the section of named
members. A segment within the control metadata is used to specify
maximum values for the user, device, and cache storage max sizes and
journal sizes.

These appear to be generally used by the am service (e.g. in
CreateCacheStorage, etc).
2019-04-03 21:18:12 -04:00
Lioncash c39c8e6982 kernel/svc: Properly sanitize mutex address in WaitProcessWideKeyAtomic
We need to be checking whether or not the given address is within the
kernel address space or if the given address isn't word-aligned and bail
in these scenarios instead of trashing any kernel state.
2019-04-03 20:25:41 -04:00
Lioncash ea8f633dc0 service/am: Correct behavior of CreateTransferMemoryStorage()
For whatever reason, shared memory was being used here instead of
transfer memory, which (quite clearly) will not work based off the name
of the function.

This corrects this wonky usage of shared memory.
2019-04-03 17:49:21 -04:00
Lioncash 140cd5e209 kernel/transfer_memory: Add accessors to data and sizes
Also amend erroneous use of size_t. We should be using u64 here.
2019-04-03 17:49:16 -04:00
bunnei a6d5ff05dc
Merge pull request #2294 from lioncash/fatal
service/am: Implement EnterFatalSection/LeaveFatalSection
2019-04-03 12:12:07 -04:00
bunnei 580e3564c9
Merge pull request #2305 from lioncash/shared
kernel/shared_memory: Sanitize supplied size when unmapping
2019-04-03 11:48:11 -04:00
bunnei 74a4a50470
Merge pull request #2314 from lioncash/const
kernel/thread: Minor interface cleanup
2019-04-03 11:46:17 -04:00
Lioncash a074363a5d kernel/server_session: Provide a GetName() override
Given server sessions can be given a name, we should allow retrieving
it instead of using the default implementation of GetName(), which would
just return "[UNKNOWN KERNEL OBJECT]".
2019-04-03 10:39:06 -04:00
Lioncash 7ccb0b16cd kernel/object: Remove unused handle type entry
The AddressArbiter type isn't actually used, given the arbiter itself
isn't a direct kernel object (or object that implements the wait object
facilities).

Given this, we can remove the enum entry entirely.
2019-04-03 10:24:32 -04:00
bunnei e796351a0d
Merge pull request #2270 from lioncash/plist
kernel/svc: Implement svcGetProcessList and svcGetThreadList
2019-04-02 21:40:39 -04:00
bunnei 57279e1981
Merge pull request #2313 from lioncash/reslimit
kernel/resource_limit: Remove the name member from resource limits
2019-04-02 16:03:54 -04:00
Lioncash 28719ee3b4 kernel/svc: Implement svcGetThreadList
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.
2019-04-02 00:48:40 -04:00
Lioncash cb2bce8006 kernel/svc: Implement svcGetProcessList
This service function simply copies out a specified number of kernel
process IDs, while simultaneously reporting the total number of
processes.
2019-04-02 00:47:14 -04:00
ReinUsesLisp 592a24ae53 process: Fix up compilation 2019-04-02 01:44:32 -03:00
bunnei 29df6bbbd3
Merge pull request #2281 from lioncash/memory
kernel/codeset: Make CodeSet's memory data member a regular std::vector
2019-04-01 22:20:05 -04:00
Lioncash 4366241739 kernel/thread: Make AllWaitObjectsReady() a const qualified member function
Now that ShouldWait() is a const qualified member function, this one can
be made const qualified as well, since it can handle passing a const
qualified this pointer to ShouldWait().
2019-04-01 18:23:50 -04:00
Lioncash 20cc0b8d3c kernel/wait_object: Make ShouldWait() take thread members by pointer-to-const
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.
2019-04-01 18:19:45 -04:00
Lioncash 2d70c30fb2 kernel/thread: Avoid sign conversion within GetCommandBufferAddress()
Previously this was performing a u64 + int sign conversion. When dealing
with addresses, we should generally be keeping the arithmetic in the
same signedness type.

This also gets rid of the static lifetime of the constant, as there's no
need to make a trivial type like this potentially live for the entire
duration of the program.
2019-04-01 17:59:45 -04:00
Lioncash 26d0381161 kernel/thread: Make parameter of GetWaitObjectIndex() const qualified
The pointed to member is never actually modified, so it can be made
const.
2019-04-01 17:48:33 -04:00
Lioncash d09e98f566 kernel/resource_limit: Remove the name member from resource limits
This doesn't really provide any benefit to the resource limit interface.
There's no way for callers to any of the service functions for resource
limits to provide a custom name, so all created instances of resource
limits other than the system resource limit would have a name of
"Unknown".

The system resource limit itself is already trivially identifiable from
its limit values, so there's no real need to take up space in the object to
identify one object meaningfully out of N total objects.
2019-04-01 16:49:28 -04:00
bunnei 62860dc0b0
Merge pull request #2301 from FearlessTobi/remove-amiibo-setting
core/yuzu: Remove enable_nfc setting
2019-04-01 15:02:08 -04:00
Lioncash 781ab8407b general: Use deducation guides for std::lock_guard and std::unique_lock
Since C++17, the introduction of deduction guides for locking facilities
means that we no longer need to hardcode the mutex type into the locks
themselves, making it easier to switch mutex types, should it ever be
necessary in the future.
2019-04-01 12:53:47 -04:00
bunnei d9b7bc4474
Merge pull request #2304 from lioncash/memsize
kernel/process: Report total physical memory used to svcGetInfo slightly better
2019-03-30 20:11:17 -04:00
bunnei ba3d95e550
Merge pull request #2308 from lioncash/deduction
kernel/scheduler: Minor tidying up
2019-03-30 19:59:10 -04:00
Lioncash 824b8e4086 kernel/scheduler: Remove unused parameter to AddThread()
This was made unused in b404fcdf14, but
the parameter itself wasn't removed.
2019-03-30 05:29:33 -04:00
Lioncash cb805f45ae kernel/scheduler: Use deduction guides on mutex locks
Since C++17, we no longer need to explicitly specify the type of the
mutex within the lock_guard. The type system can now deduce these with
deduction guides.
2019-03-30 05:28:43 -04:00
Lioncash 4b33a346ed service/fatal: Mark local variables as const where applicable 2019-03-30 03:06:23 -04:00
Lioncash 11505d3d9f service/fatal: Remove unnecessary semicolon
Resolves a -Wextra-semi warning.
2019-03-30 03:04:16 -04:00
Lioncash cc737e5832 service/fatal: Name FatalInfo structure members
Based off RE, most of these structure members are register values, which
makes, sense given this service is used to convey fatal errors.

One member indicates the program entry point address, one is a set of
bit flags used to determine which registers to print, and one member
indicates the architecture type.

The only member that still isn't determined is the final member within
the data structure.
2019-03-30 03:01:20 -04:00
Lioncash 108be41316 kernel/shared_memory: Remove unused core/memory.h include
Nothing from this header is used, so we can remove this include, getting
rid of a dependency on it.
2019-03-29 18:16:22 -04:00
Lioncash c6147a439d kernel/shared_memory: Sanitize supplied size when unmapping
The kernel makes sure that the given size to unmap is always the same
size as the entire region managed by the shared memory instance,
otherwise it returns an error code signifying an invalid size.

This is similarly done for transfer memory (which we already check for).
2019-03-29 18:16:19 -04:00
unknown c791192d64 Addressed feedback 2019-03-29 18:12:42 +01:00
unknown 6a1a2d4aa5 core: Do not link LZ4 to core. Use common/data_compression for nso segment decompression instead. 2019-03-29 16:42:34 +01:00
fearlessTobi ff7e6a42c1 core/yuzu: Remove enable_nfc setting
This was initially added to prevent problems from stubbed/not implemented NFC services, but as we never encountered such and as it's only used in a deprecated function anyway, I guess we can just remove it to prevent more clutter of the settings.
2019-03-29 15:02:28 +01:00
Lioncash 3a846aa80f kernel/process: Report total physical memory used to svcGetInfo
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.
2019-03-28 22:59:20 -04:00
Lioncash 2289e895aa kernel/process: Store the total size of the code memory loaded
This will be necessary to properly report the used memory size in
svcGetInfo.
2019-03-28 22:51:17 -04:00
bunnei f770c17d01
Merge pull request #2266 from FernandoS27/arbitration
Kernel: Fixes to Arbitration and SignalProcessWideKey Management
2019-03-28 21:42:24 -04:00
bunnei b404fcdf14
Merge pull request #2265 from FernandoS27/multilevelqueue
Replace old Thread Queue for a new Multi Level Queue
2019-03-28 21:41:40 -04:00
Lioncash 5d4ab5ec2f kernel/process: Store the main thread stack size to a data member
This will be necessary in order to properly report memory usage within
svcGetInfo.
2019-03-28 18:45:06 -04:00
Lioncash 427f1e3e3d kernel/process: Make Run's stack size parameter a u64
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).
2019-03-28 18:26:12 -04:00
Lioncash 2aca7b9e1e kernel/process: Ensure that given stack size is always page-aligned
The kernel always makes sure that the given stack size is aligned to
page boundaries.
2019-03-28 18:25:00 -04:00
bunnei 16dc3a1dd5
Merge pull request #2284 from lioncash/heap-alloc
kernel/vm_manager: Unify heap allocation/freeing functions
2019-03-28 17:56:49 -04:00
Zach Hilman 552d5071fa patch_manager: Dump NSO name with build ID 2019-03-27 20:09:01 -04:00
Fernando Sahmkow db42bcb306 Fixes and corrections on formatting. 2019-03-27 14:49:43 -04:00
Fernando Sahmkow dde0814837 Use MultiLevelQueue instead of old ThreadQueueList 2019-03-27 14:34:32 -04:00
Zach Hilman 41d2565f29 game_list: Register content with ContentProvider 2019-03-26 22:05:37 -04:00
Zach Hilman 60f39060c6 core: Port current uses of RegisteredCache to ContentProvider 2019-03-26 22:05:37 -04:00
Zach Hilman 45cb41f517 core: Store system-wide ContentProvider for the emulator 2019-03-26 22:05:37 -04:00
Zach Hilman a6c7ae6fe8 file_sys: Create ContentProvider interface and default implementations 2019-03-26 22:03:26 -04:00
Lioncash 758d84db9a service/am: Implement EnterFatalSection and LeaveFatalSection
These functions act in tandem similar to how a lock or mutex require a
balanced lock()/unlock() sequence.

EnterFatalSection simply increments a counter for how many times it has
been called, while LeaveFatalSection ensures that a previous call to
EnterFatalSection has occured. If a previous call has occurred (the
counter is not zero), then the counter gets decremented as one would
expect. If a previous call has not occurred (the counter is zero), then
an error code is returned.
2019-03-26 17:02:42 -04:00
Lioncash 96d518a59f service/am: Sort ISelfController's member functions according to table order
Makes the declaration order of the handling functions consistent with
the handler table itself.
2019-03-26 17:02:29 -04:00
bunnei 47f2405ab1
Merge pull request #2285 from lioncash/unused-struct
kernel/process: Remove unused AddressMapping struct
2019-03-26 11:17:03 -04:00
bunnei 595511876e
Merge pull request #2287 from lioncash/coretiming-cb
core/core_timing: Make callback parameters consistent
2019-03-25 21:06:33 -04:00
bunnei 8a24a804c5
Merge pull request #2286 from lioncash/fwd
kernel/kernel: Remove unnecessary forward declaration
2019-03-25 21:05:33 -04:00