Commit graph

676 commits

Author SHA1 Message Date
bunnei
b55fa06eef Merge pull request #726 from lioncash/overload
hle_ipc: Introduce generic WriteBuffer overload for multiple container types
2018-07-19 16:18:38 -07:00
bunnei
e9c9207523 Merge pull request #721 from lioncash/svc
svc: Correct always true assertion case in SetThreadCoreMask
2018-07-19 16:11:40 -07:00
Lioncash
2b158ebd25 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.
2018-07-19 17:05:12 -04:00
Lioncash
9ee475f731 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.
2018-07-19 15:46:17 -04:00
Lioncash
a52cb33af2 hle_ipc: Amend usage of buffer_index within one of HLERequestContext's WriteBuffer() overloads
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.
2018-07-19 11:10:16 -04:00
bunnei
25c34badfa Merge pull request #692 from lioncash/assign
address_arbiter: Correct assignment within an assertion statement in WakeThreads()
2018-07-18 20:56:28 -07:00
bunnei
90042f35a5 Merge pull request #690 from lioncash/move
core/memory, core/hle/kernel: Use std::move where applicable
2018-07-18 20:55:55 -07:00
bunnei
6f120be510 Merge pull request #688 from lioncash/comma
vm_manager: Add missing commas to string literal array elements in GetMemoryStateName()
2018-07-18 18:59:09 -07:00
Lioncash
76a9fc2f85 address_arbiter: Correct assignment within an assertion statement in WakeThreads()
This was introduced within d12af72c8f, and
considering there's no comment indicating that this is intentional, this
is very likely a bug.
2018-07-18 19:46:46 -04:00
Lioncash
81bf614695 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.
2018-07-18 19:37:19 -04:00
Lioncash
b1b1c60009 core/memory, core/hle/kernel: Use std::move where applicable
Avoids pointless copies
2018-07-18 19:34:31 -04:00
Lioncash
e72928762f core: Don't construct instance of Core::System, just to access its live instance
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.
2018-07-18 18:18:27 -04:00
bunnei
5dde645197 Merge pull request #671 from MerryMage/clear-exclusive-state
scheduler: Clear exclusive state when switching contexts
2018-07-17 07:33:32 -07:00
bunnei
430c52b249 Merge pull request #672 from SciresM/to_address_fix
svc:: Fix bug in svcWaitForAddress
2018-07-17 07:32:42 -07:00
bunnei
df66fadc12 nvflinger: Fix for BufferQueue event handling. 2018-07-17 00:26:23 -04:00
Michael Scire
045893374f Kernel/Arbiter: Fix bug in WaitIfLessThan 2018-07-16 20:55:53 -06:00
MerryMage
bd97579188 scheduler: Clear exclusive state when switching contexts 2018-07-16 11:24:00 +01:00
David Marcec
66bd4de380 No need to use ASSERT_MSG with an empty message 2018-07-14 23:13:16 +10:00
James Rowe
d74d2a77cb Update clang format 2018-07-02 21:45:47 -04:00
James Rowe
e159c550d8 Rename logging macro back to LOG_* 2018-07-02 21:45:47 -04:00
bunnei
55d7d4afa4 Merge pull request #579 from SciresM/master
svc: Fully implement svcSignalToAddress and svcWaitForAddress
2018-06-22 12:08:39 -04:00
mailwl
29f156eb60 IPC: skip empty buffer write
prevent yuzu crash, if games, like Axiom Verge, trying to read 0 bytes from file
2018-06-22 11:28:10 +03:00
Michael Scire
a3509a9e74 Kernel/Arbiters: Fix casts, cleanup comments/magic numbers 2018-06-22 00:47:59 -06:00
Michael Scire
28fe461cd3 Add additional missing format. 2018-06-21 21:09:51 -06:00
Michael Scire
96617f16ed Run clang-format on PR. 2018-06-21 21:05:34 -06:00
Michael Scire
9d83964c1b Kernel/Arbiters: HLE is atomic, adjust code to reflect that. 2018-06-21 20:25:57 -06:00
Michael Scire
2a0ea82fec Kernel/Arbiters: Initialize arb_wait_address in thread struct. 2018-06-21 05:13:06 -06:00
Michael Scire
3aa03cca5a Kernel/Arbiters: Clear WaitAddress in SignalToAddress 2018-06-21 04:20:39 -06:00
Michael Scire
d12af72c8f Kernel/Arbiters: Mostly implement SignalToAddress 2018-06-21 04:10:11 -06:00
Michael Scire
3119b64d86 Kernel/Arbiters: Implement WaitForAddress 2018-06-21 01:40:29 -06:00
Michael Scire
6e9b11ffa0 Kernel/Arbiters: Add stubs for 4.x SignalToAddress/WaitForAddres SVCs. 2018-06-21 00:49:43 -06:00
Subv
cb4ff57322 Build: Fixed some MSVC warnings in various parts of the code. 2018-06-20 11:39:10 -05:00
bunnei
149fef99a0 Merge pull request #572 from Armada651/user-except-stub
svc: Add a stub for UserExceptionContextAddr.
2018-06-18 11:37:13 -04:00
Jules Blok
5614c1329e svc: Add a stub for UserExceptionContextAddr. 2018-06-18 09:29:11 +02:00
Subv
dd9a1fd943 Kernel/Threads: A thread waking up by timeout from a WaitProcessWideKey may already have an assigned lock owner.
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.
2018-06-02 14:06:35 -05:00
Subv
2a690458b5 Kernel/Thread: Corrected a typo that caused the affinity mask to never be changed. 2018-05-30 21:36:29 -05:00
Subv
40c82fc9c5 Kernel/SVC: Support special core values -2 and -3 in svcSetThreadCoreMask.
Also added some proper error handling.
2018-05-30 21:36:29 -05:00
Subv
bcae826522 Kernel/Thread: Corrected a typo in an assert about the processor id. 2018-05-30 11:32:46 -05:00
greggameplayer
4201782cea Add & correct miscellaneous things (#470)
* add some InfoType

* correct OpenApplicationProxy cmd number

* add IDisplayController functions

* fix clang-format

* add more system languages
2018-05-25 22:31:54 -04:00
bunnei
11597c4ab2 Merge pull request #454 from Subv/signal_processwide
Kernel/SVC: Signal the highest priority threads first in svcSignalProcessWideKey
2018-05-23 10:28:23 -04:00
bunnei
613a6d661e Merge pull request #457 from Subv/mutex_waiters
Mutex: Do not assert when the mutex waiting threads list isn't empty on mutex release.
2018-05-20 23:44:44 -04:00
Subv
fe463e2a1c 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.
2018-05-20 14:41:58 -05:00
Subv
e3e8902d40 Kernel/SVC: Signal the highest priority threads first in svcSignalProcessWideKey. 2018-05-19 16:58:30 -05:00
Subv
8ce8160ce3 Kernel/Threads: Reschedule the proper core when operating on that core's threads. 2018-05-19 16:57:44 -05:00
Subv
8935ca8e11 SVC: Removed unused WaitSynchronization1 function 2018-05-19 16:56:33 -05:00
David Marcec
75bd5bf8be Added RequestWithContext & ControlWithContext 2018-05-17 14:03:52 -07:00
bunnei
ce7d89cb0e thread: Rename mask to affinity_masks. 2018-05-10 19:34:53 -04:00
bunnei
d96be9b56b thread: Support core change on ResumeFromWait and improve ChangeCore. 2018-05-10 19:34:53 -04:00
bunnei
eabfdfe4ec scheduler: Protect scheduling functions with a global mutex. 2018-05-10 19:34:52 -04:00
bunnei
82bb8701ea thread: Initialize ideal_core and mask members. 2018-05-10 19:34:52 -04:00