| Commit message (Collapse) | Author | Age | Files | Lines |
|
|
|
|
|
|
|
| |
Given we already pass in a reference to the kernel that the shared
memory instance is created under, we can just use that to check the
current process, rather than using the global accessor functions.
This allows removing direct dependency on the system instance entirely.
|
|
|
|
| |
Makes immutable state explicit.
|
|
|
|
|
|
|
|
|
|
| |
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.
|
|
|
|
| |
Directly initializes members where applicable.
|
|
|
|
|
| |
Avoids implicit truncation warnings from u32 -> u16 (the truncation is
desirable behavior here).
|
|
|
|
|
|
| |
A fairly trivial change. Other sections of the codebase use nested
namespaces instead of separate namespaces here. This one must have just
been overlooked.
|
|
|
|
|
|
|
|
|
|
|
| |
Gets rid of the largest set of mutable global state within the core.
This also paves a way for eliminating usages of GetInstance() on the
System class as a follow-up.
Note that no behavioral changes have been made, and this simply extracts
the functionality into a class. This also has the benefit of making
dependencies on the core timing functionality explicit within the
relevant interfaces.
|
|
|
|
|
|
| |
Places all of the timing-related functionality under the existing Core
namespace to keep things consistent, rather than having the timing
utilities sitting in its own completely separate namespace.
|
|
|
|
|
|
|
|
|
|
|
|
| |
A holdover from citra, the Horizon kernel on the switch has no
prominent kernel object that functions as a timer. At least not
to the degree of sophistication that this class provided.
As such, this can be removed entirely. This class also wasn't used at
all in any meaningful way within the core, so this was just code sitting
around doing nothing. This also allows removing a few things from the
main KernelCore class that allows it to use slightly less resources
overall (though very minor and not anything really noticeable).
|
|
|
|
|
|
|
|
|
| |
No inheritors of the WaitObject class actually make use of their own
implementations of these functions, so they can be made non-virtual.
It's also kind of sketchy to allow overriding how the threads get added
to the list anyways, given the kernel itself on the actual hardware
doesn't seem to customize based off this.
|
|
|
|
|
| |
This implementation just calls the base class variant of the function,
so this isn't necessary.
|
|
|
|
| |
This just calls the base variant of the function, so it can be removed.
|
|
|
|
|
|
|
|
|
|
| |
Looking into the implementation of the C++ standard facilities that seem
to be within all modules, it appears that they use 7 as a break reason
to indicate an uncaught C++ exception.
This was primarily found via the third last function called within
Horizon's equivalent of libcxxabi's demangling_terminate_handler(),
which passes the value 0x80000007 to svcBreak.
|
|
|
|
| |
Pulse is considered a hack and nothing should be using it. We should completely remove it
|
|
|
|
| |
Gets rid of a few unnecessary header dependencies in some source files.
|
|
|
|
|
|
|
|
|
|
| |
This is a bounds check to ensure that the thread priority is within the
valid range of 0-64. If it exceeds 64, that doesn't necessarily mean
that an actual priority of 64 was expected (it actually means whoever
called the function screwed up their math).
Instead clarify the message to indicate the allowed range of thread
priorities.
|
|
|
|
|
|
| |
Now that we handle the kernel capability descriptors we can correct
CreateThread to properly check against the core and priority masks
like the actual kernel does.
|
|
|
|
| |
Makes them consistent with their kernel capability counterparts.
|
|
|
|
|
| |
Rather than use a switch here, this can be collapsed into a simple range
check, which is a little easier on the eyes.
|
|\
| |
| | |
kernel/process: Start the main thread using the specified ideal core
|
| |
| |
| |
| |
| | |
This matches kernel behavior in that processes are started using their
specified ideal core, rather than always starting on core 0.
|
| |
| |
| |
| |
| |
| | |
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.
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
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.
|
|\ \
| | |
| | | |
Print backtrace on svcBreak
|
| | | |
|
| | |
| | |
| | |
| | | |
Added to both dynarmic and unicorn
|
| | |
| | |
| | |
| | | |
When we get an svcBreak we get a backtrace now
|
| |/
|/|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
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: Handle kernel capability descriptors
|
| | |
| | |
| | |
| | |
| | | |
While we're at it, we can also toss out the leftover capability parsing
from Citra.
|
| | | |
|
| | |
| | |
| | |
| | |
| | | |
This just specifies the handle table size. There's also a section of
reserved bits that are checked against.
|
| | | |
|
| | | |
|
| | |
| | |
| | |
| | |
| | |
| | | |
Similar to the service capability flags, however, we currently don't
emulate the GIC, so this currently handles all interrupts as being valid
for the time being.
|
| | | |
|
| | |
| | |
| | |
| | |
| | |
| | | |
Handles the priority mask and core mask flags to allow building up the
masks to determine the usable thread priorities and cores for a kernel
process instance.
|
| | |
| | |
| | |
| | |
| | |
| | |
| | | |
We've had the old kernel capability parser from Citra, however, this is
unused code and doesn't actually map to how the kernel on the Switch
does it. This introduces the basic functional skeleton for parsing
process capabilities.
|
| | |
| | |
| | |
| | |
| | | |
Like the other members related to memory regions, the attributes need to
be reset back to their defaults as well.
|
|\ \ \
| | | |
| | | | |
svc: Implement SetThreadActivity (thread suspension)
|
| | | | |
|
|\ \ \ \
| | | | |
| | | | | |
Fixed uninitialized memory due to missing returns in canary
|
| | | | |
| | | | |
| | | | |
| | | | | |
Functions which are suppose to crash on non canary builds usually don't return anything which lead to uninitialized memory being used.
|
|\ \ \ \ \
| |_|_|/ /
|/| | | | |
kernel/{process, thread}: Amend behavior related to IDs
|
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | | |
If a thread handle is passed to svcGetProcessId, the kernel attempts to
access the process ID via the thread's instance's owning process.
Technically, this function should also be handling the kernel debug
objects as well, however we currently don't handle those kernel objects
yet, so I've left a note via a comment about it to remind myself when
implementing it in the future.
|
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | | |
Starts the process ID counter off at 81, which is what the kernel itself
checks against internally when creating processes. It's actually
supposed to panic if the PID is less than 81 for a userland process.
|
| | | | |
| | | | |
| | | | |
| | | | |
| | | | | |
The service call uses a 64-bit value, just like svcGetProcessId. This
amends the function signature accordingly.
|
| | | | |
| | | | |
| | | | |
| | | | |
| | | | | |
The kernel uses a 64-bit value for the thread ID, so we shouldn't be
using a 32-bit value.
|
| | | | |
| | | | |
| | | | |
| | | | |
| | | | | |
svcGetProcessId's out parameter is a pointer to a 64-bit value, not a
32-bit one.
|
| | | | |
| | | | |
| | | | |
| | | | |
| | | | | |
In the actual kernel, this is a 64-bit value, so we shouldn't be using a
32-bit type to handle it.
|
|\ \ \ \ \
| |_|/ / /
|/| | | | |
kernel/svc: Implement svcSetMemoryAttribute
|
| | | | |
| | | | |
| | | | |
| | | | |
| | | | | |
With all the basic backing functionality implemented, we can now unstub
svcSetMemoryAttribute.
|
| | | | |
| | | | |
| | | | |
| | | | |
| | | | | |
This puts the backing functionality for svcSetMemoryAttribute in place,
which will be utilized in a following change.
|
| | | | | |
|
| | | | |
| | | | |
| | | | |
| | | | |
| | | | | |
This is shorter and more concise. This also removes the now-innaccurate
comment, as it's not returned wholesale to svcQueryMemory anymore.
|
| |/ / /
| | | |
| | | |
| | | |
| | | |
| | | | |
Adds the barebones enumeration constants and functions in place to
handle memory attributes, while also essentially leaving the attribute
itself non-functional.
|
|/ / / |
|
|\ \ \
| | | |
| | | | |
svc: Implement yield types 0 and -1
|
| | | | |
|
| | | |
| | | |
| | | | |
This will automatically occur anyway when PrepareReschedule is called
|
| | | | |
|
| | | | |
|
| | | | |
|
| | | | |
|
|\ \ \ \
| | | | |
| | | | | |
vm_manager/svc: Modify MemoryState enum, and correct error handling for svcQueryMemory
|
| | | | |
| | | | |
| | | | |
| | | | |
| | | | | |
svcQueryProcessMemory is trivial to implement, given all the behavior
necessary for it is present, it just needs a handler for it.
|
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | | |
In the previous change, the memory writing was moved into the service
function itself, however it still had a problem, in that the entire
MemoryInfo structure wasn't being written out, only the first 32 bytes
of it were being written out. We still need to write out the trailing
two reference count members and zero out the padding bits.
Not doing this can result in wrong behavior in userland code in the following
scenario:
MemoryInfo info; // Put on the stack, not quaranteed to be zeroed out.
svcQueryMemory(&info, ...);
if (info.device_refcount == ...) // Whoops, uninitialized read.
This can also cause the wrong thing to happen if the user code uses
std::memcmp to compare the struct, with another one (questionable, but
allowed), as the padding bits are not guaranteed to be a deterministic
value. Note that the kernel itself also fully zeroes out the structure
before writing it out including the padding bits.
|
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | | |
Moves the memory writes directly into QueryProcessMemory instead of
letting the wrapper function do it. It would be inaccurate to allow the
handler to do it because there's cases where memory shouldn't even be
written to. For example, if the given process handle is invalid.
HOWEVER, if the memory writing is within the wrapper, then we have no
control over if these memory writes occur, meaning in an error case, 68
bytes of memory randomly get trashed with zeroes, 64 of those being
written to wherever the memory info address points to, and the remaining
4 being written wherever the page info address points to.
One solution in this case would be to just conditionally check within
the handler itself, but this is kind of smelly, given the handler
shouldn't be performing conditional behavior itself, it's a behavior of
the managed function. In other words, if you remove the handler from the
equation entirely, does the function still retain its proper behavior?
In this case, no.
Now, we don't potentially trash memory from this function if an invalid
query is performed.
|
| | | | |
| | | | |
| | | | |
| | | | | |
These should be swapped.
|
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | | |
The kernel returns a memory info instance with the base address set to
the end of the address space, and the size of said block as
0 - address_space_end, it doesn't set both of said members to zero.
|
| | | | |
| | | | |
| | | | |
| | | | |
| | | | | |
Gets rid of the need to directly access the managed VMAs outside of the
memory manager itself just for querying memory.
|
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | | |
Gets the two structures out of an unrelated header and places them with
the rest of the memory management code.
This also corrects the structures. PageInfo appears to only contain a
32-bit flags member, and the extra padding word in MemoryInfo isn't
necessary.
|
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | | |
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.
|
|\ \ \ \ \
| | | | | |
| | | | | | |
svc_wrap: Correct register index for a wrapper specialization
|
| |/ / / /
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | | |
This would result in svcSetMemoryAttribute getting the wrong value for
its third parameter. This is currently fine, given the service function
is stubbed, however this will be unstubbed in a future change, so this
needs to change.
|
|/ / / /
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | | |
The Process object kept itself alive indefinitely because its handle_table
contains a SharedMemory object which owns a reference to the same Process object,
creating a circular ownership scenario.
Break that up by storing only a non-owning pointer in the SharedMemory object.
|
|\ \ \ \
| | | | |
| | | | | |
kernel/process: Set ideal core from metadata
|
| | | | |
| | | | |
| | | | |
| | | | |
| | | | | |
A very trivial change. If metadata is available, the process should use
it to retrieve the desired core for the process to run on.
|
|\ \ \ \ \
| | | | | |
| | | | | | |
vm_manager: Make vma_map private
|
| |/ / / /
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | | |
This was only ever public so that code could check whether or not a
handle was valid or not. Instead of exposing the object directly and
allowing external code to potentially mess with the map contents, we
just provide a member function that allows checking whether or not a
handle is valid.
This makes all member variables of the VMManager class private except
for the page table.
|
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | | |
While partially correct, this service call allows the retrieved event to
be null, as it also uses the same handle to check if it was referring to
a Process instance. The previous two changes put the necessary machinery
in place to allow for this, so we can simply call those member functions
here and be done with it.
|
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | | |
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.
|
|/ / / /
| | | |
| | | |
| | | |
| | | |
| | | | |
svcResetSignal relies on the event instance to have already been
signaled before attempting to reset it. If this isn't the case, then an
error code has to be returned.
|
| | | | |
|
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | | |
This function simply does a handle table lookup for a writable event
instance identified by the given handle value. If a writable event
cannot be found for the given handle, then an invalid handle error is
returned. If a writable event is found, then it simply signals the
event, as one would expect.
|
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | | |
svcCreateEvent operates by creating both a readable and writable event
and then attempts to add both to the current process' handle table.
If adding either of the events to the handle table fails, then the
relevant error from the handle table is returned.
If adding the readable event after the writable event to the table
fails, then the writable event is removed from the handle table and the
relevant error from the handle table is returned.
Note that since we do not currently test resource limits, we don't check
the resource limit table yet.
|
|\ \ \ \
| | | | |
| | | | | |
kernel/object: Amend handle types to distinguish between readable and writable events
|
| | |/ /
| |/| |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | | |
Two kernel object should absolutely never have the same handle ID type.
This can cause incorrect behavior when it comes to retrieving object
types from the handle table. In this case it allows converting a
WritableEvent into a ReadableEvent and vice-versa, which is undefined
behavior, since the object types are not the same.
This also corrects ClearEvent() to check both kernel types like the
kernel itself does.
|
| | | |
| | | |
| | | |
| | | | |
Another hold-over from Citra.
|
|/ / /
| | |
| | |
| | |
| | | |
Allows a process to register the resource limit as part of its handle
table.
|
| | | |
|
|\ \ \
| | | |
| | | | |
svc: Reorganize svcGetInfo, handle more error cases for existing implemented info categories
|
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | | |
The kernel uses the handle table of the current process to retrieve the
process that should be used to retrieve certain information. To someone
not familiar with the kernel, this might raise the question of "Ok,
sounds nice, but doesn't this make it impossible to retrieve information
about the current process?".
No, it doesn't, because HandleTable instances in the kernel have the
notion of a "pseudo-handle", where certain values allow the kernel to
lookup objects outside of a given handle table. Currently, there's only
a pseudo-handle for the current process (0xFFFF8001) and a pseudo-handle
for the current thread (0xFFFF8000), so to retrieve the current process,
one would just pass 0xFFFF8001 into svcGetInfo.
The lookup itself in the handle table would be something like:
template <typename T>
T* Lookup(Handle handle) {
if (handle == PSEUDO_HANDLE_CURRENT_PROCESS) {
return CurrentProcess();
}
if (handle == PSUEDO_HANDLE_CURRENT_THREAD) {
return CurrentThread();
}
return static_cast<T*>(&objects[handle]);
}
which, as is shown, allows accessing the current process or current
thread, even if those two objects aren't actually within the HandleTable
instance.
|
| | |/
| |/|
| | |
| | |
| | |
| | | |
Our implementation of svcGetInfo was slightly incorrect in that we
weren't doing proper error checking everywhere. Instead, reorganize it
to be similar to how the kernel seems to do it.
|
|\ \ \
| |/ /
|/| | |
kernel: Divide Event into ReadableEvent and WritableEvent
|
| | | |
|
| | | |
|
| | | |
|
| | | |
|
| | |
| | |
| | |
| | | |
Used to store ReadableEvents of all events on the system.
|
| | |
| | |
| | |
| | | |
More hardware accurate. On the actual system, there is a differentiation between the signaler and signalee, they form a client/server relationship much like ServerPort and ClientPort.
|
| | | |
|
|/ /
| |
| |
| |
| | |
A non-existent parameter was left in some formatting calls (the logging
macro for which only does anything meaningful on debug builds)
|
|\ \
| | |
| | | |
Changed logging to be "Log before execution", Added more error logging, all services/svc should now log on some level
|
| | | |
|
| | | |
|
| | | |
|
| | | |
|
| | | |
|
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | | |
The opposite of the getter functions, this function sets the limit value
for a particular ResourceLimit resource category, with the restriction
that the new limit value must be equal to or greater than the current
resource value. If this is violated, then ERR_INVALID_STATE is returned.
e.g.
Assume:
current[Events] = 10;
limit[Events] = 20;
a call to this service function lowering the limit value to 10 would be
fine, however, attempting to lower it to 9 in this case would cause an
invalid state error.
|
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | | |
This kernel service function is essentially the exact same as
svcGetResourceLimitLimitValue(), with the only difference being that it
retrieves the current value for a given resource category using the
provided resource limit handle, rather than retrieving the limiting
value of that resource limit instance.
Given these are exactly the same and only differ on returned values, we
can extract the existing code for svcGetResourceLimitLimitValue() to
handle both values.
|
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | | |
This kernel service function retrieves the maximum allowable value for
a provided resource category for a given resource limit instance. Given
we already have the functionality added to the resource limit instance
itself, it's sufficient to just hook it up.
The error scenarios for this are:
1. If an invalid resource category type is provided, then ERR_INVALID_ENUM is returned.
2. If an invalid handle is provided, then ERR_INVALID_HANDLE is returned (bad thing goes in, bad thing goes out, as one would expect).
If neither of the above error cases occur, then the out parameter is
provided with the maximum limit value for the given category and success
is returned.
|
|/ /
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
This function simply creates a ResourceLimit instance and attempts to
create a handle for it within the current process' handle table. If the
kernal fails to either create the ResourceLimit instance or create a
handle for the ResourceLimit instance, it returns a failure code
(OUT_OF_RESOURCE, and HANDLE_TABLE_FULL respectively). Finally, it exits
by providing the output parameter with the handle value for the
ResourceLimit instance and returning that it was successful.
Note: We do not return OUT_OF_RESOURCE because, if yuzu runs out of
available memory, then new will currently throw. We *could* allocate the
kernel instance with std::nothrow, however this would be inconsistent
with how all other kernel objects are currently allocated.
|
| | |
|
| |
| |
| |
| |
| | |
These don't depend on class state, and are effectively implementation
details, so they can go into the cpp file .
|
| |
| |
| |
| |
| |
| | |
The previous handle table size is a holdover from Citra. The actual
handle table construct on Horizon only allows for a maximum of 1024
entries.
|
| |
| |
| |
| |
| | |
We don't need to potentially inline the teardown logic of all of the
handle instances.
|
|\ \
| | |
| | | |
kernel/shared_memory: Make data members private, plus minor interface changes
|
| | |
| | |
| | |
| | |
| | |
| | | |
Both member functions assume the passed in target process will not be
null. Instead of making this assumption implicit, we can change the
functions to be references and enforce this at the type-system level.
|
| | |
| | |
| | |
| | |
| | | |
Given this doesn't mutate instance state, we can provide a
const-qualified variant as well.
|
| | |
| | |
| | |
| | | |
Keeps the interface consistent with the regular Create() function.
|
| | |
| | |
| | |
| | |
| | |
| | |
| | | |
Makes the interface nicer to use in terms of 64-bit code, as it makes it
less likely for one to get truncation warnings (and also makes sense in
the context of the rest of the interface where 64-bit types are used for
sizes and offsets
|
| |/
| |
| |
| |
| |
| | |
Rather than allow unfettered access to the class internals, we hide all
members by default and create and API that other code can operate
against.
|
| |
| |
| |
| |
| |
| | |
<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.
|
|\ \
| | |
| | | |
am: Implement HLE software keyboard applet
|
| | | |
|
| | |
| | |
| | | |
Seems to be used and created identically to SharedMemory, so just reuse that.
|
| |/
|/|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
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: Complete LDR:RO implementation
|
| | | |
|
| | |
| | |
| | |
| | | |
Credits to Subv
|
|\ \ \
| |_|/
|/| | |
svc: ResetSignal is not stubbed
|
| | |
| | |
| | | |
https://user-images.githubusercontent.com/20753089/48677874-b8e01c80-eb7b-11e8-8043-b99faa29022c.PNG
|
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | | |
Similar to PR 1706, which cleans up the error codes for the filesystem
code, but done for the kernel error codes. This removes the ErrCodes
namespace and specifies the errors directly. This also fixes up any
straggling lines of code that weren't using the named error codes where
applicable.
|
|\ \ \
| | | |
| | | | |
Implement SetMemoryPermission
|
| | | | |
|
| | | | |
|
|\ \ \ \
| |_|_|/
|/| | | |
kernel/thread: Deduplicate scheduler switching code
|
| | | |
| | | |
| | | |
| | | |
| | | | |
The code in both places was the same verbatim, so we can extract it to a
function to deduplicate the logic.
|
|\ \ \ \
| | | | |
| | | | | |
svc: Use proper random entropy generation algorithm
|
| |/ / / |
|
| | | |
| | | |
| | | |
| | | |
| | | |
| | | | |
Now that we've moved all of the heap-related stuff to the VMManager
class, we can unstub this function, as the necessary members are visible
now.
|
|/ / /
| | |
| | |
| | |
| | | |
Avoids a breach of responsibilities in the interface and keeps the
direct code for memory management within the VMManager class.
|
| | | |
|
|/ /
| |
| |
| |
| |
| |
| |
| | |
* svcBreak now dumps information from the debug buffer passed
info1 and info2 seem to somtimes hold an address to a buffer, this is usually 4 bytes or the size of the int and contains an error code. There's other circumstances where it can be something different so we hexdump these to examine them at a later date.
* Addressed comments
|
| |
| |
| |
| | |
Cleans up unused includes and trims off some dependencies on externals.
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
* get rid of boost::optional
* Remove optional references
* Use std::reference_wrapper for optional references
* Fix clang format
* Fix clang format part 2
* Adressed feedback
* Fix clang format and MacOS build
|
|\ \
| | |
| | | |
hle_ipc: Make GetDomainMessageHeader return a regular pointer
|
| | |
| | |
| | |
| | | |
Gets rid of the need to call the getter and then check for null.
|
| |/
| |
| |
| |
| | |
Nothing requires the shared owner ship here, so we can just return a
plain pointer.
|
|/ |
|
|
|
|
| |
Nothing from this enum is intended to be used outside of this function.
|
|
|
|
|
|
|
|
|
|
| |
This retrieves:
if (curr_thread == handle_thread) {
result = total_thread_ticks + (hardware_tick_count - last_context_switch_ticks);
} else if (curr_thread == handle_thread && sub_id == current_core_index) {
result = hardware_tick_count - last_context_switch_ticks;
}
|
| |
|
| |
|
|
|
|
|
|
| |
Now that we've gotten the innaccurate error codes out of the way, we can
finally toss away a bunch of these, trimming down the error codes to
ones that are actually used and knocking out two TODO comments.
|
|
|
|
| |
This is more consistent with what the kernel does.
|
| |
|
|
|
|
| |
This is what the kernel does in this instance.
|
|
|
|
| |
These are now entirely unused and can be removed.
|
|
|
|
|
| |
Like with the previous change, the kernel doesn't return NOT_AUTHORIZED
here. It returns INVALID_THREAD_PRIORITY.
|
|
|
|
|
|
| |
All priority checks are supposed to occur before checking the validity
of the thread handle, we're also not supposed to return
ERR_NOT_AUTHORIZED here.
|
|
|
|
|
| |
The kernel appears to return 0xE601 for this situation. Particularly in
svcWaitSynchronization, svcReplyAndReceive, and svcGetThreadContext
|
|
|
|
| |
The kernel appears to return 0xF601 for this case.
|
|\
| |
| | |
Added break types to svcBreak
|
| | |
|
| |
| |
| |
| | |
There seems to be more such as type 1, and 2. Unsure what these currently are but when a game hits them we can investigate and add the rest
|
|\ \
| |/
|/| |
kernel/process: Make the handle table per-process
|
| |
| |
| |
| |
| |
| |
| |
| | |
In the kernel, there isn't a singular handle table that everything gets
tossed into or used, rather, each process gets its own handle table that
it uses. This currently isn't an issue for us, since we only execute one
process at the moment, but we may as well get this out of the way so
it's not a headache later on.
|
|/
|
|
|
|
| |
This should be comparing against the queried process' vma_map, not the
current process'. The only reason this hasn't become an issue yet is we
currently only handle one process being active at any time.
|
|\
| |
| | |
svc: Add missing sanitizing checks for MapSharedMemory/UnmapSharedMemory
|
| |
| |
| |
| |
| |
| |
| |
| | |
Now that the changes clarifying the address spaces has been merged, we
can wrap the checks that the kernel performs when mapping shared memory
(and other forms of memory) into its own helper function and then use
those within MapSharedMemory and UnmapSharedMemory to complete the
sanitizing checks that are supposed to be done.
|
| |
| |
| |
| |
| | |
The kernel itself checks whether or not the provided addresses are word
aligned before continuing, so we should be doing the same.
|
|/
|
|
|
| |
Aligning on 4KB pages isn't a Switch-specific thing, so this can be
moved to common so it can be used with other things as well.
|
|\
| |
| | |
svc: Clarify enum values for AddressSpaceBaseAddr and AddressSpaceSize in svcGetInfo()
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
So, one thing that's puzzled me is why the kernel seemed to *not* use
the direct code address ranges in some cases for some service functions.
For example, in svcMapMemory, the full address space width is compared
against for validity, but for svcMapSharedMemory, it compares against
0xFFE00000, 0xFF8000000, and 0x7FF8000000 as upper bounds, and uses
either 0x200000 or 0x8000000 as the lower-bounds as the beginning of the
compared range. Coincidentally, these exact same values are also used in
svcGetInfo, and also when initializing the user address space, so this
is actually retrieving the ASLR extents, not the extents of the address
space in general.
|
|/ |
|
|\
| |
| | |
svc: Implement svcGetProcessInfo
|
| |
| |
| |
| |
| |
| |
| | |
A fairly basic service function, which only appears to currently support
retrieving the process state. This also alters the ProcessStatus enum to
contain all of the values that a kernel process seems to be able of
reporting with regards to state.
|
|/
|
|
| |
This should help diagnose crashes easier and prevent many users thinking that a game is still running when in fact it's just an audio thread still running(this is typically not killed when svcBreak is hit since the game expects us to do this)
|
|\
| |
| | |
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.
|
|\ \
| | |
| | | |
svc: Fix typos in sanitizing checks for MapMemory/UnmapMemory
|
| |/ |
|
|\ \
| | |
| | | |
Fixed incorrect types for svcBreak
|
| | | |
|
| | |
| | |
| | |
| | | |
signal_debugger seems like a more fitting name
|
| | |
| | |
| | |
| | | |
svcBreak reason should be a u32, not a u64.
|
| |/
|/|
| |
| |
| |
| | |
Regular value initialization is adequate here for zeroing out data. It
also has the benefit of not invoking undefined behavior if a non-trivial
type is ever added to the struct for whatever reason.
|
| |
| |
| |
| |
| |
| |
| |
| | |
This adds the missing address range checking that the service functions
do before attempting to map or unmap memory. Given that both service
functions perform the same set of checks in the same order, we can wrap
these into a function and just call it from both functions, which
deduplicates a little bit of code.
|
|/
|
|
|
|
|
|
|
|
|
| |
There's no real need to use a shared pointer in these cases, and only
makes object management more fragile in terms of how easy it would be to
introduce cycles. Instead, just do the simple thing of using a regular
pointer. Much of this is just a hold-over from citra anyways.
It also doesn't make sense from a behavioral point of view for a
process' thread to prolong the lifetime of the process itself (the
process is supposed to own the thread, not the other way around).
|
| |
|
| |
|
|
|
|
| |
When loading NROs, svcBreak is called to signal to the debugger that a new "module" is loaded. As no debugger is technically attached we shouldn't be killing the programs execution.
|
| |
|
|
|
|
| |
This will allow us to easily remove the use of "NFC" in "System"
|
|
|
|
|
|
|
|
|
| |
This was the result of a typo accidentally introduced in
e51d715700a35a8f14e5b804b6f7553c9a40888b. This restores the previous
correct behavior.
The behavior with the reference was incorrect and would cause some games
to fail to boot.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Conceptually, it doesn't make sense for a thread to be able to persist
the lifetime of a scheduler. A scheduler should be taking care of the
threads; the threads should not be taking care of the scheduler.
If the threads outlive the scheduler (or we simply don't actually
terminate/shutdown the threads), then it should be considered a bug
that we need to fix.
Attributing this to balika011, as they opened #1317 to attempt to fix
this in a similar way, but my refactoring of the kernel code caused
quite a few conflicts.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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.
|
|
|
|
|
|
|
|
|
| |
Now that we have all of the rearranging and proper structure sizes in
place, it's fairly trivial to implement svcGetThreadContext(). In the
64-bit case we can more or less just write out the context as is, minus
some minor value sanitizing. In the 32-bit case we'll need to clear out
the registers that wouldn't normally be accessible from a 32-bit
AArch32 exectuable (or process).
|
|
|
|
|
|
|
|
|
|
|
| |
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).
|
|
|
|
|
|
|
| |
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.
|
|\
| |
| | |
kernel/object: Remove unnecessary std::move from DynamicObjectCast()
|
| |
| |
| |
| |
| |
| |
| |
| |
| | |
boost::static_pointer_cast for boost::intrusive_ptr (what SharedPtr is),
takes its parameter by const reference. Given that, it means that this
std::move doesn't actually do anything other than obscure what the
function's actual behavior is, so we can remove this. To clarify, this
would only do something if the parameter was either taking its argument
by value, by non-const ref, or by rvalue-reference.
|
|\ \
| |/
|/| |
process/vm_manager: Initial modifications to load NPDM metadata
|
| |
| |
| |
| |
| |
| |
| |
| | |
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.
|
| |
| |
| |
| |
| |
| | |
Previously, these were reporting hardcoded values, but given the regions
can change depending on the requested address spaces, these need to
report the values that the memory manager contains.
|
| |
| |
| |
| |
| | |
Given games can also request a 32-bit or 39-bit address space, we
shouldn't be hardcoding the address space range as 36-bit.
|
| |
| |
| |
| |
| |
| |
| |
| |
| | |
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.
|
|\ \
| | |
| | | |
kernel/scheduler: Take ARM_Interface instances by reference
|
| |/
| |
| |
| |
| | |
It doesn't make sense to allow a scheduler to be constructed around a
null pointer.
|
|\ \
| |/
|/| |
svc: Updated svc names
|
| | |
|
| |
| |
| |
| |
| | |
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.
|
| |
| |
| |
| |
| |
| | |
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()
|
| |/
| |
| |
| |
| |
| |
| | |
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.
|
|/
|
|
|
|
| |
Avoids an unnecessary inclusion and also uncovers three places where
indirect inclusions were relied upon, which allows us to also resolve
those.
|
|\
| |
| | |
svc_wrap: Convert the PARAM macro into a function
|
| |
| |
| |
| |
| |
| | |
This can just be a regular function, getting rid of the need to also
explicitly undef the define at the end of the file. Given FuncReturn()
was already converted into a function, it's #undef can also be removed.
|
|\ \
| | |
| | | |
kernel/svc: Handle invalid address cases within svcArbitrateLock() and svcArbitrateUnlock()
|
| | |
| | |
| | |
| | |
| | |
| | | |
We already have a ResultCode constant for the case of an invalid
address, so we can just use it instead of re-rolling that ResultCode
type.
|
| |/
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
The kernel does the equivalent of the following check before proceeding:
if (address + 0x8000000000 < 0x7FFFE00000) {
return ERR_INVALID_MEMORY_STATE;
}
which is essentially what our IsKernelVirtualAddress() function does. So
we should also be checking for this.
The kernel also checks if the given input addresses are 4-byte aligned,
however our Mutex::TryAcquire() and Mutex::Release() functions already
handle this, so we don't need to add code for this case.
|
|/
|
|
|
|
|
|
|
| |
This modifies the CPU interface to more accurately match an
AArch64-supporting CPU as opposed to an ARM11 one. Two of the methods
don't even make sense to keep around for this interface, as Adv Simd is
used, rather than the VFP in the primary execution state. This is
essentially a modernization change that should have occurred from the
get-go.
|
|\
| |
| | |
kernel/errors: Amend error code for ERR_NOT_FOUND
|
| |
| |
| |
| |
| | |
This is the value returned by the kernel for svcConnectToNamedPort() if
the named port cannot be found.
|
|\ \
| | |
| | | |
kernel/svc: Handle a few error cases within memory-related functions
|
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | | |
The kernel caps the size limit of shared memory to 8589930496 bytes (or
(1GB - 512 bytes) * 8), so approximately 8GB, where every GB has a 512
byte sector taken off of it.
It also ensures the shared memory is created with either read or
read/write permissions for both permission types passed in, allowing the
remote permissions to also be set as "don't care".
|
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | | |
Part of the checking done by the kernel is to check if the given
address and size are 4KB aligned, as well as checking if the size isn't
zero. It also only allows mapping shared memory as readable or
read/write, but nothing else, and so we shouldn't allow mapping as
anything else either.
|
| | |
| | |
| | |
| | |
| | | |
The kernel checks if the addresses and given size is 4KB aligned before
continuing onwards to map the memory.
|
| |/
| |
| |
| |
| | |
The kernel checks if the given size is a multiple of 2MB and <= to 4GB
before going ahead and attempting to allocate that much memory.
|
|\ \
| | |
| | | |
Port #4192 from Citra: "svc: change unknown to thread in CreateThread"
|
| | | |
|
|/ / |
|
|/
|
|
|
|
| |
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.
|
|\
| |
| | |
kernel/errors: Amend invalid thread priority and invalid processor ID error codes
|
| |
| |
| |
| | |
This is what the kernel does for an out-of-range processor ID.
|
| | |
|
| |
| |
| |
| |
| |
| | |
While unlikely, it does avoid constructing a std::string and
unnecessarily calling into the memory code if a game or executable
decides to be really silly about their logging.
|
|/
|
|
| |
This should be a u64 to represent size.
|
|
|
|
|
|
|
|
|
|
| |
Given we now have the kernel as a class, it doesn't make sense to keep
the current process pointer within the System class, as processes are
related to the kernel.
This also gets rid of a subtle case where memory wouldn't be freed on
core shutdown, as the current_process pointer would never be reset,
causing the pointed to contents to continue to live.
|
|
|
|
|
|
| |
Now that we have a class representing the kernel in some capacity, we
now have a place to put the named port map, so we move it over and get
rid of another piece of global state within the core.
|
|
|
|
|
|
|
|
|
|
|
| |
The follow-up to e2457418dae19b889b2ad85255bb95d4cd0e4bff, 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.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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/error: Amend several error codes
|
| |
| |
| |
| |
| |
| | |
We can make this error code an alias of the resource limit exceeded
error code, allowing us to get rid of the lingering 3DS error code of
the same type.
|
| |
| |
| |
| |
| | |
We can treat this as an alias of TooLarge for documentation purposes.
This also lets us get rid of another lingering 3DS-related error code.
|
| |
| |
| |
| |
| | |
This replaces the lingering 3DS constant with the proper one, and
utilizes it within HandleTable's Create() member function.
|
| | |
|
| | |
|
|\ \
| | |
| | | |
core: Namespace all code in the arm subdirectory under the Core namespace
|
| |/
| |
| |
| | |
Gets all of these types and interfaces out of the global namespace.
|
|/
|
|
|
|
| |
We already have the variable itself set up to perform this task, so we
can just return its value from the currently executing process instead
of always stubbing it to zero.
|
|\
| |
| | |
Core::CoreTiming: add UnscheduleEventThreadsafe
|
| | |
|
| |
| |
| |
| |
| |
| | |
Allows querying the inverse of IsDomain() to make things more readable.
This will likely also be usable in the event of implementing
ConvertDomainToSession().
|
|/
|
|
|
|
| |
Given if we hit here all is lost, we should probably be logging the
break reason code and associated information to distinguish between the
causes.
|
|
|
|
|
|
|
|
|
|
| |
Despite being covered by a global mutex, we should still ensure that the
class handles its reference counts properly. This avoids potential
shenanigans when it comes to data races.
Given this is the root object that drives quite a bit of the kernel
object hierarchy, ensuring we always have the correct behavior (and no
races) is a good thing.
|
|\
| |
| | |
Use an approximated amortized amount of ticks when advancing timing.
|
| |
| |
| |
| | |
The current core may have nothing to do with the core where the new thread was scheduled to run. In case it's the same core, then the following PrepareReshedule call will take care of that.
|
|\ \
| | |
| | | |
scheduler: Make HaveReadyThreads() a const member function
|
| |/
| |
| |
| |
| | |
This function doesn't modify instance state, so the const qualifier can
be added to it.
|
|\ \
| | |
| | | |
Fixed a bunch of race conditions when running in multicore mode.
|
| | |
| | |
| | |
| | | |
Another thread might be in the middle of a reschedule, thus altering the state of the schedulers.
|
| |/
| |
| |
| |
| |
| | |
WakeAfterDelay might be called from any host thread, so err on the side of caution and use the thread-safe CoreTiming::ScheduleEventThreadsafe.
Note that CoreTiming is still far from thread-safe, there may be more things we have to work on for it to be up to par with what we want.
|
|/
|
|
|
|
|
|
|
|
| |
Exit from AddMutexWaiter early if the thread is already waiting for a mutex owned by the owner thread.
This accounts for the possibility of a thread that is waiting on a condition variable being awakened twice in a row.
Also added more validation asserts.
This should fix one of the random crashes in Breath Of The Wild.
|
| |
|
|
|
|
|
| |
This function doesn't modify anything within the reference Thread
instance.
|
|
|
|
|
|
|
|
| |
These members don't need to be entirely exposed, we can instead expose
an API to operate on them without directly needing to mutate them
We can also guard against overflow/API misuse this way as well, given
active_sessions is an unsigned value.
|
|
|
|
|
| |
Instead we can simply provide accessors to the required data instead of
giving external read/write access to the variables directly.
|
|
|
|
|
| |
In all cases the vector being supplied is empty, so we can just return
by value in these instances.
|
|\
| |
| | |
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.
|
|/
|
|
|
|
| |
This amends cases where crashes can occur that were missed due to the
odd way the previous code was set up (using 3DS memory regions that
don't exist).
|
|
|
|
| |
Removes leftover code from citra that isn't needed.
|
|\
| |
| | |
kernel: Move object class to its own source files
|
| |
| |
| |
| |
| |
| | |
General moving to keep kernel object types separate from the direct
kernel code. Also essentially a preliminary cleanup before eliminating
global kernel state in the kernel code.
|
|\ \
| | |
| | | |
kernel/thread: Minor changes
|
| | |
| | |
| | |
| | |
| | |
| | | |
Avoids using a u32 to compare against a range of size_t, which can be a
source of warnings. While we're at it, compress a std::tie into a
structured binding.
|
| | |
| | |
| | |
| | |
| | | |
This function only reads the data being referenced, it doesn't modify
it, so we can turn the reference into a const reference.
|
| |/
| |
| |
| |
| | |
This function isn't used outside of this translation unit, so we can
make it internally linked.
|
| | |
|
| |
| |
| |
| | |
Makes our immutable state explicit.
|
|/
|
|
| |
These two variables correspond to address ranges.
|
|
|
|
|
| |
Given there's no implementation, we may as well remove the code
entirely.
|
|\
| |
| | |
kernel: Remove unused object_address_table.cpp/.h
|
| |
| |
| |
| |
| |
| | |
These source files were entirely unused throughout the rest of the
codebase. This also has the benefit of getting rid of a global variable
as well.
|
|/
|
|
|
| |
Removes unnecessary direct dependencies in some headers and also gets
rid of indirect dependencies that were being relied on to be included.
|
|
|
|
|
| |
Instead, we can just expose functions that return the queryable state
instead of letting anything modify it.
|
|\
| |
| | |
svc: Log parameters in SetMemoryAttribute()
|
| |
| |
| |
| | |
Provides slightly more context than only logging out the address value.
|
|\ \
| | |
| | | |
core_timing: Split off utility functions into core_timing_util
|
| | | |
|
| |/
|/|
| |
| |
| | |
The loop's induction variable was signed, but we were comparing against
an unsigned variable.
|
|\ \
| |/
|/| |
mutex: Pass SharedPtr to GetHighestPriorityMutexWaitingThread() by reference
|
| |
| |
| |
| |
| | |
The pointed to thread's members are simply observed in this case, so we
don't need to copy it here.
|
|/ |
|
|
|
|
|
| |
This is just an unused hold-over from citra, so we can get rid of this
to trim off an exposed global, among other things.
|
|
|
|
| |
This is a holdover from citra that's essentially unused.
|
| |
|
|\
| |
| | |
CPU: Save and restore the TPIDR_EL0 system register on every context switch
|
| |
| |
| |
| | |
Note that there's currently a dynarmic bug preventing this register from being written.
|
|/
|
|
|
| |
Makes the thread status strongly typed, so implicit conversions can't
happen. It also makes it easier to catch mistakes at compile time.
|
|\
| |
| | |
hle_ipc: Introduce generic WriteBuffer overload for multiple container types
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
This introduces a slightly more generic variant of WriteBuffer().
Notably, this variant doesn't constrain the arguments to only accepting
std::vector instances. It accepts whatever adheres to the
ContiguousContainer concept in the C++ standard library.
This essentially means, std::array, std::string, and std::vector can be
used directly with this interface. The interface no longer forces you to
solely use containers that dynamically allocate.
To ensure our overloads play nice with one another, we only enable the
container-based WriteBuffer if the argument is not a pointer, otherwise
we fall back to the pointer-based one.
|
|\ \
| |/
|/| |
svc: Correct always true assertion case in SetThreadCoreMask
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
The reason this would never be true is that ideal_processor is a u8 and
THREADPROCESSORID_DEFAULT is an s32. In this case, it boils down to how
arithmetic conversions are performed before performing the comparison.
If an unsigned value has a lesser conversion rank (aka smaller size)
than the signed type being compared, then the unsigned value is promoted
to the signed value (i.e. u8 -> s32 happens before the comparison). No
sign-extension occurs here either.
An alternative phrasing:
Say we have a variable named core and it's given a value of -2.
u8 core = -2;
This becomes 254 due to the lack of sign. During integral promotion to
the signed type, this still remains as 254, and therefore the condition
will always be true, because no matter what value the u8 is given it
will never be -2 in terms of 32 bits.
Now, if one type was a s32 and one was a u32, this would be entirely
different, since they have the same bit width (and the signed type would
be converted to unsigned instead of the other way around) but would
still have its representation preserved in terms of bits, allowing the
comparison to be false in some cases, as opposed to being true all the
time.
---
We also get rid of two signed/unsigned comparison warnings while we're
at it.
|
|/
|
|
|
|
|
|
|
| |
Previously, the buffer_index parameter was unused, causing all writes to
use the buffer index of zero, which is not necessarily what is wanted
all the time.
Thankfully, all current usages don't use a buffer index other than zero,
so this just prevents a bug before it has a chance to spring.
|
|\
| |
| | |
address_arbiter: Correct assignment within an assertion statement in WakeThreads()
|
| |
| |
| |
| |
| |
| | |
This was introduced within 4f81bc4e1bd12e4df7410c6790ba818d8dbba9c0, and
considering there's no comment indicating that this is intentional, this
is very likely a bug.
|
|\ \
| | |
| | | |
core/memory, core/hle/kernel: Use std::move where applicable
|
| |/
| |
| |
| | |
Avoids pointless copies
|
|\ \
| | |
| | | |
vm_manager: Add missing commas to string literal array elements in GetMemoryStateName()
|
| |/
| |
| |
| |
| | |
Without these, this would perform concatenation, which is definitely not
what we want here.
|
|/
|
|
|
|
|
|
|
| |
This would result in a lot of allocations and related object
construction, just to toss it all away immediately after the call.
These are definitely not intentional, and it was intended that all of
these should have been accessing the static function GetInstance()
through the name itself, not constructed instances.
|
|\
| |
| | |
scheduler: Clear exclusive state when switching contexts
|
| | |
|
|\ \
| | |
| | | |
svc:: Fix bug in svcWaitForAddress
|
| |/ |
|
|/ |
|
| |
|
| |
|
| |
|
|\
| |
| | |
svc: Fully implement svcSignalToAddress and svcWaitForAddress
|
| | |
|
| | |
|
| | |
|
| | |
|
| | |
|
| | |
|
| | |
|
| | |
|
| | |
|
|/
|
|
| |
prevent yuzu crash, if games, like Axiom Verge, trying to read 0 bytes from file
|
| |
|
|\
| |
| | |
svc: Add a stub for UserExceptionContextAddr.
|
| | |
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
This situation may happen like so:
Thread 1 with low priority calls WaitProcessWideKey with timeout.
Thread 2 with high priority calls WaitProcessWideKey without timeout.
Thread 3 calls SignalProcessWideKey
- Thread 2 acquires the lock and awakens.
- Thread 1 can't acquire the lock and is put to sleep with the lock owner being Thread 2.
Thread 1's timeout expires, with the lock owner still being set to Thread 2.
|
| | |
|
| |
| |
| |
| | |
Also added some proper error handling.
|
| | |
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
* add some InfoType
* correct OpenApplicationProxy cmd number
* add IDisplayController functions
* fix clang-format
* add more system languages
|
|\ \
| | |
| | | |
Kernel/SVC: Signal the highest priority threads first in svcSignalProcessWideKey
|
| | | |
|
| | | |
|
| | | |
|
|\ \ \
| | | |
| | | | |
Mutex: Do not assert when the mutex waiting threads list isn't empty on mutex release.
|
| |/ /
| | |
| | |
| | | |
A thread may own multiple mutexes at the same time, and only release one of them while other threads are waiting for the other mutexes.
|
|/ / |
|
| | |
|
| | |
|
| | |
|
| | |
|
| | |
|
| | |
|
| | |
|
| | |
|
| | |
|
| | |
|
|\ \
| | |
| | | |
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).
|
|/ /
| |
| |
| | |
- This can be used for domain objects as inputs to service functions.
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
* GetSharedFontInOrderOfPriority
* Update pl_u.cpp
* Ability to use ReadBuffer and WriteBuffer with different buffer indexes, fixed up GetSharedFontInOrderOfPriority
* switched to NGLOG
* Update pl_u.cpp
* Update pl_u.cpp
* language_code is actually language code and not index
* u32->u64
* final cleanups
|
| |
| |
| |
| | |
All of these variables and functions are related to timings and should be within the namespace.
|
| |
| |
| |
| | |
Given we utilize fmt, we don't need to provide our own functions for formatting anymore
|
| | |
|
| | |
|
| |
| |
| |
| | |
Functions don't need to be terminated by semicolons.
|
| | |
|
|\ \
| | |
| | | |
Kernel: Reworked the new kernel synchronization primitives.
|
| | |
| | |
| | |
| | |
| | |
| | |
| | | |
Verified with a hwtest and implemented based on reverse engineering.
Thread A's priority will get bumped to the highest priority among all the threads that are waiting for a mutex that A holds.
Once A releases the mutex and ownership is transferred to B, A's priority will return to normal and B's priority will be bumped.
|
| | | |
|
| | | |
|
| | | |
|
| | | |
|
| | |
| | |
| | |
| | | |
They work in tandem with guest code to provide synchronization primitives along with svcArbitrateLock/Unlock
|
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | | |
Switch mutexes are no longer kernel objects, they are managed in userland and only use the kernel to handle the contention case.
Mutex addresses store a special flag value (0x40000000) to notify the guest code that there are still some threads waiting for the mutex to be released. This flag is updated when a thread calls ArbitrateUnlock.
TODO:
* Fix svcWaitProcessWideKey
* Fix svcSignalProcessWideKey
* Remove the Mutex class.
|
|/ /
| |
| |
| | |
Prevents enum identifiers from leaking into the surrounding scope.
|
| |
| |
| |
| | |
C++17 has non-member size() which we can just call where necessary.
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
* Updated ACC with more service names
* Updated SVC with more service names
* Updated set with more service names
* Updated sockets with more service names
* Updated SPL with more service names
* Updated time with more service names
* Updated vi with more service names
|
| |
| |
| |
| | |
- Gets Binding of Isaac running.
|
| | |
|
| | |
|
| | |
|
| | |
|
| | |
|
| | |
|
| | |
|
| | |
|
| | |
|
| | |
|
| | |
|
| | |
|
| | |
|
| | |
|
| | |
|
| | |
|
| | |
|
| | |
|
| | |
|
| | |
|
| | |
|
|\ \
| | |
| | | |
Implemented the SaveData archive and MountSaveData.
|
| |/
| |
| |
| | |
There may be many CodeSets per Process, so it's wasteful and overcomplicated to store the program id in each of them.
|
|/ |
|
|\
| |
| | |
IPC: add domain header to response if only it exists in request
|
| | |
|
| | |
|
| | |
|
|\ \
| | |
| | | |
UnmapSharedMemory
|
| | | |
|
| |/
| |
| |
| |
| |
| |
| |
| | |
C++11 requires spaces on the Identifier
Add inttypes include
clang
|
|/ |
|
| |
|
| |
|
| |
|
| |
|
|
|
|
|
|
|
|
| |
Ported from citra PR #3091
The delay specified here is from a Nintendo 3DS, and should be measured in a Nintendo Switch.
This change is enough to prevent Puyo Puyo Tetris's main thread starvation.
|
| |
|
| |
|
|\
| |
| | |
Refactor IPC buffer descriptor interface
|
| | |
|
| | |
|
| | |
|
| | |
|
| | |
|
|/ |
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
|\
| |
| | |
memory: Replace all memory hooking with Special regions
|
| | |
|
| | |
|
| | |
|
| | |
|
| | |
|
| | |
|
|/ |
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
| |
* Added svcCreateSharedMemory
* Services which are not implemented now throw UNIMPLEMENTED()
* clang-format
* changed perms to u32
* removed camelcase
|
|
|
|
|
|
|
|
| |
* Fixes some cast warnings, partially fixes citra #3064
* Converted casts to uint32_t to u32
* Ran clang-format
|
| |
|
| |
|
|
|
|
|
|
|
|
|
|
| |
* Stub PopLaunchParameter and implement Buffer C Descriptors reading
* Address PR feedback
* Ensure we push a u64 not a size_t
* Fix formatting
|
|
|
|
| |
Makes the codebase a little more consistent with regards to available documentation. Also amends the duplicate case where there was a similar entry at 0x72 named ConnectToPort.
|
|
|
|
| |
Makes the table match SwitchBrew for these entries
|
| |
|
| |
|
| |
|
|
|
|
|
| |
# Conflicts:
# src/core/hle/kernel/svc.cpp
|
| |
|
| |
|
|\
| |
| | |
added more svcGetInfo pairs for 3.0.0+ support, Changed HEAP_SIZE and TLS_AREA_VADDR. changed mem usage & heap usage stub added, ISelfController, IApplication function stubs. Added SetThreadCoreMask
|
| | |
|
| | |
|
|/ |
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
|
|
|
|
|
| |
Also properly keep track of data in guest memory, this fixes managing the semaphore from userland.
It was found that Semaphores are actually Condition Variables, with Release(1) and Release(-1) being equivalent to notify_one and notify_all. We should change the name of the class to reflect this.
|
| |
|
| |
|
|
|
|
| |
* CoreTiming: New CoreTiming; Add Test for CoreTiming
|
| |
|
| |
|
|
|
|
| |
Popping objects from the buffer is still not implemented.
|
|
|
|
| |
Service code now doesn't have to deal with this.
|
|
|
|
| |
Domain object ids are always stored immediately after the raw data.
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
|
|
|
| |
This is kinda crufty, but we need it for now to update guest state variables.
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
|\
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
# 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
|
| |\
| | |
| | | |
SharedMemory: Don't take over and unmap the source memory block when creating a shared memory, just reference it
|
| | |
| | |
| | |
| | | |
Also reference the right offset into the backing block for the requested address.
|
| |\ \
| | |/
| |/| |
Memory: Add overloads for ReadBlock and WriteBlock that operate on a specific process.
|
| | | |
|
| |\ \
| | |/
| |/| |
Kernel/Threads: When putting a thread to wait, specify a function to execute when it is awoken
|
| | |
| | |
| | |
| | |
| | |
| | | |
This change makes for a clearer (less confusing) path of execution in the scheduler, now the code to execute when a thread awakes is closer to the code that puts the thread to sleep (WaitSynch1, WaitSynchN). It also allows us to implement the special wake up behavior of ReplyAndReceive without hacking up WaitObject::WakeupAllWaitingThreads.
If savestates are desired in the future, we can change this implementation to one similar to the CoreTiming event system, where we first register the callback functions at startup and assign their identifiers to the Thread callback variable instead of directly assigning a lambda to the wake up callback variable.
|
| | | |
|
| |/
| |
| |
| | |
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.
|
| |
| |
| |
| | |
Don't expose Memory::current_page_table as a global.
|
| |\
| | |
| | | |
Kernel/Memory: Give each process its own page table and allow switching the current page table upon reschedule
|
| | |
| | |
| | |
| | | |
We were unnecessarily clearing the cache when going from Process A -> Idle -> Process A, this caused extreme performance regressions.
|
| | | |
|
| | | |
|
| | |
| | |
| | |
| | | |
The loader is in charge of setting the newly created process's page table as the main one during the loading process.
|
| |\ \
| | | |
| | | | |
Kernel/HLE: Use a mutex to synchronize access to the HLE kernel state between the cpu thread and any other possible threads that might touch the kernel (network thread, etc).
|
| | | |
| | | |
| | | |
| | | | |
This mutex is acquired in SVC::CallSVC, ie, as soon as the guest application enters the HLE kernel, and should be acquired by the aforementioned threads before modifying kernel structures.
|
| |\ \ \
| | | | |
| | | | | |
Kernel/Threads: Don't immediately switch to the new main thread when loading a new process.
|
| | | |/
| | |/|
| | | |
| | | |
| | | | |
This is necessary for loading multiple processes at the same time.
The main thread will be automatically scheduled when necessary once the scheduler runs.
|
| |/ / |
|
| | | |
|
| | | |
|
| | | |
|
| | | |
|
|/ / |
|
|\ \
| |/
|/| |
Add address conversion functions returning optional, Add function to flush virtual region from rasterizer cache
|
| |
| |
| |
| | |
And fix a few places in the code to take advantage of that.
|
|\ \
| | |
| | | |
Kernel/SVC: Partially implemented svcReplyAndReceive
|
| | | |
|
| | | |
|
| | | |
|
| | | |
|
| |/
|/|
| |
| |
| | |
Missed this in my first implementation. Thanks to @wwylele for pointing
out that this was missing.
|
|\ \
| | |
| | | |
Trivial no-op additions
|
| |/ |
|
|\ \
| | |
| | | |
Remove ResultVal::MoveFrom
|
| |/
| |
| |
| |
| | |
Replace it with std::move(result_val).Unwrap(), or Foo().Unwrap() in
case you already have an rvalue.
|
|/ |
|
| |
|
|
|
|
|
| |
Reduces the necessary allocation to max(in_handles, out_handles) rather
than (in_handles + out_handles).
|
| |
|
| |
|
|
|
|
|
|
| |
Copy the IPC command buffer to/from the request context before/after the
handler is invoked. This is part of a move away from using global data
for handling IPC requests.
|
|\
| |
| | |
New service framework
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
The old "Interface" class had a few problems such as using free
functions (Which didn't allow you to write the service handler as if it
were a regular class.) which weren't very extensible. (Only received one
parameter with a pointer to the Interface object.)
The new ServiceFramework aims to solve these problems by working with
member functions and passing a generic context struct as parameter. This
struct can be extended in the future without having to update all
existing service implementations.
|
| | |
|
| | |
|
|/
|
|
| |
Fixes #2760
|
|
|
|
|
|
| |
This allows attaching a HLE handle to a ServerPort at any point after it
is created, allowing port/session creation to be generic between HLE and
regular services.
|
|
|
|
|
| |
Most of the code that works with this is or will be in the kernel, so
it's a more appropriate place for it to be.
|
| |
|
|
|
|
|
| |
Now that HandleTable doesn't directly depend on WaitObject anymore, this
can be separated from the main kernel.h header.
|
|
|
|
|
| |
This isn't necessary anymore since plain Get works correctly for
WaitObjects.
|
| |
|
| |
|
|\
| |
| | |
Kernel: Properly update port counters on session disconnection.
|
| |
| |
| |
| | |
It is not meant to be used by anything other than CreateSessionPair.
|
| | |
|
| |
| |
| |
| | |
Reduce the associated port's connection count when a ServerSession is destroyed.
|
| |
| |
| |
| |
| |
| |
| | |
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.
|
|/
|
|
| |
Also move address space mapping out of video_core.
|
| |
|
| |
|
|
|
|
|
|
|
|
|
| |
Corrects a few issues with regards to Doxygen documentation, for example:
- Incorrect parameter referencing.
- Missing @param tags.
- Typos in @param tags.
and a few minor other issues.
|
|\
| |
| | |
Replace built-in Profiler with indicators in status bar
|
| | |
|
|/ |
|
| |
|
| |
|
|\
| |
| | |
Kernel: Implemented Pulse event and timers.
|
| |
| |
| |
| | |
Closes #1904
|
|\ \
| | |
| | | |
Don't yield execution in SleepThread(0) if there are no available threads to run
|
| | |
| | |
| | |
| | | |
With this we avoid an useless temporary deschedule of the current thread.
|
|\ \ \
| | | |
| | | | |
Kernel/Semaphore: Fixed a regression in semaphore waits.
|
| |/ /
| | |
| | |
| | |
| | |
| | | |
The regression was caused by a missing check in #2260.
The new behavior is consistent with the real kernel.
|
|\ \ \
| | | |
| | | | |
Kernel: Removed the priority boost code for starved threads.
|
| |/ /
| | |
| | |
| | |
| | |
| | | |
After hwtesting and reverse engineering the kernel, it was found that the CTROS scheduler performs no priority boosting for threads like this, although some other forms of scheduling priority-starved threads might take place.
For example, it was found that hardware interrupts might cause low-priority threads to run if the CPU is preempted in the middle of an SVC handler that deschedules the current (high priority) thread before scheduling it again.
|
|/ / |
|
| | |
|
| |
| |
| |
| | |
This fixes a potential bug where threads would not get removed from said list if they awoke after waiting with WaitSynchronizationN with wait_all = false
|
| | |
|
| |
| |
| |
| |
| |
| |
| |
| | |
This commit removes the overly general THREADSTATUS_WAIT_SYNCH and replaces it with two more granular statuses:
THREADSTATUS_WAIT_SYNCH_ANY when a thread waits on objects via WaitSynchronization1 or WaitSynchronizationN with wait_all = false.
THREADSTATUS_WAIT_SYNCH_ALL when a thread waits on objects via WaitSynchronizationN with wait_all = true.
|
| | |
|
| | |
|
| |
| |
| |
| |
| |
| |
| | |
The implementation is based on reverse engineering of the 3DS's kernel.
A mutex holder's priority will be temporarily boosted to the best priority among any threads that want to acquire any of its held mutexes.
When the holder releases the mutex, it's priority will be boosted to the best priority among the threads that want to acquire any of its remaining held mutexes.
|
| |
| |
| |
| | |
This will be useful when implementing mutex priority inheritance.
|
|/
|
|
| |
Not all syscalls should cause reschedules, this commit attempts to remedy that, however, it still does not cover all cases.
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
|\
| |
| | |
Threading: Reworked the way our scheduler works.
|
| | |
|
| | |
|
| |
| |
| |
| |
| |
| | |
Define a variable with the value of the sync timeout error code.
Use a boost::flat_map instead of an unordered_map to hold the equivalence of objects and wait indices in a WaitSynchN call.
|
| | |
|
| | |
|
| | |
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
Threads will now be awakened when the objects they're waiting on are signaled, instead of repeating the WaitSynchronization call every now and then.
The scheduler is now called once after every SVC call, and once after a thread is awakened from sleep by its timeout callback.
This new implementation is based off reverse-engineering of the real kernel.
See https://gist.github.com/Subv/02f29bd9f1e5deb7aceea1e8f019c8f4 for a more detailed description of how the real kernel handles rescheduling.
|
| | |
|
| | |
|
| |
| |
| |
| |
| |
| | |
Further implementation will happen in a future commit.
Fixes a regression.
|
| | |
|
| |
| |
| |
| | |
The error code was taken from the 3DS kernel.
|
| |
| |
| |
| | |
HandleSyncRequest now takes care of calling the command buffer translate function before actually invoking the command handler for HLE services.
|
| | |
|
| | |
|
| | |
|
| | |
|
| |
| |
| |
| |
| |
| |
| | |
Sessions and Ports are now detached from each other.
HLE services are handled by means of a SessionRequestHandler class, Interface now inherits from this class.
The File and Directory classes are no longer kernel objects, but SessionRequestHandlers instead, bound to a ServerSession when requested.
File::OpenLinkFile now creates a new session pair and binds the File instance to it.
|
| |
| |
| |
| | |
Pass the triggering ServerSession to the HLE command handler to differentiate which session caused the request.
|
| |
| |
| |
| | |
Interface is now used by aggregation in ClientPort, to forward service commands to their HLE implementation if needed.
|
| | |
|
|/
|
|
|
|
|
| |
All handles obtained via srv::GetServiceHandle or svcConnectToPort are references to ClientSessions.
Service modules will wait on the counterpart of those ClientSessions (Called ServerSessions) using svcReplyAndReceive or svcWaitSynchronization[1|N], and will be awoken when a SyncRequest is performed.
HLE Interfaces are now ClientPorts which override the HandleSyncRequest virtual member function to perform command handling immediately.
|
|\
| |
| | |
Kernel/Loader: Grab the system mode from the NCCH ExHeader.
|
| |
| |
| |
| |
| |
| |
| | |
3dsx and elf files default to system mode 2 (96MB allocated to the application).
This allows Home Menu to boot without modifications.
Closes #1849
|
|/
|
|
| |
Related to #1904
|
| |
|
| |
|
| |
|
| |
|
|
|
|
|
|
|
| |
This makes clang-format useful on those.
Also add a bunch of forgotten transitive includes, which otherwise
prevented compilation.
|
| |
|
| |
|
| |
|
| |
|
|\
| |
| | |
Switch context to the same thread if necessary
|
| | |
|
|\ \
| | |
| | | |
srv: Update according 3dbrew
|
| |/ |
|
|\ \
| | |
| | | |
Thread: update timeout when reruning WaitSynch
|
| |/ |
|
| | |
|
|/
|
|
| |
This is part of an ongoing effort to implement support for multiple processes.
|
|\
| |
| | |
Memory: Remove most usages of GetPointer
|
| | |
|
|/ |
|
|\
| |
| | |
Set fpscr for new threads
|
| | |
|
|/
|
|
|
|
| |
Reserve enough space in the vector that holds the linear heap memory to prevent relocations of the backing memory when growing too much.
Closes #1790
|
|\
| |
| | |
Kernel: Implemented shared memory.
|
| | |
|
| | |
|
| | |
|
| | |
|
| | |
|
| |
| |
| |
| |
| |
| |
| | |
Applications can request the kernel to allocate a piece of the linear heap for them when creating a shared memory object.
Shared memory areas are now properly mapped into the target processes when calling svcMapMemoryBlock.
Removed the APT Shared Font hack as it is no longer needed.
|
| |
| |
| |
| | |
R0 is used as the last parameter instead of R4.
|
|\ \
| |/
|/| |
Kernel/Threads: Dynamically allocate the TLS region for threads.
|
| |
| |
| |
| |
| |
| | |
Each thread gets a 0x200-byte area from the 0x1000-sized page, when all 8 thread slots in a single page are used up, the kernel allocates a new page to hold another 8 entries.
This is consistent with what the real kernel does.
|
|\ \
| | |
| | | |
Kernel/Threading: Warn when a thread can be scheduled in the Syscore (Core 1)
|
| |/
| |
| |
| | |
We do not currently implement any cores other than the AppCore (Core 0).
|
|\ \
| |/
|/| |
hle: Get rid of direct global access to g_reschedule
|
| |
| |
| |
| |
| | |
This shouldn't be directly exposed if there's already a partial API that operates on it.
We can just provide the rest of that API.
|
|\ \
| | |
| | | |
Common: Remove Common::make_unique, use std::make_unique
|
| |/ |
|
|/ |
|
| |
|
| |
|
| |
|
|
|
|
|
|
|
|
|
| |
This commit:
* Adds a new subproject, audio_core.
* Defines structures that exist in DSP shared memory.
* Hooks up various other parts of the emulator into audio core.
This sets the foundation for a later HLE DSP implementation.
|
| |
|
| |
|
|
|
|
| |
This implementation will need to be (almost completely) changed when we implement multiprocess support.
|
|
|
|
| |
Closes #1139
|
|
|
|
| |
This was verified with hwtests that i plan to upload later on.
|
|
|
|
|
| |
This makes smealum/ctrulib@b96dd51d3349961189d4ab1bc2a5c45deff21c09 work
with Citra.
|
| |
|
| |
|
| |
|
|
|
|
| |
Typo which sneaked in through review on #1025
|
| |
|
|
|
|
| |
Should fix invalid read loops in some games
|
| |
|
|
|
|
|
| |
This also adds some basic memory usage accounting. These two types are
used by Super Smash Bros. during startup.
|
|
|
|
|
|
| |
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.
|
| |
|
|
|
|
|
| |
These helpers aren't really part of the kernel, and mem_map.cpp/h is
going to be moved there next.
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
|
|
|
| |
They'll be reset if needed during the next svcWaitSynchronization call (if there's any pending)
|
|
|
|
|
|
|
|
| |
This commit fixes several kernel object leaks. The most severe of them
was threads not being removed from the private handle table used for
CoreTiming events. This resulted in Threads never being released, which
in turn held references to Process, causing CodeSets to never be freed
when loading other applications.
|
|\
| |
| | |
Fix applet includes using iwyu
|
| | |
|
|/ |
|
|
|
|
|
|
| |
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.
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
|\
| |
| | |
Kernel: Add VMManager to manage process address spaces
|
| |
| |
| |
| |
| |
| |
| |
| | |
This enables more dynamic management of the process address space,
compared to just directly configuring the page table for major areas.
This will serve as the foundation upon which the rest of the Kernel
memory management functions will be built.
|
|/ |
|
| |
|
| |
|
|\
| |
| | |
core/video_core: Fix a few warnings when compiling on MSVC.
|
| |
| |
| |
| | |
Sign mismatches and "forcing value to bool" warnings.
|
| |
| |
| |
| |
| |
| | |
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.
|
| |
| |
| |
| |
| |
| |
| | |
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.
|
|/ |
|
|\
| |
| | |
Core/Memory: Add TLS support for creating up to 300 threads
|
| | |
|
|\ \
| | |
| | | |
Thread: Remove the idle thread
|
| | |
| | |
| | |
| | | |
Instead just use nullptr to represent no thread is active.
|
|\ \ \
| |_|/
|/| | |
Core/Scheduling: Prepare the new priority in the thread queue when svcSetPriority is called
|
| |/ |
|
|\ \
| |/
|/| |
Core/HLE: Implemented the SVCs GetProcessId and GetProcessIdOfThread
|
| | |
|
| | |
|
|/ |
|
|\
| |
| | |
Fix crashes due to un-initialized GSP shared memory
|
| |
| |
| |
| |
| |
| | |
This works around crashes related to GSP/HID/etc. shared memory blocks
having garbage values. The proper fix requires proper management of
mapped memory blocks in the process.
|
| | |
|
| | |
|
|/
|
|
|
| |
The TLS area for thread T with id Ti is located at TLS_AREA_VADDR + (Ti - 1) * 0x200.
This allows some games like Mario Kart 7 to continue further.
|
|
|
|
|
|
|
| |
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.
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
|
|
|
| |
This has been obsoleted by the field in Process.
|
| |
|
| |
|
| |
|
| |
|
| |
|
|
|
|
| |
- CreateMutex/ReleaseMutex/ReleaseSemaphore/SetTimer/CancelTimer/ArbitrateAddress
|
| |
|
|
|
|
|
|
| |
SVC: Return correct error code on invalid CreateThread processor ID.
SVC: Assert when creating a thread with an invalid userland priority.
|
| |
|
| |
|
| |
|
| |
|
|
|
|
|
|
|
| |
Involves making asserts use printf instead of the log functions (log functions are asynchronous and, as such, the log won't be printed in time)
As such, the log type argument was removed (printf obviously can't use it, and it's made obsolete by the file and line printing)
Also removed some GEKKO cruft.
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* Simplifies scheduling logic, specifically regarding thread status. It should be much clearer which statuses are valid
for a thread at any given point in the system.
* Removes dead code from thread.cpp.
* Moves the implementation of resetting a ThreadContext to the corresponding core's implementation.
Other changes:
* Fixed comments in arm interfaces.
* Updated comments in thread.cpp
* Removed confusing, useless, functions like MakeReady() and ChangeStatus() from thread.cpp.
* Removed stack_size from Thread. In the CTR kernel, the thread's stack would be allocated before thread creation.
|
| |
|
| |
|
|
|
|
|
| |
They're finally unnecessary, and will stop cluttering the application's
handle table.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
During normal operation, a thread waiting on an WaitObject and the
object hold mutual references to each other for the duration of the
wait.
If a process is forcefully terminated (The CTR kernel has a SVC to do
this, TerminateProcess, though no equivalent exists for threads.) its
threads would also be stopped and destroyed, leaving dangling pointers
in the WaitObjects.
The solution is to simply have the Thread remove itself from WaitObjects
when it is stopped. The vector of Threads in WaitObject has also been
changed to hold SharedPtrs, just in case. (Better to have a reference
cycle than a crash.)
|
|
|
|
|
|
| |
This should speed up compile times a bit, as well as enable more liberal
use of forward declarations. (Due to SharedPtr not trying to emit the
destructor anymore.)
|
| |
|
| |
|
| |
|
| |
|
|
|
|
| |
This is to support the removal of GetHandle soon
|
| |
|
| |
|
|
|
|
| |
Remove unnecessary/unused struct variables.
|
| |
|
| |
|
|
|
|
|
| |
It was only being used in two places, where it was replaced by a local
constant.
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
|
|
|
|
| |
- ReleaseNextThread->WakeupNextThread
- ReleaseAllWaitingThreads->WakeupAllWaitingThreads.
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
|
|
|
|
|
| |
- Separate wait checking from waiting the current thread
- Resume thread when wait_all=true only if all objects are available at once
- Set output to correct wait object index when there are duplicate handles
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
|\
| |
| | |
Thread: Prevent waking a thread multiple times.
|
| |
| |
| |
| | |
If a thread was woken up by something, cancel the wakeup timeout.
|
| | |
|
|/ |
|
| |
|
| |
|
| |
|
| |
|
| |
|
|\
| |
| | |
Implemented timers
|
| | |
|
| |
| |
| |
| | |
It will now properly wait the specified number of nanoseconds and then wake up the thread.
|
| |
| |
| |
| | |
This thread will not actually execute instructions, it will only advance the timing/events and try to yield immediately to the next ready thread, if there aren't any ready threads then it will be rescheduled and start its job again.
|
|/
|
|
|
|
|
|
| |
Replace all the C-style complicated buffer management with a std::deque.
In addition to making the code easier to understand it also adds support
for non-POD IdTypes.
Also clean the rest of the code to follow our code style.
|
|\
| |
| | |
AddressArbiter: Ported arbitration type 2 from 3dmoo.
|
| |
| |
| |
| | |
(Thanks 3dmoo!)
|
|/
|
|
| |
This will happen when the mutex is already owned by another thread. Should fix some issues with games being stuck due to waiting threads not being awoken.
|
|
|
|
|
|
|
|
|
|
|
| |
This handle manager more closely mirrors the behaviour of the CTR-OS
one. In addition object ref-counts and support for DuplicateHandle have
been added.
Note that support for DuplicateHandle is still experimental, since parts
of the kernel still use Handles internally, which will likely cause
troubles if two different handles to the same object are used to e.g.
wait on a synchronization primitive.
|
| |
|
| |
|
|\
| |
| | |
License change
|
| | |
|
| |
| |
| |
| |
| |
| | |
- Removed unused VBLANK sleep mode
- Added error log for bad context switch
- Renamed VerifyWait to CheckWaitType to be more clear
|
|\ \
| | |
| | | |
Kernel: Implement support for current thread pseudo-handle
|
| | |
| | |
| | |
| | | |
This boots a few (mostly Nintendo 1st party) games further.
|
| |/
|/| |
|
|\ \
| | |
| | | |
Kernel: Add missing permissions
|
| | | |
|
| |/
|/|
| |
| |
| |
| |
| |
| |
| |
| | |
The savedata for each game is stored in /savedata/<ProgramID> for NCCH files. ELF files and 3DSX files use the folder 0 because they have no ID information
Got rid of the code duplication in File and Directory
Files that deal with the host machine's file system now live in DiskFile, similarly for directories and DiskDirectory and archives with DiskArchive.
FS_U: Use the correct error code when a file wasn't found
|
| | |
|
| | |
|
| |
| |
| |
| |
| |
| |
| | |
This is a first step at fixing the conceptual insanity that is our
handling of service and IPC calls. For now, interfaces still directly
derived from Session because we don't have the infrastructure to do it
properly. (That is, Processes and scheduling them.)
|
| | |
|
| |
| |
| |
| | |
Same semantics, idea by @yuriks
|
| | |
|
| | |
|
| | |
|
| | |
|
| |
| |
| |
| | |
This behavior was tested on hardware, however i'm still not sure what use the "initial_count" parameter has
|
| |
| |
| |
| |
| | |
ToDo: Implement svcReleaseSemaphore
* Some testing against hardware needed
|
| | |
|
| | |
|
|\ \
| | |
| | | |
Kernel/Mutex: Properly lock the mutex when a thread enters it
|
| | |
| | |
| | |
| | | |
Moved Mutex::WaitSynchronization to the end of the file.
|
| | | |
|
| | |
| | |
| | |
| | | |
Also resume only the next immediate thread waiting for the mutex when it is released, instead of resuming them all.
|
| | | |
|
|/ /
| |
| |
| |
| |
| |
| | |
This is in line with what the hardware itself does.
It does this by splitting the initial directory opening into Directory.Open(), which will return false if a stat fails.
Then, Archive::OpenDirectory will return nullptr, and archive.cpp will return an error code .
|
|\ \
| | |
| | | |
SVC: Implemented GetThreadId.
|
| | |
| | |
| | |
| | | |
Use the next_thread_id variable directly.
|
| | | |
|
| | |
| | |
| | |
| | | |
For now threads are using their Handle value as their Id, it should not really cause any problems because Handle values are unique in Citra, but it should be changed. I left a ToDo there because this is not correct behavior as per hardware.
|
|\ \ \
| | | |
| | | | |
Implemented RenameFile and RenameDirectory in FS:USER
|
| | | | |
|
| | | | |
|
| | | | |
|
| | | | |
|
| |/ /
|/| | |
|
|\ \ \
| | | |
| | | | |
Mutex: Changed behavior to always release mutex for all threads.
|
| |/ / |
|
|/ / |
|
| | |
|
| | |
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
All service calls in the CTR OS return result codes indicating the
success or failure of the call. Previous to this commit, Citra's HLE
emulation of services and the kernel universally either ignored errors
or returned dummy -1 error codes.
This commit makes an initial effort to provide an infrastructure for
error reporting and propagation which can be use going forward to make
HLE calls accurately return errors as the original system. A few parts
of the code have been updated to use the new system where applicable.
One part of this effort is the definition of the `ResultCode` type,
which provides facilities for constructing and parsing error codes in
the structured format used by the CTR.
The `ResultVal` type builds on `ResultCode` by providing a container for
values returned by function that can report errors. It enforces that
correct error checking will be done on function returns by preventing
the use of the return value if the function returned an error code.
Currently this change is mostly internal since errors are still
suppressed on the ARM<->HLE border, as a temporary compatibility hack.
As functionality is implemented and tested this hack can be eventually
removed.
|
|\ \
| | |
| | | |
Added DeleteFile and DeleteDirectory functions to FS:USER and the archives.
|
| | | |
|
|\ \ \
| | | |
| | | | |
Remove trailing spaces from the entire project
|
| | | | |
|
|\ \ \ \
| |/ / /
|/| | | |
Add static to some variables
|
| |/ / |
|
|/ / |
|
| | |
|
| | |
|
| |
| |
| |
| | |
added a todo to kernel archive
|
| | |
|
|/ |
|
| |
|
| |
|
|
|
|
| |
This was automated using `clang-modernize`.
|
|
|
|
| |
Kernel: Return an invalid handle to OpenFile when it failed to open.
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
|
|
|
| |
These avoid relying on memset for clearing the arrays.
|
|
|
|
| |
Most functions already operate on std::strings. This also removes the need to manually null terminate thread names.
|
| |
|
| |
|
| |
|
| |
|
|
|
|
|
|
|
|
| |
AddressArbiter: Added documentation comment, fixed whitespace issue.
AddressArbiter: Fixed incorrect comment, reordered if-statement to be more clear.
SVC: Removed trailing whitespace.
|
|
|
|
|
|
| |
Thread: Cleaned up arbitrate address functions.
Thread: Cleaned up ArbitrateAllThreads function.
|
|
|
|
| |
- Also added some safety checks to MapSharedMemory.
|
|
|
|
| |
SharedMemory: Added optional name field for tracking known objects.
|
| |
|
|
|
|
|
|
|
|
|
|
| |
Archive: Fixed brace ugliness for neobrain :)
FS: Commented out unused local variables to prevent warnings.
...But keeping them here for future use.
archive_romfs: Removed unused #include.
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
- SVC: Added ExitThread support
- SVC: Added SignalEvent support
- Thread: Added WAITTYPE_EVENT for waiting threads for event signals
- Thread: Added support for blocking on other threads to finish (e.g. Thread::Join)
- Thread: Added debug function for printing current threads ready for execution
- Thread: Removed hack/broken thread ready state code from Kernel::Reschedule
- Mutex: Moved WaitCurrentThread from SVC to Mutex::WaitSynchronization
- Event: Added support for blocking threads on event signalling
Kernel: Added missing algorithm #include for use of std::find on non-Windows platforms.
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
|
|
|
|
| |
- cleaned up Kernel code a bit (moved stuff into namespace, fixed whitespace issues)
- added handle types for all different CTROS handles
|
| |
|
|
|
|
| |
- various cleanups
|
|
|
|
| |
- added ResetType enum
|
| |
|
|
|
|
|
| |
- reorganized some kernel thread functions
- added placeholder __KernelWaitThread_Synchronization function
|
|
|
|
| |
- added KERNEL_DEFAULT_STACK_SIZE definition (0x4000)
|
| |
|
| |
|
|
|
|
|
| |
- added __KernelSwitchToThread for enabling a thread
- added __KernelRotateThreadReadyQueue
|
| |
|
| |
|
| |
|
| |
|
|
|
|
| |
- fixed some logging
|
|
|