Commit graph

6090 commits

Author SHA1 Message Date
Lioncash 50a518be69 core/memory: Migrate over GetPointerFromVMA() to the Memory class
Now that everything else is migrated over, this is essentially just code
relocation and conversion of a global accessor to the class member
variable.

All that remains is to migrate over the page table.
2019-11-26 21:55:39 -05:00
Lioncash e4c381b885 core/memory: Migrate over Write{8, 16, 32, 64, Block} to the Memory class
The Write functions are used slightly less than the Read functions,
which make these a bit nicer to move over.

The only adjustments we really need to make here are to Dynarmic's
exclusive monitor instance. We need to keep a reference to the currently
active memory instance to perform exclusive read/write operations.
2019-11-26 21:55:39 -05:00
Lioncash b05bfc6036 core/memory: Migrate over Read{8, 16, 32, 64, Block} to the Memory class
With all of the trivial parts of the memory interface moved over, we can
get right into moving over the bits that are used.

Note that this does require the use of GetInstance from the global
system instance to be used within hle_ipc.cpp and the gdbstub. This is
fine for the time being, as they both already rely on the global system
instance in other functions. These will be removed in a change directed
at both of these respectively.

For now, it's sufficient, as it still accomplishes the goal of
de-globalizing the memory code.
2019-11-26 21:55:39 -05:00
Lioncash 89ef3ef575 core/memory: Migrate over ZeroBlock() and CopyBlock() to the Memory class
These currently aren't used anywhere in the codebase, so these are very
trivial to move over to the Memory class.
2019-11-26 21:55:38 -05:00
Lioncash 849581075a core/memory: Migrate over RasterizerMarkRegionCached() to the Memory class
This is only used within the accelerated rasterizer in two places, so
this is also a very trivial migration.
2019-11-26 21:55:38 -05:00
Lioncash b2165c6b35 core/memory: Migrate over ReadCString() to the Memory class
This only had one usage spot, so this is fairly straightforward to
convert over.
2019-11-26 21:55:38 -05:00
Lioncash 3f08e8d8d4 core/memory: Migrate over GetPointer()
With all of the interfaces ready for migration, it's trivial to migrate
over GetPointer().
2019-11-26 21:55:38 -05:00
Lioncash 536fc7f0ea core: Prepare various classes for memory read/write migration
Amends a few interfaces to be able to handle the migration over to the
new Memory class by passing the class by reference as a function
parameter where necessary.

Notably, within the filesystem services, this eliminates two ReadBlock()
calls by using the helper functions of HLERequestContext to do that for
us.
2019-11-26 21:55:37 -05:00
Lioncash fc7d0a17b6 core/memory: Move memory read/write implementation functions into an anonymous namespace
These will eventually be migrated into the main Memory class, but for
now, we put them in an anonymous namespace, so that the other functions
that use them, can be migrated over separately.
2019-11-26 21:53:35 -05:00
Lioncash e58748fd80 core/memory: Migrate over address checking functions to the new Memory class
A fairly straightforward migration. These member functions can just be
mostly moved verbatim with minor changes. We already have the necessary
plumbing in places that they're used.

IsKernelVirtualAddress() can remain a non-member function, since it
doesn't rely on class state in any form.
2019-11-26 21:53:34 -05:00
Lioncash 323680e5ad core/memory: Migrate over memory mapping functions to the new Memory class
Migrates all of the direct mapping facilities over to the new memory
class. In the process, this also obsoletes the need for memory_setup.h,
so we can remove it entirely from the project.
2019-11-26 21:53:34 -05:00
Lioncash 4c2ed2706e core/memory: Introduce skeleton of Memory class
Currently, the main memory management code is one of the remaining
places where we have global state. The next series of changes will aim
to rectify this.

This change simply introduces the main skeleton of the class that will
contain all the necessary state.
2019-11-26 21:53:34 -05:00
bunnei ec0ce96c56
core_timing: Use better reference tracking for EventType. (#3159)
* core_timing: Use better reference tracking for EventType.

- Moves ownership of the event to the caller, ensuring we don't fire events for destroyed objects.
- Removes need for unique names - we won't be using this for save states anyways.
2019-11-26 21:48:56 -05:00
bunnei f6b9b7910e kernel: Fix reference management for client/server session.
- Fixes shutdown crash and crash in Pokemon SwSh.
2019-11-25 18:17:49 -05:00
bunnei 50c7539108
Merge pull request #3094 from lioncash/tables
service: Update function tables
2019-11-24 20:30:58 -05:00
bunnei 9046d4a548
kernel: Replace usage of boost::intrusive_ptr with std::shared_ptr for kernel objects. (#3154)
* kernel: Replace usage of boost::intrusive_ptr with std::shared_ptr for kernel objects.

- See https://github.com/citra-emu/citra/pull/4710 for details.
2019-11-24 20:15:51 -05:00
bunnei 63248f4edd
Update svc.cpp 2019-11-23 16:01:06 -05:00
bunnei 6eaf7ab55f svc: GetSystemTick should return cntpct_el0, not core ticks. 2019-11-23 15:29:15 -05:00
bunnei 6a3fc5d2ff
Merge pull request #3114 from FernandoS27/cond-var
Kernel: Correct behavior of Condition Variables to be more similar to real hardware.
2019-11-23 13:24:39 -05:00
bunnei 6e4d46908a
Merge pull request #3130 from FernandoS27/cancel-sync
Kernel: Correct Cancel Synchronization.
2019-11-23 13:23:23 -05:00
bunnei eedb048585
Merge pull request #3112 from lioncash/skip
service/am: Remove unnecessary Skip calls
2019-11-21 15:30:01 -05:00
bunnei d7953b8ee5
Merge pull request #3111 from lioncash/query
am: Stub QueryApplicationPlayStatistics
2019-11-21 15:29:34 -05:00
Fernando Sahmkow 46bb609981 Kernel: Optimize condition variable threads management. 2019-11-21 11:13:29 -04:00
Fernando Sahmkow 2ab41ceff4 Kernel: Correct SignalProcessWideKey
When the target is 0, all threads must be processed.
2019-11-21 10:46:55 -04:00
Fernando Sahmkow 2d16507f9f Kernel: Correct behavior of Condition Variables to be more similar to real hardware.
This commit ensures cond var threads act exactly as they do in the real
console. The original implementation uses an RBTree and the behavior of
cond var threads is that at the same priority level they act like a
FIFO.
2019-11-21 10:46:55 -04:00
Fernando Sahmkow 7d16b2d2dd Kernel: Correct Cancel Synchronization.
This commit corrects the behavior of cancel synchronization when the
thread is running/ready and ensures the next wait is cancelled as it's
suppose to.
2019-11-16 12:41:51 -04:00
bunnei 3e0e4f146b
Merge pull request #3091 from lioncash/core-conversion
core: Make most implicit type conversion warnings errors on MSVC
2019-11-15 12:08:50 -05:00
Lioncash 2c4c2b5eee service/am: Remove unnecessary Skip calls
We can simplify these by wrapping the necessary members in structs and
then simply reading out the whole struct.
2019-11-14 16:31:52 -05:00
Lioncash 1cd8637bf0 am: Stub QueryApplicationPlayStatistics
Maintains implementation parity between QueryApplicationPlayStatistics
and QueryApplicationPlayStatisticsByUid.

These function the same behaviorally underneath the hood, with the only
difference being that one allows specifying a UID.
2019-11-14 16:02:39 -05:00
bunnei 885d88825e
Merge pull request #3089 from SciresM/play_statistics
Implement stub for IApplicationFunctions::QueryApplicationPlayStatisticsByUid
2019-11-14 13:54:29 -05:00
bunnei 360b0d1b30
Merge pull request #3093 from lioncash/mbedtls
core: Migrate off deprecated mbedtls functions
2019-11-14 13:47:23 -05:00
bunnei 02880a8195
Merge pull request #3092 from lioncash/util
key_manager: Make use of IOFile in WriteKeyToFile()
2019-11-14 13:46:55 -05:00
Lioncash 03b73aa575 xts_archive: Remove redundant std::string constructor
We can just call the .data() member of path instead of constructing a
completely new string.
2019-11-13 10:02:10 -05:00
Lioncash e21b6ff79d service: Update function tables
Keeps the function tables up to date.

Updated based off information from Switchbrew.
2019-11-12 10:32:56 -05:00
Lioncash 64cbebc58f key_manager: Make use of IOFile in WriteKeyToFile()
This properly handles unicode-based paths on Windows, while opening a
raw stream doesn't out-of-the-box.

Prevents file creation from potentially failing on Windows PCs that make
use of unicode characters in their save paths (e.g. writing to a user's
AppData folder, where the user has a name with non-ASCII characters).
2019-11-12 08:52:18 -05:00
Lioncash e0c46e6879 core: Migrate off deprecated mbedtls functions
These functions are marked for deprecation and it's recommended that the
*_ret variants be used instead.
2019-11-12 08:45:56 -05:00
Lioncash 47a6bb2d5b externals: Update httplib
Since the introduction of this library, numerous improvements have been
made. Notably, many of the warnings we would get by simply including the
library header have now been fixed. This makes it much easier to make
conversion warning an error.
2019-11-12 08:31:27 -05:00
Lioncash f11b87ebf1 service: Resolve sign conversion errors
These are fairly trivial to resolve and most of the changes entail
using RESULT_UNKNOWN over ResultCode(-1).
2019-11-12 07:55:39 -05:00
Lioncash 75dec14f21 perf_stats: Resolve implicit int to double conversion error
We simply need to turn the literal argument to std::accumulate into a
double, rather than an int.
2019-11-12 07:55:39 -05:00
Lioncash 23878bf360 loader; Resolve sign conversion/truncation errors 2019-11-12 07:55:39 -05:00
Lioncash 86a1eb7789 gdbstub: Resolve sign conversion errors 2019-11-12 07:55:39 -05:00
Lioncash 12dc918937 kernel: Resolve sign conversion warnings
Uncovered a bug within Thread's SetCoreAndAffinityMask() where an
unsigned variable (ideal_core) was being compared against "< 0", which
would always be a false condition.

We can also get rid of an unused function (GetNextProcessorId) which contained a sign
mismatch warning.
2019-11-12 07:55:39 -05:00
Lioncash 86c397dd6e file_sys: Resolve sign conversion warnings
Resolves a few trivial sign conversion/mismatch errors.
2019-11-12 07:55:39 -05:00
Lioncash ef060ed40c result: Add default error code for the ResultCode(-1) case
Will be used to reduce the overall duplication of the same magic value
all over the codebase in following changes.
2019-11-12 07:55:38 -05:00
Lioncash 581d2e36e5 crypto: Resolve sign-conversion warnings 2019-11-12 07:55:22 -05:00
Lioncash 27ab99490e result: Resolve sign-coversion warnings
The constructor was implicitly using signed->unsigned conversions to
produce 0xFFFFFFFF. We can just specify this explicitly with UINT32_MAX.
2019-11-12 07:06:48 -05:00
Lioncash 19a0abc19b arm_unicorn: Resolve sign conversion warnings
While we're at it, this also resolves a type truncation warning as well,
given the code was truncating from a 64-bit value to a 32-bit one.
2019-11-12 07:06:48 -05:00
Lioncash 96d677bef0 CMakeLists: Make most implicit type conversion warnings errors on MSVC
Quite frequently there have been cases where code has been merged into
the core that produces warning. In order to prevent this from occurring,
we can make the compiler flag these cases and allow our CI to flag down
any code that would generate these warnings.

This is beneficial given silent conversions from signed/unsigned can
result in logic bugs. This forces one writing changes to be explicit
about when signedness conversions are desirable, rather than leaving it
up to readers' interpretation.

Currently the codebase isn't in a state where it will build successfully
with this change applied, but this will be addressed in subsequent
follow-up changes. This set of changes will focus on making it build
properly with these changes for MSVC as a starting point for basic
coverage.
2019-11-12 07:06:25 -05:00
Michael Scire b0b0786493 Implement stub for QueryApplicationPlayStatisticsByUid 2019-11-11 07:32:47 -08:00
Fernando Sahmkow 3c95e49c42 nifm: Only return that there's an internet connection when there's a BCATServer
This helps games that need internet for other purposes boot as the rest
of our internet infrastructure is incomplete.
2019-11-06 23:10:32 -05:00
bunnei c1a3d19897
Merge pull request #3062 from bunnei/event-improve
kernel: Improve events
2019-11-06 10:05:50 -05:00
David 0e34f648f4
Merge pull request #2859 from Morph1984/hid
hid: Stub SetNpadJoyAssignmentModeSingle and GetNpadHandheldActivationMode
2019-11-06 12:48:07 +11:00
bunnei 1bdae0fe29 common_func: Use std::array for INSERT_PADDING_* macros.
- Zero initialization here is useful for determinism.
2019-11-03 22:22:41 -05:00
bunnei ece5287843 kernel: readable_event: Signal only once. 2019-11-03 04:25:41 -05:00
bunnei b0ab803ce8 kernel: events: Remove ResetType::Automatic.
- This does not actually seem to exist in the real kernel - games reset these automatically.

# Conflicts:
#	src/core/hle/service/am/applets/applets.cpp
#	src/core/hle/service/filesystem/fsp_srv.cpp
2019-11-03 04:22:45 -05:00
bunnei 28bb248db6 kernel: readable_event: Initialize members. 2019-11-03 04:18:39 -05:00
FearlessTobi 832c138eff core/am: Stub InitializeApplicationCopyrightFrameBuffer, SetApplicationCopyrightImage and SetApplicationCopyrightVisibility
These commands require Screenshots to be implemented anyway, so they are safe to stub for now.
2019-11-03 07:37:38 +01:00
Rodrigo Locatti 04b838c857
Merge pull request #3038 from lioncash/docs
kernel/scheduler: Minor changes
2019-10-30 03:47:28 +00:00
bunnei a81bd962ab
Merge pull request #3007 from DarkLordZach/fsc-regress
savedata_factory: Automatically create certain savedata
2019-10-29 22:05:09 -04:00
Lioncash 6c8f28813c scheduler: Mark parameter of AskForReselectionOrMarkRedundant() as const
This is only compared against, so it can be made const.
2019-10-27 23:35:50 -04:00
Lioncash f19c1a7cda scheduler: Silence sign conversion warnings 2019-10-27 22:44:52 -04:00
Lioncash 2fb0bbff29 scheduler: Initialize class members directly where applicable
Reduces the overall amount of code.
2019-10-27 22:13:55 -04:00
Lioncash 2dc469ceba scheduler: Amend documentation comments
Adjusts the formatting of a few of the comments an ensures they get
recognized as proper Doxygen comments.
2019-10-27 22:12:32 -04:00
David 4c5731c34f
Merge pull request #2971 from FernandoS27/new-scheduler-v2
Kernel: Implement a New Thread Scheduler V2
2019-10-28 10:53:27 +11:00
bunnei 6fe89acf0d
Merge pull request #2991 from lioncash/npad
hid/npad: Minor cleanup
2019-10-22 19:51:24 -04:00
Zach Hilman bb207fe27a savedata_factory: Automatically create certain savedata
After further hardware investigation, it appears that some games, perhaps those more lazily coded, will not call EnsureSaveData, meaning that they expect the normal (current) save to be automatically made. Additionally, some games do not create a cache or temporary save before use.
In these 3 specific instances, the save is created automatically for the game if it doesn't exist.
2019-10-22 15:47:38 -04:00
bunnei a86a88109a core: Fix clang-format errors. 2019-10-19 14:47:18 -04:00
Nicolae-Andrei Cociorba 20521da259 Fix null pointer deref. 2019-10-18 14:12:12 +00:00
bunnei d1713ad451
Merge pull request #2992 from lioncash/dmnt
dmnt_cheat_vm: Correct register Restore and ClearRegs behavior
2019-10-17 19:52:24 -04:00
Lioncash 2c34d8aabb dmnt_cheat_vm: Correct register Restore and ClearRegs behavior
Previously these were performing the same behavior as the Save and
ClearSaved opcode types.
2019-10-17 18:49:39 -04:00
Rodrigo Locatti 7cf091bb20
Merge pull request #2989 from lioncash/apm
service/apm/controller: Minor interface changes
2019-10-17 19:20:14 -03:00
Lioncash 8d8e495248 hid/npad: Fix incorrect connection boolean value in ConnectAllDisconnectedControllers()
We should be setting the connection state to true, otherwise we aren't
actually making the controllers connected like the function name
indicates.
2019-10-17 18:19:47 -04:00
Lioncash d076466f26 hid/npad: Add missing break in default case
While not an issue, it does prevent fallthrough from occurring if
anything is ever added after this case (unlikely to occur, but this
turns a trivial "should not cause issues" into a definite "won't cause
issues).
2019-10-17 18:17:42 -04:00
Lioncash 26c84718c8 hid/npad: Replace std::for_each with ranged for loops
Performs the same behavior, but is built into the core language itself.

No functional change.
2019-10-17 18:16:36 -04:00
Lioncash e433e99191 hid/npad: Remove redundant non-const variant of IsControllerSupported()
The const qualified variant can also be called in non-const contexts, so
we can remove the non-const variant to eliminate a bit of code
duplication.
2019-10-17 18:11:41 -04:00
Lioncash a71e8066a1 hid/npad: Move function declarations
Clearly separate these from the variable declarations to make them more
visible.
2019-10-17 18:09:08 -04:00
Lioncash 98c6a95079 core/core: Resolve -Wreorder warnings
Amends the initializer lists to be ordered in the same manner that
they're declared within the class.
2019-10-17 17:51:06 -04:00
Lioncash 6414d9e2e5 core/memory/cheat_engine: Resolve -Wreorder warnings
Amends the initializer lists to be ordered in the same manner that
they're declared within the class.
2019-10-17 16:21:47 -04:00
Lioncash b77430df70 apm/controller: Make SetPerformanceConfiguration() use an array of pairs over a map
While a map is an OK way to do lookups (and usually recommended in most
cases), this is a map that lives for the entire duration of the program
and only deallocates its contents when the program terminates.

Given the total size of the map is quite small, we can simply use a
std::array of pairs and utilize std::find_if to perform the same
behavior without loss of performance.

This eliminates a static constructor and places the data into the
read-only segment.

While we're at it, we can also handle malformed inputs instead of
directly dereferencing the resulting iterator.
2019-10-17 16:13:14 -04:00
Lioncash 141d929929 apm/controller: Make GetCurrentPerformanceMode() a const member function
This doesn't modify instance state, so it can be made const qualified.
2019-10-17 15:58:25 -04:00
bunnei ef9b31783d
Merge pull request #2912 from FernandoS27/async-fixes
General fixes to Async GPU
2019-10-16 10:34:48 -04:00
bunnei 2299950de1
Merge pull request #2972 from lioncash/system
{bcat, gpu, nvflinger}: Remove trivial usages of the global system accessor
2019-10-15 17:49:12 -04:00
Lioncash cc1d7048b5 bcat: Remove use of global system accessors
Removes all uses of the global system accessor within the BCAT
interface.
2019-10-15 16:39:27 -04:00
Fernando Sahmkow 64e652d8cb Kernel Thread: Cleanup THREADPROCESSORID_DONT_UPDATE. 2019-10-15 11:55:30 -04:00
Fernando Sahmkow e28c7f5217 Kernel: Address Feedback 2 2019-10-15 11:55:28 -04:00
Fernando Sahmkow a3524879be Kernel: Clang Format 2019-10-15 11:55:27 -04:00
Fernando Sahmkow c32520ceb7 Kernel: Reverse global accessor removal. 2019-10-15 11:55:26 -04:00
Fernando Sahmkow 3073615dbc Kernel: Address Feedback. 2019-10-15 11:55:25 -04:00
Fernando Sahmkow 25f8606a6d Kernel Scheduler: Make sure the global scheduler shutdowns correctly. 2019-10-15 11:55:24 -04:00
Fernando Sahmkow b3c1deba49 Kernel_Thread: Eliminate most global accessors. 2019-10-15 11:55:23 -04:00
Fernando Sahmkow 0b72b34d89 KernelSVC: Assert that condition variable address is aligned to 4 bytes. 2019-10-15 11:55:22 -04:00
Fernando Sahmkow 96b1b144af Kernel: Correct Paused scheduling 2019-10-15 11:55:21 -04:00
Fernando Sahmkow 1c6a11ab14 Kernel: Corrections to Wait Objects clearing in which a thread could still be signalled after a timeout or a cancel. 2019-10-15 11:55:20 -04:00
Fernando Sahmkow 27d571c084 Kernel: Correct redundant yields to only advance time forward. 2019-10-15 11:55:20 -04:00
Fernando Sahmkow 7176857177 Kernel: Corrections to ModifyByWaitingCountAndSignalToAddressIfEqual 2019-10-15 11:55:19 -04:00
Fernando Sahmkow 44e09e5f21 Kernel: Correct Results in Condition Variables and Mutexes 2019-10-15 11:55:18 -04:00
Fernando Sahmkow 1ec1e81373 Kernel: Clang Format 2019-10-15 11:55:17 -04:00
Fernando Sahmkow e05a8c2385 Kernel: Remove global system accessor from WaitObject 2019-10-15 11:55:16 -04:00
Fernando Sahmkow 0cf26cee59 Scheduler: Implement Yield Count and Core migration on Thread Preemption. 2019-10-15 11:55:16 -04:00
Fernando Sahmkow 2d382de6fa Scheduler: Corrections to YieldAndBalanceLoad and Yield bombing protection. 2019-10-15 11:55:15 -04:00