Commit graph

765 commits

Author SHA1 Message Date
Lioncash 3a4841e403 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 88a3140c9b
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 519035db3d
Merge pull request #672 from SciresM/to_address_fix
svc:: Fix bug in svcWaitForAddress
2018-07-17 07:32:42 -07:00
bunnei 170e19d4ea nvflinger: Fix for BufferQueue event handling. 2018-07-17 00:26:23 -04:00
Michael Scire 3b885691a1 Kernel/Arbiter: Fix bug in WaitIfLessThan 2018-07-16 20:55:53 -06:00
MerryMage 56cc1c11ec scheduler: Clear exclusive state when switching contexts 2018-07-16 11:24:00 +01:00
David Marcec a7d6c0d6ea No need to use ASSERT_MSG with an empty message 2018-07-14 23:13:16 +10:00
James Rowe 0d46f0df12 Update clang format 2018-07-02 21:45:47 -04:00
James Rowe 638956aa81 Rename logging macro back to LOG_* 2018-07-02 21:45:47 -04:00
bunnei 6d7941042b
Merge pull request #579 from SciresM/master
svc: Fully implement svcSignalToAddress and svcWaitForAddress
2018-06-22 12:08:39 -04:00
mailwl a27befe456 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 067ac434ba Kernel/Arbiters: Fix casts, cleanup comments/magic numbers 2018-06-22 00:47:59 -06:00
Michael Scire 5f8aa02584 Add additional missing format. 2018-06-21 21:09:51 -06:00
Michael Scire 08d454e30d Run clang-format on PR. 2018-06-21 21:05:34 -06:00
Michael Scire dc70a87af1 Kernel/Arbiters: HLE is atomic, adjust code to reflect that. 2018-06-21 20:25:57 -06:00
Michael Scire 8f8fe62a19 Kernel/Arbiters: Initialize arb_wait_address in thread struct. 2018-06-21 05:13:06 -06:00
Michael Scire 62bd1299ea Kernel/Arbiters: Clear WaitAddress in SignalToAddress 2018-06-21 04:20:39 -06:00
Michael Scire 4f81bc4e1b Kernel/Arbiters: Mostly implement SignalToAddress 2018-06-21 04:10:11 -06:00
Michael Scire 9d71ce88ce Kernel/Arbiters: Implement WaitForAddress 2018-06-21 01:40:29 -06:00
Michael Scire 7e191dccc1 Kernel/Arbiters: Add stubs for 4.x SignalToAddress/WaitForAddres SVCs. 2018-06-21 00:49:43 -06:00
Subv a3d82ef5d9 Build: Fixed some MSVC warnings in various parts of the code. 2018-06-20 11:39:10 -05:00
bunnei 4ac4b308e4
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 bf4e2b2f0b svc: Add a stub for UserExceptionContextAddr. 2018-06-18 09:29:11 +02:00
Subv 9cd87a6352 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 c02d7c8ce7 Kernel/Thread: Corrected a typo that caused the affinity mask to never be changed. 2018-05-30 21:36:29 -05:00
Subv 3957b0c34e 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 d1f9c750a6 Kernel/Thread: Corrected a typo in an assert about the processor id. 2018-05-30 11:32:46 -05:00
greggameplayer b16e5c6a81 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 3825b703fa
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 693f78e6c2
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 fd500d3da6 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 2a35a36251 Kernel/SVC: Signal the highest priority threads first in svcSignalProcessWideKey. 2018-05-19 16:58:30 -05:00
Subv c74f2555b6 Kernel/Threads: Reschedule the proper core when operating on that core's threads. 2018-05-19 16:57:44 -05:00
Subv fab3dd98fe SVC: Removed unused WaitSynchronization1 function 2018-05-19 16:56:33 -05:00
David Marcec fd86cdb2e2 Added RequestWithContext & ControlWithContext 2018-05-17 14:03:52 -07:00
bunnei 46ec9a9bc9 thread: Rename mask to affinity_masks. 2018-05-10 19:34:53 -04:00
bunnei fbd7afefaa thread: Support core change on ResumeFromWait and improve ChangeCore. 2018-05-10 19:34:53 -04:00
bunnei 91af2f94e8 scheduler: Protect scheduling functions with a global mutex. 2018-05-10 19:34:52 -04:00
bunnei 4822765fef thread: Initialize ideal_core and mask members. 2018-05-10 19:34:52 -04:00
bunnei 8aa5d25f82 threading: Reschedule only on cores that are necessary. 2018-05-10 19:34:52 -04:00
bunnei d6e3cd9a17 svc: Implement GetThreadCoreMask and SetThreadCoreMask. 2018-05-10 19:34:51 -04:00
bunnei 6ea8b3ef60 thread: Implement ChangeCore function. 2018-05-10 19:34:50 -04:00
bunnei 1c36f2a798 svc: SignalProcessWideKey should apply to all cores. 2018-05-10 19:34:49 -04:00
bunnei 6a890023e9 svc: Implement GetCurrentProcessorNumber. 2018-05-10 19:34:49 -04:00
bunnei a434fdcb10 core: Implement multicore support. 2018-05-10 19:34:46 -04:00
bunnei 1147db9dd1
Merge pull request #431 from lioncash/fmt
general: Make formatting of logged hex values more straightforward
2018-05-02 15:24:41 -04:00
Lioncash 7c9644646f
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).
2018-05-02 09:49:36 -04:00
bunnei fadab1d5f3 ipc: Add support for PopIpcInterface() method.
- This can be used for domain objects as inputs to service functions.
2018-05-01 21:57:44 -04:00
David ff2f0d980a GetSharedFontInOrderOfPriority (#381)
* 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
2018-05-01 16:28:36 -04:00
Lioncash 0197e28cc9
core_timing: Namespace all functions and constants in core_timing's header
All of these variables and functions are related to timings and should be within the namespace.
2018-04-30 03:32:59 -04:00
Lioncash 3abba08080
string_util: Remove StringFromFormat() and related functions
Given we utilize fmt, we don't need to provide our own functions for formatting anymore
2018-04-29 18:52:33 -04:00
Lioncash 843dd62c81
core: Replace usages of LOG_GENERIC with new fmt-capable equivalents 2018-04-27 11:57:52 -04:00
Lioncash 8475496630
general: Convert assertion macros over to be fmt-compatible 2018-04-27 10:04:02 -04:00
Lioncash 1913cf4783
kernel/shared_memory: Remove unnecessary semicolon at end of ConvertPermissions()
Functions don't need to be terminated by semicolons.
2018-04-25 20:32:16 -04:00
Lioncash 40dee76c57
kernel: Migrate logging macros to fmt-compatible ones 2018-04-25 20:32:09 -04:00
bunnei 0214351f4f
Merge pull request #370 from Subv/sync_primitives
Kernel: Reworked the new kernel synchronization primitives.
2018-04-23 16:33:00 -04:00
Subv 46572d027d Kernel: Implemented mutex priority inheritance.
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.
2018-04-23 11:23:44 -05:00
Subv a70ed9c8ae Kernel: Use 0x2C as default main thread priority for homebrew and lone NRO/NSOs 2018-04-20 21:04:35 -05:00
Subv 013778aa21 Qt: Update the WaitTree widget to show info about the current mutex of each thread. 2018-04-20 21:04:34 -05:00
Subv be155f4d9d Kernel: Remove unused ConditionVariable class. 2018-04-20 21:04:33 -05:00
Subv 5fdfbfe25a Kernel: Remove old and unused Mutex code. 2018-04-20 21:04:32 -05:00
Subv b18ccf9399 Kernel: Properly implemented svcWaitProcessWideKey and svcSignalProcessWideKey
They work in tandem with guest code to provide synchronization primitives along with svcArbitrateLock/Unlock
2018-04-20 21:04:27 -05:00
Subv e81a2080eb Kernel: Corrected the implementation of svcArbitrateLock and svcArbitrateUnlock.
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.
2018-04-20 21:04:25 -05:00
Lioncash bec05db746 resource_limit: Make ResourceTypes an enum class
Prevents enum identifiers from leaking into the surrounding scope.
2018-04-20 19:41:45 -04:00
Lioncash d9e316e353 common_funcs: Remove ARRAY_SIZE macro
C++17 has non-member size() which we can just call where necessary.
2018-04-19 22:36:52 -04:00
Hexagon12 e52a87b98a Various service name fixes - part 2 (rebased) (#322)
* 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
2018-04-17 11:37:43 -04:00
bunnei 43f0f163e1 vm_manager: Increase GetTotalMemoryUsage value.
- Gets Binding of Isaac running.
2018-04-14 22:04:10 -04:00
bunnei 40bccd74d3 svc: Stub out SetThreadActivity, GetThreadContext. 2018-04-02 23:51:01 -04:00
bunnei 99ae9dbf49 shared_memory: Remove incorrect 3ds-specific check. 2018-04-02 23:50:58 -04:00
bunnei f4ba523992 hle_ipc, fsp_srv: Cleanup logging. 2018-03-31 23:30:00 -04:00
bunnei eef097bdc7 hle_ipc: Do not ensure write buffer size. 2018-03-31 16:06:46 -04:00
bunnei b27ab46bde memory: Fix stack region. 2018-03-31 16:06:45 -04:00
bunnei f6893969b3 svc: Stub GetThreadCoreMask. 2018-03-29 21:23:15 -04:00
N00byKing 1d8b6ad13b Clang Fixes 2018-03-19 17:53:35 +01:00
N00byKing 0e72d0d826 More Warning cleanups 2018-03-19 17:27:04 +01:00
N00byKing ef875d6a35 Clean Warnings (?) 2018-03-19 17:07:08 +01:00
bunnei c86af6939c hle_ipc: Add SleepClientThread to block current thread within HLE routines. 2018-03-18 20:56:34 -04:00
bunnei 2faa83ca13 hle_ipc: Use shared_ptr instead of unique_ptr to allow copies. 2018-03-18 20:56:33 -04:00
bunnei 019f1a0cf0 hle_ipc: Remove GetPointer(..) usage with WriteToOutgoingCommandBuffer. 2018-03-18 20:56:33 -04:00
bunnei e353b9fb3d thread: Add THREADSTATUS_WAIT_HLE_EVENT, remove THREADSTATUS_WAIT_ARB. 2018-03-18 20:56:32 -04:00
bunnei cc6f22e0e4 process: MirrorMemory should use MemoryState::Mapped. 2018-03-16 19:24:54 -04:00
bunnei e9a857ce82 process: Unmap previously allocated heap. 2018-03-16 18:32:25 -04:00
bunnei 403f8e79ea arm_interface: Support unmapping previously mapped memory. 2018-03-16 18:32:24 -04:00
bunnei 34a29ad051 svc: Use more correct values for GetInfo MapRegion and NewMapRegion. 2018-03-16 18:32:23 -04:00
bunnei 8581404482 kernel: Move stack region outside of application heap. 2018-03-16 18:32:23 -04:00
bunnei 3923b0f589 process: Fix stack memory state. 2018-03-16 18:32:21 -04:00
bunnei 8be7131033 MemoryState: Add additional memory states and improve naming. 2018-03-16 18:32:21 -04:00
bunnei 7d6653268f core: Move process creation out of global state. 2018-03-14 18:42:19 -04:00
bunnei 46fc7d8502
Merge pull request #216 from Subv/savedata
Implemented the SaveData archive and MountSaveData.
2018-03-01 22:14:31 -05:00
Subv 827f8ca3c7 Kernel: Store the program id in the Process class instead of the CodeSet class.
There may be many CodeSets per Process, so it's wasteful and overcomplicated to store the program id in each of them.
2018-03-01 19:03:53 -05:00
Jules Blok c74af07c49 thread: Clear the process list on shutdown. 2018-02-27 17:13:39 +01:00
bunnei 926604fc14
Merge pull request #207 from mailwl/duplicatesession
IPC: add domain header to response if only it exists in request
2018-02-26 20:52:56 -08:00
bunnei f1beb69899
Merge pull request #215 from N00byKing/umapsharedmmry
UnmapSharedMemory
2018-02-25 21:04:24 -08:00
N00byKing 08c6ac02cf
(Hopefully) Fix MinGW Build 2018-02-25 13:40:22 +01:00
N00byKing 2b41c6e573 Add UnmapSharedMemory
C++11 requires spaces on the Identifier

Add inttypes include

clang
2018-02-25 11:38:06 +01:00
mailwl e4f94ee30b Stub more functions 2018-02-22 17:28:15 +03:00
mailwl 1289a3c3c1 Add warning if Domain request has no domain message header 2018-02-20 22:51:54 +03:00
mailwl 827152d1fd Fix: change check for domain order and existance of domain message header 2018-02-20 21:59:58 +03:00
mailwl 1572c45aa0 IPC: add domain header to response if only it exists in request 2018-02-20 19:27:49 +03:00
bunnei 8db80d8389 scheduler: Cleanup based on PR feedback. 2018-02-19 16:46:42 -05:00
bunnei ac81c02ed9 kernel: Use Scheduler class for threading. 2018-02-18 15:17:16 -05:00
bunnei c78d495161 kernel: Add Scheduler, which encapsulates the scheduling loading from Thread module. 2018-02-18 14:58:40 -05:00
bunnei cec0d4f191 kernel: Remove unused address_arbiter code. 2018-02-18 14:46:11 -05:00
Subv 94ee8fc97b Kernel/IPC: Add a small delay after each SyncRequest to prevent thread starvation.
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.
2018-02-18 13:25:48 -05:00
mailwl 6797d4a907 Service/hid: stub some functions 2018-02-16 06:15:05 +03:00
bunnei df008a159b shared_memory: Remove some checks. 2018-02-14 22:24:06 -05:00
bunnei db873a232c
Merge pull request #188 from bunnei/refactor-buffer-descriptor
Refactor IPC buffer descriptor interface
2018-02-14 18:31:53 -05:00
bunnei 88bfec37ce hle_ipc: Remove const from WriteBuffer size. 2018-02-14 14:21:10 -05:00
Lioncash c1146d2a5f
thread: Silence formatting specifier warnings 2018-02-14 01:50:14 -05:00
Lioncash 1e33db8573
vm_manager: Silence formatting specifier warnings 2018-02-14 01:50:14 -05:00
bunnei 6fd19f05f1 hle_ipc: Add GetReadBufferSize and check write buffer size. 2018-02-14 00:14:17 -05:00
bunnei fc1b425520 hle_ipc: Add helper functions for reading and writing buffers. 2018-02-13 23:54:07 -05:00
bunnei 1ce6fff064 hle_ipc: Add helper functions for reading and writing buffers. 2018-02-13 23:26:03 -05:00
bunnei 903beb43a8 mutex: Update hasWaiters on release. 2018-02-05 21:54:10 -05:00
bunnei 42fc437268 GetInfo: Implement IsCurrentProcessBeingDebugged. 2018-02-04 12:34:45 -05:00
bunnei 0b6b147939 WaitProcessWideKeyAtomic: Handle case where condition variable was already created. 2018-02-04 12:30:51 -05:00
bunnei 647364db8f svc: SharedMemory size should be 64-bits and cleanup. 2018-02-03 13:36:54 -05:00
bunnei f9c9ce2005 ArbitrateLock: Assert that requesting_thread is current_thread. 2018-02-03 13:29:18 -05:00
shinyquagsire23 96c444d1ff shared_memory: Only mark addresses as invalid if they are within the heap 2018-01-29 23:38:56 -07:00
bunnei c1a8e4bfe4
Merge pull request #148 from MerryMage/feature/special-memory
memory: Replace all memory hooking with Special regions
2018-01-27 15:20:53 -05:00
MerryMage 738f91a57d memory: Replace all memory hooking with Special regions 2018-01-27 15:16:39 +00:00
bunnei 7588b24f46 server_session: Fix scenario where all domain handlers are closed. 2018-01-24 22:24:16 -05:00
bunnei 1b1d399e5f hle: Rename RequestBuilder to ResponseBuilder. 2018-01-24 22:24:10 -05:00
bunnei f0035420d7 ipc_helpers: Make interface domain agnostic and add header validation. 2018-01-24 22:19:01 -05:00
bunnei 27bad0598a hle: Integrate Domain handling into ServerSession. 2018-01-24 22:18:56 -05:00
bunnei 67758857e4 hle: Remove Domain and SyncObject kernel objects. 2018-01-24 22:18:54 -05:00
bunnei 932fa94af7 handle_table: Remove ConvertSessionToDomain. 2018-01-24 22:18:51 -05:00
James Rowe 096be16636 Format: Run the new clang format on everything 2018-01-20 16:45:11 -07:00
David 0b6da0c1ab Added CreateSharedMemory & UNIMPLEMENTED() for non existent services. (#113)
* Added svcCreateSharedMemory

* Services which are not implemented now throw UNIMPLEMENTED()

* clang-format

* changed perms to u32

* removed camelcase
2018-01-19 19:35:25 -05:00
River City Ransomware dd62f125c3 Fixes some cast warnings, partial port of citra #3064 (#106)
* Fixes some cast warnings, partially fixes citra #3064

* Converted casts to uint32_t to u32

* Ran clang-format
2018-01-19 18:01:41 -05:00
bunnei e1ee8f4657 svc: Fix svcGetInfo MapRegionBaseAddr. 2018-01-18 23:44:15 -05:00
bunnei d80991977a svc: Add additional fields to MemoryInfo struct. 2018-01-18 23:37:54 -05:00
gdkchan 59575d5cae Stub PopLaunchParameter and implement Buffer C Descriptors reading on hle_ipc (#96)
* Stub PopLaunchParameter and implement Buffer C Descriptors reading

* Address PR feedback

* Ensure we push a u64 not a size_t

* Fix formatting
2018-01-18 14:54:34 -05:00
Lioncash 4497eb4528 svc: Rename some entries to match their analogue on SwitchBrew
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.
2018-01-17 20:38:23 -05:00
Lioncash c81ed5eb33 svc: Add CreateJitMemory and MapJitMemory svc strings
Makes the table match SwitchBrew for these entries
2018-01-17 20:32:56 -05:00
bunnei 7fa32af1c7 svc: Clang-format fix. 2018-01-17 12:19:17 -05:00
bunnei b588cbcb1d hle_ipc: Clang format. 2018-01-17 11:37:26 -05:00
bunnei 30cb98f874 ipc: Implement domain command CloseVirtualHandle. 2018-01-17 01:20:10 -05:00
Subv bf0e20c571 SVC: Correct some return values in svcGetInfo and added TitleId and PrivilegedProcessId stubs.
# Conflicts:
#	src/core/hle/kernel/svc.cpp
2018-01-16 18:50:23 -05:00
Subv 3442f4b96a SVC: Add 4.0.0+ comment to GetInfoType enum values. 2018-01-16 18:44:39 -05:00
Subv 5bc14e791a IPC: Push domain objects as move handles when not in a domain. 2018-01-16 18:42:08 -05:00
bunnei 1aa4cdc3c8
Merge pull request #52 from ogniK5377/fsp
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
2018-01-16 18:27:48 -05:00
David Marcec bb7221c5d5 SetThreadCoreMask stub, time to implement fsp 2018-01-16 14:23:53 -08:00
David Marcec 68143af636 Added more svcGetInfo pairs 2018-01-16 14:06:45 -08:00
MerryMage e35644c005 clang-format 2018-01-16 18:05:21 +00:00
bunnei 22659afcd0 shared_memory: Minor fixes and cleanup. 2018-01-14 17:20:55 -05:00
bunnei 974362bc12 svc: Implement svcMapSharedMemory. 2018-01-14 17:20:55 -05:00
bunnei bd58c5470c kernel: Increase default stack size to 64K. 2018-01-14 17:20:55 -05:00
bunnei 1247c53786 yuzu: Update license text to be consistent across project. 2018-01-13 16:22:39 -05:00
bunnei 056f987bcd core: Include <algorithm> where used. 2018-01-11 22:36:56 -05:00