aboutsummaryrefslogtreecommitdiff
path: root/src/core/hle/kernel
AgeCommit message (Collapse)Author
2018-10-12Merge pull request #1483 from lioncash/codesetbunnei
kernel/process: Make CodeSet a regular non-inherited object
2018-10-12Merge pull request #1481 from lioncash/typobunnei
svc: Fix typos in sanitizing checks for MapMemory/UnmapMemory
2018-10-12Merge pull request #1467 from ogniK5377/svcbreak-type-fixbunnei
Fixed incorrect types for svcBreak
2018-10-12kernel/process: Make CodeSet a regular non-inherited objectLioncash
These only exist to ferry data into a Process instance and end up going out of scope quite early. Because of this, we can just make it a plain struct for holding things and just std::move it into the relevant function. There's no need to make this inherit from the kernel's Object type.
2018-10-12thread: Remove unnecessary memset from ResetThreadContext()Lioncash
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.
2018-10-12svc: Fix typos in sanitizing checks for MapMemory/UnmapMemoryLioncash
2018-10-10svc: Add missing address range sanitizing checks to MapMemory/UnmapMemoryLioncash
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.
2018-10-10kernel/thread: Use a regular pointer for the owner/current processLioncash
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).
2018-10-10Changed all casts in svc_wrap.h to be static_cast insteadDavid Marcec
2018-10-10Use a better name than "dont_kill_application"David Marcec
signal_debugger seems like a more fitting name
2018-10-10Fixed incorrect types for svcBreakDavid Marcec
svcBreak reason should be a u32, not a u64.
2018-10-09Added bitfield instead of manually checking if the bit is setDavid Marcec
2018-10-09Actual kill execution when the bit isn't set, not the other way aroundDavid Marcec
2018-10-09svcBreak, Signalling to the debugger should not kill executionDavid Marcec
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.
2018-10-06Added forward define for ServerPortDavid Marcec
2018-10-06Ported #4296 from citraDavid Marcec
This will allow us to easily remove the use of "NFC" in "System"
2018-10-06kernel/mutex: Amend behavior of TransferMutexOwnership()Lioncash
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.
2018-10-05thread: Make the scheduler pointer a regular pointerbalika011
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.
2018-10-04kernel/thread: Make all instance variables privateLioncash
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.
2018-09-30kernel/svc: Implement svcGetThreadContext()Lioncash
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).
2018-09-30kernel/process: Add a data member to determine if a process is 64-bit or not.Lioncash
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).
2018-09-30kernel/process: Make data member variables privateLioncash
Makes the public interface consistent in terms of how accesses are done on a process object. It also makes it slightly nicer to reason about the logic of the process class, as we don't want to expose everything to external code.
2018-09-29Merge pull request #1412 from lioncash/movebunnei
kernel/object: Remove unnecessary std::move from DynamicObjectCast()
2018-09-29Merge pull request #1395 from lioncash/vmbunnei
process/vm_manager: Initial modifications to load NPDM metadata
2018-09-28kernel/object: Remove unnecessary std::move from DynamicObjectCast()Lioncash
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.
2018-09-26Merge pull request #1399 from lioncash/schedbunnei
kernel/scheduler: Take ARM_Interface instances by reference
2018-09-25kernel/scheduler: Take ARM_Interface instance by reference in the constructorLioncash
It doesn't make sense to allow a scheduler to be constructed around a null pointer.
2018-09-25Merge pull request #1393 from tech4me/svcbunnei
svc: Updated svc names
2018-09-24memory: Dehardcode the use of fixed memory range constantsLioncash
The locations of these can actually vary depending on the address space layout, so we shouldn't be using these when determining where to map memory or be using them as offsets for calculations. This keeps all the memory ranges flexible and malleable based off of the virtual memory manager instance state.
2018-09-24svc: Report correct memory-related values within some of the cases in ↵Lioncash
svcGetInfo() 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.
2018-09-24memory: Dehardcode the use of a 36-bit address spaceLioncash
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.
2018-09-24process/vm_manager: Amend API to allow reading parameters from NPDM metadataLioncash
Rather than hard-code the address range to be 36-bit, we can derive the parameters from supplied NPDM metadata if the supplied exectuable supports it. This is the bare minimum necessary for this to be possible. The following commits will rework the memory code further to adjust to this.
2018-09-23svc: Updated svc namestech4me
2018-09-21svc: Move most process termination code to its own function within ProcessLioncash
Reduces the use of Process class members externally and keeps most code related to tearing down a process with the rest of the process code.
2018-09-21thread/process: Move TLS slot marking/freeing to the process classLioncash
Allows making several members of the process class private, it also avoids going through Core::CurrentProcess() just to retrieve the owning process.
2018-09-20Merge pull request #1372 from lioncash/threadbunnei
kernel/thread: Use owner_process when setting the page table in SetupMainThread()
2018-09-20kernel/thread: Use owner_process when setting the page table in ↵Lioncash
SetupMainThread() The owning process of a thread is required to exist before the thread, so we can enforce this API-wise by using a reference. We can also avoid the reliance on the system instance by using that parameter to access the page table that needs to be set.
2018-09-20arm_interface: Replace kernel vm_manager include with a forward declarationLioncash
Avoids an unnecessary inclusion and also uncovers three places where indirect inclusions were relied upon, which allows us to also resolve those.
2018-09-18Merge pull request #1346 from lioncash/svcbunnei
svc_wrap: Convert the PARAM macro into a function
2018-09-18Merge pull request #1343 from lioncash/mutexbunnei
kernel/svc: Handle invalid address cases within svcArbitrateLock() and svcArbitrateUnlock()
2018-09-18svc_wrap: Convert the PARAM macro into a functionLioncash
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.
2018-09-18arm_interface: Remove ARM11-isms from the CPU interfaceLioncash
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.
2018-09-17kernel/mutex: Replace ResultCode construction for invalid addresses with the ↵Lioncash
named variant 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.
2018-09-17kernel/svc: Handle error cases for svcArbitrateLock() and svcArbitrateUnlock()Lioncash
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.
2018-09-17Merge pull request #1313 from lioncash/errorbunnei
kernel/errors: Amend error code for ERR_NOT_FOUND
2018-09-17Merge pull request #1315 from lioncash/sizebunnei
kernel/svc: Handle a few error cases within memory-related functions
2018-09-17Merge pull request #1328 from FearlessTobi/port-4192bunnei
Port #4192 from Citra: "svc: change unknown to thread in CreateThread"
2018-09-15Port # #4192 from Citra: "svc: change unknown to thread in CreateThread"Valentin Vanelslande
2018-09-15Port #4182 from Citra: "Prefix all size_t with std::"fearlessTobi
2018-09-13kernel/svc: Sanitize creation of shared memory via svcCreateSharedMemory()Lioncash
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".