summaryrefslogtreecommitdiffstats
path: root/src/core/hle/kernel/svc.cpp (unfollow)
Commit message (Collapse)AuthorFilesLines
2023-12-04core: refactor emulated cpu core activationLiam1-1475/+1480
2023-10-22kernel: update KProcessLiam1-1/+1
2023-03-13kernel: prefer std::addressofLiam1-90/+90
2023-02-21svc: Fix type consistency (exposed on macOS)Merry1-8/+8
2023-02-13kernel: use GetCurrentProcessLiam1-1/+1
2023-02-07kernel/svc: switch to generated wrappersLiam1-429/+4415
2023-02-05kernel/svc: Split implementations into separate filesLiam1-2683/+3
2023-01-22kernel: KPageTable: updateLiam1-2/+2
2023-01-08Revert "Revert "k_page_group: synchronize""bunnei1-1/+1
2022-12-29Revert "k_page_group: synchronize"gidoly1-1/+1
2022-12-25k_page_group: synchronizeLiam1-1/+1
2022-12-15kernel: svc: Fix duplicated InfoType enumNarr the Reg1-90/+47
2022-12-15kernel: process: Implement GetFreeThreadCountNarr the Reg1-1/+14
Used by Just Dance® 2023 Edition
2022-11-12kernel: implement FlushProcessDataCacheLiam1-8/+18
2022-11-10kernel/svc_types: refreshLiam1-69/+48
2022-11-04core: hle: kernel: Add KEventInfo.bunnei1-1/+1
2022-10-31kernel: fix port trackingLiam1-1/+0
2022-10-31kernel: invert session request handling flowLiam1-2/+4
2022-10-22general: Enforce C4800 everywhere except in video_coreMorph1-2/+2
2022-10-19core: hle: kernel: k_process: Improve management of page table & cleanup.bunnei1-1/+1
2022-10-19core: hle: kernel: k_process: Change Status -> State.bunnei1-2/+2
2022-10-13kernel: remove KWritableEventLiam1-13/+12
2022-10-12k_server_session: preliminary support for userspace server sessionsLiam1-14/+68
2022-10-12Add implementation of svcCreateSessionLiam1-1/+89
2022-07-15kernel: use KScheduler from mesosphereLiam1-6/+1
2022-06-27core: kernel: Replace instances of KPageLinkedList with KPageGroupgerman771-1/+1
2022-06-27core: Replace all instances of ResultCode with Resultgerman771-149/+143
2022-06-26Re-add missing `case` and braces, and trim whitespacecomex1-1/+3
2022-06-26Update src/core/hle/kernel/svc.cppcomex1-6/+14
Co-authored-by: liamwhite <liamwhite@users.noreply.github.com>
2022-06-26Support InfoType_MesosphereCurrentProcesscomex1-0/+14
2022-06-23kernel: make current thread pointer thread localLiam1-7/+6
2022-06-16Implement ExitProcess svcNikita Strygin1-1/+2
Currently this just stops all the emulation This works under assumption that only application will try to use ExitProcess, with services not touching it If application exits - it quite makes sense to end the emulation
2022-06-15kernel: notify debugger on break SVCLiam1-0/+7
2022-06-15core: centralize profile scope for DynarmicLiam1-3/+0
2022-06-14kernel: implement KProcess suspensionLiam1-1/+1
2022-06-14common: Change semantics of UNREACHABLE to unconditionally crashLiam1-1/+1
2022-04-24kernel: svc: Replace -1ULL with 0xFFFFFFFFFFFFFFFFMorph1-1/+1
Resolves the C4146 compiler warning on MSVC.
2022-04-23general: Convert source file copyright comments over to SPDXMorph1-3/+2
This formats all copyright comments according to SPDX formatting guidelines. Additionally, this resolves the remaining GPLv2 only licensed files by relicensing them to GPLv2.0-or-later.
2022-04-09hle: kernel: Invalidate entire icache in UnmapProcessMemory and UnmapCodeMemory (fixes #8174)tech-ticks1-1/+2
2022-03-26hle: kernel: svc: MapProcessMemory: Fix usage of KPageLinkedList to use physical address space.bunnei1-2/+5
2022-03-26hle: kernel: svc: CreateCodeMemory: Remove log of 'out' host pointer.bunnei1-2/+2
- This does not seem terribly useful and is inconsistent with other usage.
2022-03-26hle: kernel: svc: UnmapProcessCodeMemory: Fix inverted alignment check.bunnei1-1/+1
2022-02-21core: hle: kernel: KEvent: Pass in owner KProcess on event creation.bunnei1-1/+1
- This is necessary to ensure resource limits are freed from the right process.
2022-02-15kernel: svc: Add OutputDebugString32, CreateCodeMemory32, ControlCodeMemory32Sergi Granell1-4/+18
Very straightforward, they are just wrappers to the 64-bit version of the SVC.
2022-02-09svc: Set unique names for function tablesNarr the Reg1-77/+77
2022-02-04service: pm: Implement AtmosphereGetProcessInfotech-ticks1-1/+1
2022-02-01svc: Add 32 bit SynchronizePreemptionStateNarr the Reg1-1/+1
Used by Espgaluda II
2022-01-22core: hle: kernel: Rename Un/Map to Un/MapMeory.bunnei1-2/+2
2022-01-12hle: kernel: k_page_table: Update SetProcessMemoryPermission.bunnei1-1/+3
2022-01-12hle: kernel: k_page_table: Rename *ProcessCodeMemory -> *CodeMemory.bunnei1-2/+2
2022-01-08core: hle: kernel: svc: Updates to SetMemoryAttribute and SetMemoryPermission.bunnei1-30/+20
2021-12-31core: hle: kernel: Implement thread pinning.bunnei1-1/+20
- We largely had the mechanics in place for thread pinning, this change hooks these up. - Validated with tests https://github.com/Atmosphere-NX/Atmosphere/blob/master/tests/TestSvc/source/test_thread_pinning.cpp.
2021-12-28core: hle: kernel: Updated implementation of svcSetHeapSize.bunnei1-16/+7
- Updates our svcSetHeapSize with latest HOS, furthermore allowing heap size to properly be extended/shrunk. - Validated with tests https://github.com/Atmosphere-NX/Atmosphere/blob/master/tests/TestSvc/source/test_set_heap_size.cpp.
2021-12-23core: hle: kernel: Implement SetMemoryPermission.bunnei1-1/+31
- Not seen in any games yet, but validated with kernel tests.
2021-12-22hle: kernel: svc: GetInfo: Fix error checking with IdleTickCount.bunnei1-14/+9
- Enforce tha the supplied handle is invalid, not valid. - This gets Witcher 3 booting.
2021-12-18core: hle: Remove global HLE lock.bunnei1-9/+0
- This was added early on as a hack to protect against some concurrency issues. - It's not clear that this serves any purpose anymore, and if it does, individual components should be fixed rather than using a global recursive mutex.
2021-12-07hle: kernel: svc: Fix deadlock that can occur with single core.bunnei1-10/+8
2021-12-07hle: kernel: KServerSession: Migrate to updated KThreadQueue.bunnei1-3/+10
2021-12-07hle: kernel: KThread: Remove tracking of sync object from threads.bunnei1-2/+1
2021-12-07core: hle: kernel: Reflect non-emulated threads as core 3.bunnei1-2/+3
2021-12-05kernel: svc: Implement Map/UnmapProcessMemory and Create/ControlCodeMemoryitsmeft241-4/+210
Used by Skyline modding framework
2021-11-21kernel: svc: Move all IsValid functions to an anonymous namespaceMorph1-3/+15
2021-11-21kernel: svc: Implement SetProcessMemoryPermissionMorph1-1/+41
- Used by Skyline modding framework
2021-11-04general: Rename GetTitleID to GetProgramIDMorph1-1/+1
2021-11-04core: Remove unused includesameerj1-10/+0
2021-11-03svc: Correct WaitSynchronization num_handles param typeMorph1-2/+2
num_handles is a s32
2021-10-27Fix memory leakFeng Chen1-0/+6
2021-10-16SVC: Implement svcInfo:IdleTickCountFernando Sahmkow1-0/+17
Used by the Witcher 3
2021-09-25Fix KScopedAutoObject object leak when SendSyncRequestFeng Chen1-6/+8
2021-08-26Revert "kernel: Various improvements to scheduler"bunnei1-1/+1
2021-08-19Fix check is thread current in GetThreadContextValeri1-1/+1
Misplaced break made it only check for the first core.
2021-08-07core: hle: kernel: Reflect non-emulated threads as core 3.bunnei1-1/+1
2021-07-21hle: kernel: svc: Remove part of ExitProcess.bunnei1-5/+0
- ExitProcess is not actually implemented either way, and this needs more work before we implement.
2021-07-21kernel: svc: ConnectToNamedPort: Close extra reference to port.bunnei1-0/+1
2021-06-10kernel: svc: Add missing error check to CancelSynchronization.bunnei1-2/+2
- Avoids a potential crash if the handle is invalid, and also makes this code accurate to real kernel behavior.
2021-06-02general: Replace RESULT_SUCCESS with ResultSuccessMorph1-52/+52
Transition to PascalCase for result names.
2021-05-16core: Make variable shadowing a compile-time errorLioncash1-3/+3
Now that we have most of core free of shadowing, we can enable the warning as an error to catch anything that may be remaining and also eliminate this class of logic bug entirely.
2021-05-11hle: kernel: svc: Update ConnectToNamedPort to use new CreateNamedServicePort interface.bunnei1-4/+3
2021-05-06kernel: svc: Remove unused RetrieveResourceLimitValue function.bunnei1-32/+0
2021-05-06hle: kernel: svc: ConnectToNamedPort: Use KHandleTable::Reserve.bunnei1-3/+8
2021-05-06hle: kernel: Migrate to KHandleTable.bunnei1-4/+4
2021-05-06hle: kernel: Improve MapSharedMemory and implement UnmapSharedMemory.bunnei1-60/+78
2021-05-06hle: kernel: Rename Process to KProcess.bunnei1-15/+15
2021-05-06hle: kernel: Migrate KPort, KClientPort, and KServerPort to KAutoObject.bunnei1-9/+13
2021-05-06hle: kernel: Migrate KClientPort to KAutoObject.bunnei1-1/+1
2021-05-06hle: kernel: HandleTable: Remove deprecated APIs.bunnei1-1/+1
2021-05-06hle: kernel: Migrate KResourceLimit to KAutoObject.bunnei1-63/+64
2021-05-06hle: kernel: svc: Migrate WaitSynchronization.bunnei1-47/+23
2021-05-06hle: kernel: svc: Use new handle table API for Process.bunnei1-13/+12
2021-05-06hle: kernel: Migrate KTransferMemory to KAutoObject.bunnei1-45/+48
2021-05-06hle: kernel: Migrate KSession, KClientSession, and KServerSession to KAutoObject.bunnei1-10/+8
2021-05-06hle: kernel: svc: Migrate GetThreadContext, GetThreadCoreMask.bunnei1-2/+59
2021-05-06hle: kernel: svc: Migrate GetProcessId, CancelSynchronization, SetThreadActivity.bunnei1-13/+67
2021-05-06hle: kernel: svc_results: Update naming..bunnei1-19/+19
2021-05-06hle: kernel: Migrate KReadableEvent and KWritableEvent to KAutoObject.bunnei1-38/+32
2021-05-06hle: kernel: Refactor several threads/events/sharedmemory to use slab heaps.bunnei1-2/+2
2021-05-06hle: kernel: Migrate KEvent to KAutoObject.bunnei1-6/+3
2021-05-06hle: kernel: Migrate KSharedMemory to KAutoObject.bunnei1-12/+9
2021-05-06hle: kernel: Migrate KProcess to KAutoObject.bunnei1-3/+3
2021-05-06hle: kernel: Refactor IPC interfaces to not use std::shared_ptr.bunnei1-1/+1
2021-05-06hle: kernel: Migrate more of KThread to KAutoObject.bunnei1-200/+68
2021-05-06hle: kernel: svc: Migrate GetThreadPriority, StartThread, and ExitThread.bunnei1-21/+12
2021-05-06hle: kernel: svc: Migrate CreateThread.bunnei1-14/+21
2021-04-14k_resource_limit: Minor cleanup of member variables/headersameerj1-1/+1
2021-04-07svc: Expand SVC tablesLioncash1-0/+132
12.x expanded the range of SVC entries from 0x7F to 0xBF (with all new entries being unused), so we can expand it to also match.
2021-03-06hle: kernel: KThread: Rework dummy threads & fix memory leak.bunnei1-2/+3
- Dummy threads are created on thread local storage for all host threads. - Fixes a leak by removing creation of fibers, which are not applicable here.
2021-03-06Revert "core: Switch to unique_ptr for usage of Common::Fiber."bunnei1-1/+2
2021-02-27core: Switch to unique_ptr for usage of Common::Fiber.bunnei1-2/+1
- With using unique_ptr instead of shared_ptr, we have more explicit ownership of the context. - Fixes a memory leak due to circular reference of the shared pointer.
2021-02-19hle: kernel: Migrate PageHeap/PageTable to KPageHeap/KPageTable.bunnei1-3/+3
2021-02-19hle: kernel: Migrate to KMemoryBlock, KMemoryBlockManager, and others.bunnei1-14/+14
2021-02-19hle: kernel: Migrate MemoryLayout to KMemoryLayout.bunnei1-7/+6
2021-02-19hle: kernel: Rename SharedMemory to KSharedMemory.bunnei1-2/+2
2021-02-13kernel: More accurately reserve and release resourcesameerj1-8/+13
2021-02-13kernel: KScopedReservation implementationameerj1-3/+30
This implements KScopedReservation, allowing resource limit reservations to be more HW accurate, and release upon failure without requiring too many conditionals.
2021-02-13kernel: Unify result codes (#5890)Chloe1-98/+98
* kernel: Unify result codes Drop the usage of ERR_NAME convention in kernel for ResultName. Removed seperation between svc_results.h & errors.h as we mainly include both most of the time anyways. * oops * rename errors to svc_results
2021-02-06svc: Provide more detailed error logs for svc functionsLioncash1-59/+188
Allows SVC calls to have much more informative information during error cases. This also doesn't hide control flow returns from the reader.
2021-02-05hle: kernel: svc: Cleanup KEvent/KReadableEvent/KWritableEvent SVCs.bunnei1-57/+78
2021-02-05hle: kernel: Reimplement KReadableEvent and KWritableEvent.bunnei1-4/+5
2021-02-05hle: kernel: Rename WritableEvent to KWritableEvent.bunnei1-4/+4
2021-02-05hle: kernel: Rename ReadableEvent to KReadableEvent.bunnei1-3/+3
2021-02-03Simplify limitableresource namesChloe Marcec1-5/+3
2021-01-30Move to GetGlobalTimeNs, fix GetTotalPhysicalMemoryAvailableChloe Marcec1-4/+3
2021-01-30kernel: Rewrite resource limit to be more accurateChloe Marcec1-12/+16
Matches closer to hardware
2021-01-29hle: kernel: process: Add state lock.bunnei1-4/+7
2021-01-29hle: kernel: Recode implementation of KThread to be more accurate.bunnei1-203/+152
2021-01-29hle: kernel: KThread: Clean up thread priorities.bunnei1-40/+26
2021-01-29hle: kernel: KThread: Reorganize thread priority defaults.bunnei1-6/+4
2021-01-29hle: kernel: KThread: Fix ThreadType definition.bunnei1-3/+2
2021-01-29core: hle: kernel: Rename Thread to KThread.bunnei1-15/+15
2021-01-11hle: kernel: thread: Preserve thread wait reason for debugging only.bunnei1-0/+1
- This is decoupled from core functionality and used for debugging only.
2021-01-11core: hle: Integrate new KConditionVariable and KAddressArbiter implementations.bunnei1-237/+127
2021-01-11hle: kernel: thread: Replace ThreadStatus/ThreadSchedStatus with a single ThreadState.bunnei1-6/+5
- This is how the real kernel works, and is more accurate and simpler.
2021-01-11core: hle: kernel: Update KSynchronizationObject.bunnei1-30/+17
2020-12-29svc: demote SleepThread log to LOG_TRACEameerj1-1/+1
This log is called often, and introduces a lot of noise when debug logging is enabled, making it difficult to see other debug logs.
2020-12-08svc: Remove unnecessary castsLioncash1-35/+25
Simplifies and removes some casts. In all cases, these were generally widening from a 32-bit unsigned type to a 64-bit unsigned type, so no information would be lost from the conversion.
2020-12-06hle: kernel: Migrate to KScopedSchedulerLock.bunnei1-4/+4
2020-12-06hle: kernel: Separate KScopedSchedulerLockAndSleep from k_scheduler.bunnei1-1/+2
2020-12-06hle: kernel: Rewrite scheduler implementation based on Mesopshere.bunnei1-31/+26
2020-12-06hle: kernel: svc: Remove reschedule on svcBreak.bunnei1-5/+0
- This breaks things, and is unnecessary, since emulation will be done at this point.
2020-12-06hle: kernel: svc: Remove unnecessary hack in svcSleep.bunnei1-7/+0
2020-12-06hle: kernel: Port KAffinityMask from Mesosphere.bunnei1-1/+1
2020-11-29hle: kernel: multicore: Replace n-JITs impl. with 4 JITs.bunnei1-0/+9
2020-11-23svc: Remove unnecessary [[maybe_unused]] tagLioncash1-1/+1
The parameter is used in this function, so this suppression isn't necessary.
2020-10-21Revert "core: Fix clang build"bunnei1-4/+3
2020-10-18core: Fix clang buildLioncash1-3/+4
Recent changes to the build system that made more warnings be flagged as errors caused building via clang to break. Fixes #4795
2020-09-14kernel: Remove all dependencies on the global system instanceLioncash1-1/+1
With this, the kernel finally doesn't depend directly on the global system instance anymore.
2020-07-16kernel: Remove unused variablesLioncash1-5/+2
Resolves some compiler warnings in the Linux build.
2020-06-27SVC: Implement 32-bits wrappers and update Dynarmic.Fernando Sahmkow1-27/+171
2020-06-27SVC: Add GetCurrentProcessorNumber32, CreateTransferMemory32, SetMemoryAttribute32Fernando Sahmkow1-6/+23
2020-06-27SVC: Add GetThreadPriority32 & SetThreadPriority32Fernando Sahmkow1-2/+12
2020-06-27Common/Kernel: Corrections and small bug fixing.Fernando Sahmkow1-2/+2
2020-06-27General: Cleanup legacy code.Fernando Sahmkow1-2/+1
2020-06-27Kernel/svcBreak: Implement CacheInvalidation for Singlecore and correct svcBreak.Fernando Sahmkow1-2/+2
2020-06-27HLE_IPC: Correct HLE Event behavior on timeout.Fernando Sahmkow1-1/+9
2020-06-27SingleCore: Use Cycle Timing instead of Host Timing.Fernando Sahmkow1-0/+5
2020-06-27General: Move ARM_Interface into Threads.Fernando Sahmkow1-9/+2
2020-06-27SVC/ARM: Correct svcSendSyncRequest and cache ticks on arm interface.Fernando Sahmkow1-1/+1
2020-06-27ARM: Addapt to new Exclusive Monitor Interface.Fernando Sahmkow1-3/+1
2020-06-27General: Fix microprofile on dynarmic/svc, fix wait tree showing which threads were running.Fernando Sahmkow1-3/+7
2020-06-27Kernel: Rewind on SVC change.Fernando Sahmkow1-5/+4
2020-06-27Kernel: Preempt Single core on redudant yields.Fernando Sahmkow1-6/+17
2020-06-27Kernel: Fixes, corrections and asserts to scheduler and different svcs.Fernando Sahmkow1-13/+14
2020-06-27ARM/Memory: Correct Exclusive Monitor and Implement Exclusive Memory Writes.Fernando Sahmkow1-1/+1
2020-06-27SVC: Correct SetThreadActivity.Fernando Sahmkow1-4/+1
2020-06-27SVC: Correct svcWaitForAddress and svcSignalToAddress.Fernando Sahmkow1-3/+0
2020-06-27Kernel: Corrections to Scheduling.Fernando Sahmkow1-1/+0
2020-06-27Core: Correct HLE Event Callbacks and other issues.Fernando Sahmkow1-3/+2
2020-06-27General: Add AssertsFernando Sahmkow1-0/+1
2020-06-27General: Add better safety for JIT use.Fernando Sahmkow1-1/+5
2020-06-27SVC: Correct races on physical core switching.Fernando Sahmkow1-5/+4
2020-06-27SVC: Add locks to the memory management.Fernando Sahmkow1-0/+21
2020-06-27SVC: Correct WaitSynchronization, WaitProcessWideKey, SignalProcessWideKey.Fernando Sahmkow1-27/+48
2020-06-27SVC: Cleanup old methods.Fernando Sahmkow1-13/+9
2020-06-27SVC: Correct SendSyncRequest.Fernando Sahmkow1-4/+17
2020-06-27SVC: Correct SignalEvent, ClearEvent, ResetSignal, WaitSynchronization, CancelSynchronization, ArbitrateLockFernando Sahmkow1-1/+0
2020-06-27SVC: Remove global HLE Lock.Fernando Sahmkow1-3/+0
2020-06-27SVC: Correct GetThreadPriority, SetThreadPriority, GetThreadCoreMask, SetThreadCoreMask, GetCurrentProcessorNumberFernando Sahmkow1-9/+8
2020-06-27SVC: Correct CreateThread, StartThread, ExitThread, SleepThread.Fernando Sahmkow1-13/+5
2020-06-27General: Recover Prometheus project from harddrive failure Fernando Sahmkow1-15/+6
This commit: Implements CPU Interrupts, Replaces Cycle Timing for Host Timing, Reworks the Kernel's Scheduler, Introduce Idle State and Suspended State, Recreates the bootmanager, Initializes Multicore system.
2020-04-29kernel: Don't fail silentlyDavid Marcec1-0/+7
2020-04-28kernel: Bad GetInfo ids should not be marked as stubsDavid Marcec1-2/+2
As we currently match hardware and don't return a successful result, these should be marked as errors instead of warnings and as stubs.
2020-04-24svc: Re-add MapProcessCodeMemory/UnmapProcessCodeMemoryLioncash1-2/+138
These were lost in the re-implementation of the virtual memory manager.
2020-04-23svc: Remove unused variableLioncash1-3/+0
Since the VMM refactor, this is no longer used or needed.
2020-04-17core: hle: Address various feedback & code cleanup.bunnei1-1/+1
- Should be no functional changes.
2020-04-17kernel: svc: Updates for new VMM.bunnei1-488/+116
- Includes removing some SVC impls. that are untested.
2020-04-17core: memory: Move to Core::Memory namespace.bunnei1-5/+5
- helpful to disambiguate Kernel::Memory namespace.
2020-04-17core: kernel: Add svc_types header to include SVC-specific types.bunnei1-0/+1
2020-04-17core: kernel: Move SVC to its own namesapce.bunnei1-3/+3
2020-03-03core: hle: Implement separate A32/A64 SVC interfaces.bunnei1-65/+264
2020-02-14Core: Address FeedbackFernando Sahmkow1-1/+1
2020-02-11Kernel: Refactor synchronization to better match REFernando Sahmkow1-60/+7
2020-02-11Kernel: Change WaitObject to Synchronization object. In order to better reflect RE.Fernando Sahmkow1-6/+7
2020-02-06kernel: transfer_memory: Properly reserve and reset memory region.bunnei1-2/+6
2020-01-26Core: Refactor CpuCoreManager to CpuManager and Cpu to Core Manager.Fernando Sahmkow1-1/+1
This commit instends on better naming the new purpose of this classes.
2019-12-11kernel/svc: Correct function signature of SignalProcessWideKeyLioncash1-4/+1
This function doesn't actually return a result code, so we can amend the signature of it to match.
2019-12-08kernel/svc: Provide implementations for svcDumpInfo/svcDumpInfoNewLioncash1-2/+13
These are fairly trivial to implement, we can just do nothing. This also provides a spot for us to potentially dump out any relevant info in the future (e.g. for debugging purposes with homebrew, etc). While we're at it, we can also correct the names of both of these supervisor calls.
2019-11-28kernel: Implement a more accurate IPC dispatch.bunnei1-4/+5
2019-11-27core/memory: Migrate over Write{8, 16, 32, 64, Block} to the Memory classLioncash1-12/+15
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-27core/memory: Migrate over Read{8, 16, 32, 64, Block} to the Memory classLioncash1-6/+10
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-27core/memory: Migrate over ReadCString() to the Memory classLioncash1-2/+4
This only had one usage spot, so this is fairly straightforward to convert over.
2019-11-27core: Prepare various classes for memory read/write migrationLioncash1-1/+1
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-27core/memory: Migrate over address checking functions to the new Memory classLioncash1-2/+2
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-25kernel: Replace usage of boost::intrusive_ptr with std::shared_ptr for kernel objects. (#3154)bunnei1-26/+26
* 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-23Update svc.cppbunnei1-0/+1
2019-11-23svc: GetSystemTick should return cntpct_el0, not core ticks.bunnei1-1/+3
2019-11-21Kernel: Optimize condition variable threads management.Fernando Sahmkow1-1/+1
2019-11-21Kernel: Correct SignalProcessWideKeyFernando Sahmkow1-6/+2
When the target is 0, all threads must be processed.
2019-11-21Kernel: Correct behavior of Condition Variables to be more similar to real hardware.Fernando Sahmkow1-15/+5
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-16Kernel: Correct Cancel Synchronization.Fernando Sahmkow1-0/+5
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-03kernel: events: Remove ResetType::Automatic.bunnei1-1/+1
- 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-10-15Kernel: Address Feedback.Fernando Sahmkow1-6/+6
2019-10-15KernelSVC: Assert that condition variable address is aligned to 4 bytes.Fernando Sahmkow1-0/+4
2019-10-15Kernel: Correct redundant yields to only advance time forward.Fernando Sahmkow1-3/+5
2019-10-15Kernel: Correct Results in Condition Variables and MutexesFernando Sahmkow1-18/+9
2019-10-15Scheduler: Add protections for Yield bombingFernando Sahmkow1-4/+9
In case of redundant yields, the scheduler will now idle the core for it's timeslice, in order to avoid continuously yielding the same thing over and over.
2019-10-15Kernel: Style and CorrectionsFernando Sahmkow1-6/+9
2019-10-15Correct PrepareRescheduleFernando Sahmkow1-32/+17
2019-10-15Correct Supervisor Calls to work with the new scheduler,Fernando Sahmkow1-26/+41
2019-07-18Kernel: Downgrade WaitForAddress and SignalToAddress messages to Trace.Fernando Sahmkow1-4/+4
This messages were originally set as warnning since few games used these svcs and it was needed for debugging. This is no longer the case.
2019-07-11Restore memory perms on svcUnmapMemory/UnloadNroMichael Scire1-1/+8
Prior to PR, Yuzu did not restore memory to RW- on unmap of mirrored memory or unloading of NRO. (In fact, in the NRO case, the memory was unmapped instead of reprotected to --- on Load, so it was actually lost entirely...) This PR addresses that, and restores memory to RW- as it should. This fixes a crash in Super Smash Bros when creating a World of Light save for the first time, and possibly other games/circumstances.
2019-07-07clang-format fixesMichael Scire1-2/+1
2019-07-07address review commentaryMichael Scire1-20/+12
2019-07-07Implement MapPhysicalMemory/UnmapPhysicalMemoryMichael Scire1-8/+102
This implements svcMapPhysicalMemory/svcUnmapPhysicalMemory for Yuzu, which can be used to map memory at a desired address by games since 3.0.0. It also properly parses SystemResourceSize from NPDM, and makes information available via svcGetInfo. This is needed for games like Super Smash Bros. and Diablo 3 -- this PR's implementation does not run into the "ASCII reads" issue mentioned in the comments of #2626, which was caused by the following bugs in Yuzu's memory management that this PR also addresses: * Yuzu's memory coalescing does not properly merge blocks. This results in a polluted address space/svcQueryMemory results that would be impossible to replicate on hardware, which can lead to game code making the wrong assumptions about memory layout. * This implements better merging for AllocatedMemoryBlocks. * Yuzu's implementation of svcMirrorMemory unprotected the entire virtual memory range containing the range being mirrored. This could lead to games attempting to map data at that unprotected range/attempting to access that range after yuzu improperly unmapped it. * This PR fixes it by simply calling ReprotectRange instead of Reprotect.
2019-07-07kernel/process: Allocate the process' TLS region during initializationLioncash1-3/+1
Prior to execution within a process beginning, the process establishes its own TLS region for uses (as far as I can tell) related to exception handling. Now that TLS creation was decoupled from threads themselves, we can add this behavior to our Process class. This is also good, as it allows us to remove a stub within svcGetInfo, namely querying the address of that region.
2019-07-06kernel/vm_manager: Rename 'new map' to 'stack'Lioncash1-10/+10
Provides a more accurate name for the memory region and also disambiguates between the map and new map regions of memory, making it easier to understand.
2019-06-10kernel/svc: Implement TotalMemoryUsedWithoutMmHeap/TotalMemoryAvailableWithoutMmHeapLioncash1-2/+15
Given we don't currently implement the personal heap yet, the existing memory querying functions are essentially doing what the memory querying types introduced in 6.0.0 do. So, we can build the necessary machinery over the top of those and just use them as part of info types.
2019-06-10kernel/svc: Amend naming for TotalMemoryUsage in svcGetInfo()Lioncash1-4/+4
Disambiguates and makes the name a little more consistent with TotalPhysicalMemoryUsed.
2019-06-10kernel/svc: Remove duplicate enum entry in svcGetInfo()Lioncash1-2/+1
2019-05-25svc: Save report on call to svcBreakZach Hilman1-1/+7
2019-05-19kernel/svc: Mark GetThreadList() and UnmapProcessCodeMemory() as internally linkedLioncash1-4/+4
These are only used from within this translation unit, so they don't need to have external linkage. They were intended to be marked with this anyways to be consistent with the other service functions.
2019-05-18core/kernel/object: Rename ResetType enum membersLioncash1-1/+1
Renames the members to more accurately indicate what they signify. "OneShot" and "Sticky" are kind of ambiguous identifiers for the reset types, and can be kind of misleading. Automatic and Manual communicate the kind of reset type in a clearer manner. Either the event is automatically reset, or it isn't and must be manually cleared. The "OneShot" and "Sticky" terminology is just a hold-over from Citra where the kernel had a third type of event reset type known as "Pulse". Given the Switch kernel only has two forms of event reset types, we don't need to keep the old terminology around anymore.
2019-04-29kernel/svc: Make svcCreateThread/svcStartThread/svcSleepThread/svcExitThread calls show up in the debug logLioncash1-4/+4
These are actually quite important indicators of thread lifetimes, so they should be going into the debug log, rather than being treated as misc info and delegated to the trace log.
2019-04-29kernel/svc: Reorganize svcSetThreadCoreMask()Lioncash1-32/+39
Makes the code much nicer to follow in terms of behavior and control flow. It also fixes a few bugs in the implementation. Notably, the thread's owner process shouldn't be accessed in order to retrieve the core mask or ideal core. This should be done through the current running process. The only reason this bug wasn't encountered yet is because we currently only support running one process, and thus every owner process will be the current process. We also weren't checking against the process' CPU core mask to see if an allowed core is specified or not. With this out of the way, it'll be less noisy to implement proper handling of the affinity flags internally within the kernel thread instances.
2019-04-29kernel/thread: Update thread processor ID flagsLioncash1-1/+1
Adds the missing flags to the enum and documents them.
2019-04-19kernel/svc: Name supervisor call 0x36Lioncash1-1/+1
This call was added to the SVC handlers in the 8.0.0 kernel, so we can finally give it a name.
2019-04-17kernel/thread: Unify wait synchronization typesLioncash1-2/+2
This is a holdover from Citra, where the 3DS has both WaitSynchronization1 and WaitSynchronizationN. The switch only has one form of wait synchronizing (literally WaitSynchonization). This allows us to throw out code that doesn't apply at all to the Switch kernel. Because of this unnecessary dichotomy within the wait synchronization utilities, we were also neglecting to properly handle waiting on multiple objects. While we're at it, we can also scrub out any lingering references to WaitSynchronization1/WaitSynchronizationN in comments, and change them to WaitSynchronization (or remove them if the mention no longer applies).
2019-04-17kernel/svc: Migrate svcCancelSynchronization behavior to a thread functionLioncash1-4/+2
The actual behavior of this function is slightly more complex than what we're currently doing within the supervisor call. To avoid dumping most of this behavior in the supervisor call itself, we can migrate this to another function.
2019-04-15svc: Specify handle value in thread's nameLioncash1-2/+5
Allows the handle to be seen alongside the entry point.
2019-04-14kernel/thread: Remove unused guest_handle member variableLioncash1-6/+5
This member variable is entirely unused. It was only set but never actually utilized. Given that, we can remove it to get rid of noise in the thread interface.
2019-04-13kernel/svc: Implement svcUnmapProcessCodeMemoryLioncash1-1/+69
Essentially performs the inverse of svcMapProcessCodeMemory. This unmaps the aliasing region first, then restores the general traits of the aliased memory. What this entails, is: - Restoring Read/Write permissions to the VMA. - Restoring its memory state to reflect it as a general heap memory region. - Clearing the memory attributes on the region.
2019-04-13kernel/svc: Implement svcMapProcessCodeMemoryLioncash1-1/+69
This is utilized for mapping code modules into memory. Notably, the ldr service would call this in order to map objects into memory.
2019-04-08kernel/svc: Deglobalize the supervisor call handlersLioncash1-162/+175
Adjusts the interface of the wrappers to take a system reference, which allows accessing a system instance without using the global accessors. This also allows getting rid of all global accessors within the supervisor call handling code. While this does make the wrappers themselves slightly more noisy, this will be further cleaned up in a follow-up. This eliminates the global system accessors in the current code while preserving the existing interface.
2019-04-04kernel/svc: Properly sanitize mutex address in WaitProcessWideKeyAtomicLioncash1-0/+14
We need to be checking whether or not the given address is within the kernel address space or if the given address isn't word-aligned and bail in these scenarios instead of trashing any kernel state.
2019-04-02kernel/svc: Implement svcGetThreadListLioncash1-1/+41
Similarly like svcGetProcessList, this retrieves the list of threads from the current process. In the kernel itself, a process instance maintains a list of threads, which are used within this function. Threads are registered to a process' thread list at thread initialization, and unregistered from the list upon thread destruction (if said thread has a non-null owning process). We assert on the debug event case, as we currently don't implement kernel debug objects.
2019-04-02kernel/svc: Implement svcGetProcessListLioncash1-1/+38
This service function simply copies out a specified number of kernel process IDs, while simultaneously reporting the total number of processes.
2019-04-01general: Use deducation guides for std::lock_guard and std::unique_lockLioncash1-1/+1
Since C++17, the introduction of deduction guides for locking facilities means that we no longer need to hardcode the mutex type into the locks themselves, making it easier to switch mutex types, should it ever be necessary in the future.
2019-03-29kernel/shared_memory: Sanitize supplied size when unmappingLioncash1-1/+1
The kernel makes sure that the given size to unmap is always the same size as the entire region managed by the shared memory instance, otherwise it returns an error code signifying an invalid size. This is similarly done for transfer memory (which we already check for).
2019-03-29kernel/process: Report total physical memory used to svcGetInfoLioncash1-4/+4
Reports the (mostly) correct size through svcGetInfo now for queries to total used physical memory. This still doesn't correctly handle memory allocated via svcMapPhysicalMemory, however, we don't currently handle that case anyways.
2019-03-24kernel/vm_manager: Rename HeapAllocate to SetHeapSizeLioncash1-2/+1
Makes it more obvious that this function is intending to stand in for the actual supervisor call itself, and not acting as a general heap allocation function. Also the following change will merge the freeing behavior of HeapFree into this function, so leaving it as HeapAllocate would be misleading.
2019-03-24kernel/vm_manager: Remove unnecessary heap_used data memberLioncash1-1/+1
This isn't required anymore, as all the kernel ever queries is the size of the current heap, not the total usage of it.
2019-03-24kernel/vm_manager: Tidy up heap allocation codeLioncash1-4/+2
Another holdover from citra that can be tossed out is the notion of the heap needing to be allocated in different addresses. On the switch, the base address of the heap will always be managed by the memory allocator in the kernel, so this doesn't need to be specified in the function's interface itself. The heap on the switch is always allocated with read/write permissions, so we don't need to add specifying the memory permissions as part of the heap allocation itself either. This also corrects the error code returned from within the function. If the size of the heap is larger than the entire heap region, then the kernel will report an out of memory condition.
2019-03-20Fix small bug that kept a thread as a condvar thread after being signalled.Fernando Sahmkow1-5/+6
2019-03-20Add CondVar Thread State.Fernando Sahmkow1-2/+2
2019-03-20Small fixes to address_arbiter to better match the IDB.Fernando Sahmkow1-2/+2
2019-03-16kernel/thread: Move thread exiting logic from ExitCurrentThread to svcExitThreadLioncash1-3/+7
Puts the operation on global state in the same places as the rest of the svc calls.
2019-03-16kernel/thread: Migrate WaitCurrentThread_Sleep into the Thread interfaceLioncash1-11/+11
Rather than make a global accessor for this sort of thing. We can make it a part of the thread interface itself. This allows getting rid of a hidden global accessor in the kernel code.
2019-03-15core/hle/kernel: Make Mutex a per-process class.Lioncash1-6/+11
Makes it an instantiable class like it is in the actual kernel. This will also allow removing reliance on global accessors in a following change, now that we can encapsulate a reference to the system instance in the class.
2019-03-13core/hle/kernel/svc: Implement svcUnmapTransferMemoryLioncash1-1/+48
Similarly, like svcMapTransferMemory, we can also implement svcUnmapTransferMemory fairly trivially as well.
2019-03-13core/hle/kernel/svc: Implement svcMapTransferMemoryLioncash1-1/+57
Now that transfer memory handling is separated from shared memory, we can implement svcMapTransferMemory pretty trivially.
2019-03-13core/hle/kernel: Split transfer memory handling out into its own classLioncash1-4/+9
Within the kernel, shared memory and transfer memory facilities exist as completely different kernel objects. They also have different validity checking as well. Therefore, we shouldn't be treating the two as the same kind of memory. They also differ in terms of their behavioral aspect as well. Shared memory is intended for sharing memory between processes, while transfer memory is intended to be for transferring memory to other processes. This breaks out the handling for transfer memory into its own class and treats it as its own kernel object. This is also important when we consider resource limits as well. Particularly because transfer memory is limited by the resource limit value set for it. While we currently don't handle resource limit testing against objects yet (but we do allow setting them), this will make implementing that behavior much easier in the future, as we don't need to distinguish between shared memory and transfer memory allocations in the same place.
2019-03-08kernel: Make the address arbiter instance per-processLioncash1-2/+4
Now that we have the address arbiter extracted to its own class, we can fix an innaccuracy with the kernel. Said inaccuracy being that there isn't only one address arbiter. Each process instance contains its own AddressArbiter instance in the actual kernel. This fixes that and gets rid of another long-standing issue that could arise when attempting to create more than one process.
2019-03-08kernel/svc: Move address arbiter signaling behind a unified API functionLioncash1-15/+2
Similar to how WaitForAddress was isolated to its own function, we can also move the necessary conditional checking into the address arbiter class itself, allowing us to hide the implementation details of it from public use.
2019-03-08kernel/svc: Move address arbiter waiting behind a unified API functionLioncash1-14/+2
Rather than let the service call itself work out which function is the proper one to call, we can make that a behavior of the arbiter itself, so we don't need to directly expose those implementation details.
2019-03-05kernel/address_arbiter: Convert the address arbiter into a classLioncash1-6/+8
Places all of the functions for address arbiter operation into a class. This will be necessary for future deglobalizing efforts related to both the memory and system itself.
2019-03-05core/hle/ipc: Remove unnecessary includesLioncash1-0/+1
Removes a few inclusion dependencies from the headers or replaces existing ones with ones that don't indirectly include the required headers. This allows removing an inclusion of core/memory.h, meaning that if the memory header is ever changed in the future, it won't result in rebuilding the entirety of the HLE services (as the IPC headers are used quite ubiquitously throughout the HLE service implementations).
2019-03-04svc: Migrate address range checking functions to VMManagerLioncash1-21/+4
Provides a bit of a more proper interface for these functions.
2019-02-16core_timing: Convert core timing into a classLioncash1-4/+6
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.
2019-02-12core_timing: Rename CoreTiming namespace to Core::TimingLioncash1-4/+4
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.
2019-01-27kernel/svc: Log out uncaught C++ exceptions from svcBreakLioncash1-0/+4
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.
2018-12-31kernel/svc: Correct misleading error message within CreateThread()Lioncash1-2/+3
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.
2018-12-31kernel/svc: Sanitize core number and thread priorities in CreateThread()Lioncash1-6/+17
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.
2018-12-31kernel/process: Rename GetAllowedProcessorMask() and GetAllowedThreadPriorityMask()Lioncash1-8/+8
Makes them consistent with their kernel capability counterparts.
2018-12-31kernel/svc: Simplify thread core ID sanitizing in CreateThreadLioncash1-7/+1
Rather than use a switch here, this can be collapsed into a simple range check, which is a little easier on the eyes.
2018-12-28kernel: Rename 'default' CPU core to 'ideal' coreLioncash1-9/+9
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.
2018-12-28kernel/process: Remove most allocation functions from Process' interfaceLioncash1-14/+18
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.
2018-12-19kernel/svc: Handle thread handles within GetProcessIdLioncash1-10/+23
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.
2018-12-19svc: Implement svcSetMemoryAttributeLioncash1-5/+46
With all the basic backing functionality implemented, we can now unstub svcSetMemoryAttribute.
2018-12-19kernel/svc: Correct output parameter for svcGetThreadIdLioncash1-1/+1
The service call uses a 64-bit value, just like svcGetProcessId. This amends the function signature accordingly.
2018-12-19kernel/svc: Correct output parameter for svcGetProcessIdLioncash1-1/+1
svcGetProcessId's out parameter is a pointer to a 64-bit value, not a 32-bit one.
2018-12-19Moved backtrace to ArmInterfaceDavid Marcec1-2/+3
2018-12-12svc: Enable svcQueryProcessMemoryLioncash1-1/+1
svcQueryProcessMemory is trivial to implement, given all the behavior necessary for it is present, it just needs a handler for it.
2018-12-12svc: Write out the complete MemoryInfo structure in QueryProcessMemoryLioncash1-0/+3
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.
2018-12-12svc: Handle memory writing explicitly within QueryProcessMemoryLioncash1-9/+22
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.
2018-12-12vm_manager: Migrate memory querying to the VMManager interfaceLioncash1-16/+4
Gets rid of the need to directly access the managed VMAs outside of the memory manager itself just for querying memory.
2018-12-12vm_manager: Amend MemoryState enum membersLioncash1-2/+2
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.
2018-12-12Fix Process object leak on emulation stopJens Schmer1-7/+6
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.
2018-12-06vm_manager: Make vma_map privateLioncash1-8/+12
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.
2018-12-05svc: Avoid incorrect fast yield conditionZach Hilman1-6/+1
2018-12-05kernel/svc: Correct behavior of svcResetSignal()Lioncash1-4/+11
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.
2018-12-04kernel/svc: Remove unused header inclusionLioncash1-1/+0
2018-12-04kernel/svc: Implement svcSignalEvent()Lioncash1-1/+16
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.
2018-12-04kernel/svc: Implement svcCreateEvent()Lioncash1-1/+29
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.
2018-12-04kernel/object: Amend handle types to distinguish between readable and writable eventsLioncash1-6/+13
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.
2018-12-04kernel/svc: Implement the resource limit svcGetInfo optionLioncash1-1/+28
Allows a process to register the resource limit as part of its handle table.
2018-12-04svc: Implement SetThreadActivity (thread suspension)Luke Street1-4/+34
2018-12-04[Kernel::CreateThread] Match format specifiers to LOG_TRACE's argumentsV.Kalyuzhny1-1/+1
2018-12-04scheduler: Avoid manual Reschedule callZach Hilman1-1/+3
This will automatically occur anyway when PrepareReschedule is called
2018-12-03scheduler: Only work steal higher priority threads from other coresZach Hilman1-10/+6
2018-12-03Print backtrace on svcBreakDavid Marcec1-0/+2
When we get an svcBreak we get a backtrace now
2018-12-02svc: Use the current process' handle table for retrieving the process instance to act uponLioncash1-1/+2
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.
2018-12-02svc: Reorganize svcGetInfo, handle more error cases for existing implemented info categoriesLioncash1-50/+99
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.
2018-12-02svc: Avoid performance-degrading unnecessary rescheduleZach Hilman1-7/+4
2018-12-01Fix debug buildLioncash1-1/+1
A non-existent parameter was left in some formatting calls (the logging macro for which only does anything meaningful on debug builds)
2018-11-29kernel/event: Reference ReadableEvent from WritableEventZach Hilman1-2/+2
2018-11-29core: Port all current usages of Event to Readable/WritableEventZach Hilman1-5/+6
2018-11-27svc: Implement svcSetResourceLimitLimitValue()Lioncash1-1/+36
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.
2018-11-27svc: Implement svcGetResourceLimitCurrentValue()Lioncash1-16/+49
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.
2018-11-27svc: Implement svcGetResourceLimitLimitValue()Lioncash1-1/+28
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.
2018-11-27svc: Implement svcCreateResourceLimit()Lioncash1-1/+19
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.
2018-11-27Added comment on Main memory size for more clarityDavid Marcec1-0/+1
2018-11-27Made svcSetHeapSize and svcCreateSharedMemory more readableDavid Marcec1-4/+4
2018-11-27Reworked svcs slightly, improved error messages in AM and fsp_srvDavid Marcec1-12/+20
2018-11-26Improved error messages for SVCsDavid Marcec1-76/+170
2018-11-26Changed logging to be "Log before execution", Added more error logging, all services should now log on some levelDavid Marcec1-11/+90
2018-11-25svc: Return ERR_INVALID_ENUM_VALUE from svcGetInfoLuke Street1-1/+2
2018-11-22scheduler: Add explanations for YieldWith and WithoutLoadBalancingZach Hilman1-7/+14
2018-11-20kernel/resource_limit: Clean up interfaceLioncash1-11/+0
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.
2018-11-19kernel/shared_memory: Make Map() and Unmap() take the target process by reference rather than as a pointerLioncash1-2/+2
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.
2018-11-19svc: Implement yield types 0 and -1Zach Hilman1-2/+25
2018-11-18svc: ResetSignal is not stubbedTobias1-1/+1
https://user-images.githubusercontent.com/20753089/48677874-b8e01c80-eb7b-11e8-8043-b99faa29022c.PNG
2018-11-18am: Deglobalize software keyboard appletZach Hilman1-4/+4
2018-11-18svc: Implement svcCreateTransferMemoryZach Hilman1-3/+33
Seems to be used and created identically to SharedMemory, so just reuse that.
2018-11-16kernel/errors: Clean up error codesLioncash1-10/+10
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.
2018-11-13svc: Use proper random entropy generation algorithmZach Hilman1-1/+10
2018-11-13svc: Return random seed for svcGetInfo RandomEntropyZach Hilman1-1/+2
2018-11-08svcBreak now dumps information from the debug buffer passed (#1646)David1-0/+28
* 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
2018-11-06Implement SetMemoryPermissionFrederic Laing1-3/+39
2018-11-03Stubbed SetMemoryPermissionFrederic Laing1-1/+7
2018-10-28core: Make System references const where applicableLioncash1-1/+1
2018-10-26svc: Localize the GetInfo enum class to the function itselfLioncash1-0/+31
Nothing from this enum is intended to be used outside of this function.
2018-10-26svc: Implement svcGetInfo command 0xF0000002Lioncash1-0/+30
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; }
2018-10-24kernel/svc: Amend returned error code for invalid priorities in CreateThreadLioncash1-1/+1
Like with the previous change, the kernel doesn't return NOT_AUTHORIZED here. It returns INVALID_THREAD_PRIORITY.
2018-10-24kernel/svc: Move and correct returned error code for invalid thread priorities in SetThreadPriority()Lioncash1-5/+6
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.
2018-10-23Added assertion failed, reworked logging levelsDavid Marcec1-16/+24
2018-10-23Added break types to svcBreakDavid Marcec1-4/+42
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
2018-10-20kernel/process: Make the handle table per-processLioncash1-60/+60
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.
2018-10-20svc: Fix vma boundary check in svcQueryMemoryLioncash1-1/+1
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.
2018-10-18svc: Check for word alignment of addresses within svcArbitrateLock/svcArbitrateUnlockLioncash1-0/+8
The kernel itself checks whether or not the provided addresses are word aligned before continuing, so we should be doing the same.
2018-10-18common: Move Is4KBAligned() to alignment.hLioncash1-9/+7
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.
2018-10-18svc: Add missing sanitizing checks for MapSharedMemory/UnmapSharedMemoryLioncash1-3/+27
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.
2018-10-15core_cpu: Make Cpu scheduler instances unique_ptrs instead of shared_ptrsLioncash1-1/+1
2018-10-15svc: Clarify enum values for AddressSpaceBaseAddr and AddressSpaceSize in svcGetInfo()Lioncash1-17/+4
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.
2018-10-14Stop all threads on svcBreakDavid Marcec1-0/+6
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)
2018-10-13svc: Implement svcGetProcessInfoLioncash1-1/+24
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.
2018-10-12svc: Fix typos in sanitizing checks for MapMemory/UnmapMemoryLioncash1-3/+3
2018-10-11svc: Add missing address range sanitizing checks to MapMemory/UnmapMemoryLioncash1-12/+79
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 processLioncash1-6/+6
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-10Use a better name than "dont_kill_application"David Marcec1-2/+2
signal_debugger seems like a more fitting name
2018-10-10Fixed incorrect types for svcBreakDavid Marcec1-3/+3
svcBreak reason should be a u32, not a u64.
2018-10-09Added bitfield instead of manually checking if the bit is setDavid Marcec1-4/+12
2018-10-09Actual kill execution when the bit isn't set, not the other way aroundDavid Marcec1-1/+1
2018-10-09svcBreak, Signalling to the debugger should not kill executionDavid Marcec1-5/+12
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-04kernel/thread: Make all instance variables privateLioncash1-57/+64
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()Lioncash1-2/+30
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: Make data member variables privateLioncash1-15/+15
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-25memory: Dehardcode the use of fixed memory range constantsLioncash1-1/+2
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-25svc: Report correct memory-related values within some of the cases in svcGetInfo()Lioncash1-14/+28
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-24svc: Updated svc namestech4me1-7/+7
2018-09-21svc: Move most process termination code to its own function within ProcessLioncash1-27/+5
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-18kernel/svc: Handle error cases for svcArbitrateLock() and svcArbitrateUnlock()Lioncash1-0/+8
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-15Port # #4192 from Citra: "svc: change unknown to thread in CreateThread"Valentin Vanelslande1-1/+1
2018-09-15Port #4182 from Citra: "Prefix all size_t with std::"fearlessTobi1-13/+14
2018-09-14kernel/svc: Sanitize creation of shared memory via svcCreateSharedMemory()Lioncash1-2/+18
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".
2018-09-14kernel/svc: Sanitize addresses, permissions, and sizes within svcMapSharedMemory() and svcUnmapSharedMemory()Lioncash1-17/+25
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.
2018-09-14kernel/svc: Sanitize addresses and sizes within svcMapMemory() and svcUnmapMemory()Lioncash1-0/+23
The kernel checks if the addresses and given size is 4KB aligned before continuing onwards to map the memory.
2018-09-14kernel/svc: Sanitize heap sizes within svcSetHeapSize()Lioncash1-0/+6
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.
2018-09-12svc: Return ERR_INVALID_PROCESSOR_ID in CreateThread() if an invalid processor ID is givenLioncash1-2/+2
This is what the kernel does for an out-of-range processor ID.
2018-09-12kernel/errors: Correct error codes for invalid thread priority and invalid processor IDLioncash1-2/+2
2018-09-12svc: Do nothing if svcOutputDebugString() is given a length of zeroLioncash1-0/+4
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.
2018-09-12svc: Correct parameter type for OutputDebugString()Lioncash1-1/+1
This should be a u64 to represent size.
2018-09-02service: Migrate global named port map to the KernelCore classLioncash1-5/+7
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.
2018-08-31core/core: Replace includes with forward declarations where applicableLioncash1-0/+4
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.
2018-08-29kernel: Eliminate kernel global stateLioncash1-25/+55
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.
2018-08-25svc: Return process title ID if queried in GetInfo()Lioncash1-2/+1
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.
2018-08-15kernel/svc: Log svcBreak parametersLioncash1-2/+5
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.
2018-08-13Kernel/SVC: Don't reschedule the current core when creating a new thread.Subv1-1/+0
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.
2018-08-12Kernel/Mutex: Don't duplicate threads in the mutex waiter list.Subv1-2/+1
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.
2018-08-02kernel/vm_manager: Use const where applicableLioncash1-1/+1
Makes our immutable state explicit.
2018-07-31kernel: Remove unused object_address_table.cpp/.hLioncash1-1/+0
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.
2018-07-31kernel: Remove unnecessary includesLioncash1-0/+3
Removes unnecessary direct dependencies in some headers and also gets rid of indirect dependencies that were being relied on to be included.
2018-07-24svc: Resolve sign comparison warnings in WaitSynchronization()Lioncash1-4/+7
The loop's induction variable was signed, but we were comparing against an unsigned variable.
2018-07-24svc: Log parameters in SetMemoryAttribute()Lioncash1-1/+3
Provides slightly more context than only logging out the address value.
2018-07-22Kernel/SVC: Perform atomic accesses in SignalProcessWideKey as per the real kernel.Subv1-7/+31
2018-07-20thread: Convert ThreadStatus into an enum classLioncash1-10/+10
Makes the thread status strongly typed, so implicit conversions can't happen. It also makes it easier to catch mistakes at compile time.
2018-07-19svc: Correct always true assertion case in SetThreadCoreMaskLioncash1-3/+4
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-03Update clang formatJames Rowe1-28/+25
2018-07-03Rename logging macro back to LOG_*James Rowe1-47/+47
2018-06-22Kernel/Arbiters: Fix casts, cleanup comments/magic numbersMichael Scire1-4/+4
2018-06-22Add additional missing format.Michael Scire1-19/+21
2018-06-21Kernel/Arbiters: Initialize arb_wait_address in thread struct.Michael Scire1-0/+4
2018-06-21Kernel/Arbiters: Mostly implement SignalToAddressMichael Scire1-1/+1
2018-06-21Kernel/Arbiters: Add stubs for 4.x SignalToAddress/WaitForAddres SVCs.Michael Scire1-3/+50
2018-06-20Build: Fixed some MSVC warnings in various parts of the code.Subv1-2/+2
2018-06-18svc: Add a stub for UserExceptionContextAddr.Jules Blok1-0/+5
2018-05-31Kernel/SVC: Support special core values -2 and -3 in svcSetThreadCoreMask.Subv1-1/+26
Also added some proper error handling.
2018-05-19Kernel/SVC: Signal the highest priority threads first in svcSignalProcessWideKey.Subv1-51/+68
2018-05-19Kernel/Threads: Reschedule the proper core when operating on that core's threads.Subv1-2/+6
2018-05-19SVC: Removed unused WaitSynchronization1 functionSubv1-30/+0
2018-05-11thread: Rename mask to affinity_masks.bunnei1-1/+1
2018-05-11threading: Reschedule only on cores that are necessary.bunnei1-2/+2
2018-05-11svc: Implement GetThreadCoreMask and SetThreadCoreMask.bunnei1-7/+22
2018-05-11svc: SignalProcessWideKey should apply to all cores.bunnei1-43/+50
2018-05-11svc: Implement GetCurrentProcessorNumber.bunnei1-2/+2
2018-05-11core: Implement multicore support.bunnei1-21/+22
2018-05-02general: Make formatting of logged hex values more straightforwardLioncash1-38/+39
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-04-30string_util: Remove StringFromFormat() and related functionsLioncash1-1/+1
Given we utilize fmt, we don't need to provide our own functions for formatting anymore
2018-04-27general: Convert assertion macros over to be fmt-compatibleLioncash1-1/+1
2018-04-26kernel: Migrate logging macros to fmt-compatible onesLioncash1-69/+69
2018-04-23Kernel: Implemented mutex priority inheritance.Subv1-0/+9
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-21Kernel: Remove unused ConditionVariable class.Subv1-6/+0
2018-04-21Kernel: Properly implemented svcWaitProcessWideKey and svcSignalProcessWideKeySubv1-83/+46
They work in tandem with guest code to provide synchronization primitives along with svcArbitrateLock/Unlock
2018-04-21Kernel: Corrected the implementation of svcArbitrateLock and svcArbitrateUnlock.Subv1-20/+2
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-21resource_limit: Make ResourceTypes an enum classLioncash1-2/+2
Prevents enum identifiers from leaking into the surrounding scope.
2018-04-20common_funcs: Remove ARRAY_SIZE macroLioncash1-1/+2
C++17 has non-member size() which we can just call where necessary.
2018-04-17Various service name fixes - part 2 (rebased) (#322)Hexagon121-8/+8
* 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-03svc: Stub out SetThreadActivity, GetThreadContext.bunnei1-2/+14
2018-03-30svc: Stub GetThreadCoreMask.bunnei1-3/+11
2018-03-19More Warning cleanupsN00byKing1-1/+1
2018-03-19Clean Warnings (?)N00byKing1-1/+1
2018-03-16svc: Use more correct values for GetInfo MapRegion and NewMapRegion.bunnei1-5/+5
2018-03-16MemoryState: Add additional memory states and improve naming.bunnei1-1/+1
2018-03-14core: Move process creation out of global state.bunnei1-18/+20
2018-02-25(Hopefully) Fix MinGW BuildN00byKing1-1/+1
2018-02-25Add UnmapSharedMemoryN00byKing1-1/+12
C++11 requires spaces on the Identifier Add inttypes include clang
2018-02-22Stub more functionsmailwl1-1/+11
2018-02-18kernel: Use Scheduler class for threading.bunnei1-2/+2
2018-02-04GetInfo: Implement IsCurrentProcessBeingDebugged.bunnei1-0/+3
2018-02-04WaitProcessWideKeyAtomic: Handle case where condition variable was already created.bunnei1-8/+15
2018-02-03svc: SharedMemory size should be 64-bits and cleanup.bunnei1-8/+8
2018-02-03ArbitrateLock: Assert that requesting_thread is current_thread.bunnei1-0/+1
2018-01-25hle: Remove Domain and SyncObject kernel objects.bunnei1-2/+1
2018-01-21Format: Run the new clang format on everythingJames Rowe1-4/+6
2018-01-20Added CreateSharedMemory & UNIMPLEMENTED() for non existent services. (#113)David1-1/+13
* Added svcCreateSharedMemory * Services which are not implemented now throw UNIMPLEMENTED() * clang-format * changed perms to u32 * removed camelcase
2018-01-19svc: Fix svcGetInfo MapRegionBaseAddr.bunnei1-1/+1
2018-01-18svc: Rename some entries to match their analogue on SwitchBrewLioncash1-7/+7
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-18svc: Add CreateJitMemory and MapJitMemory svc stringsLioncash1-2/+2
Makes the table match SwitchBrew for these entries
2018-01-17svc: Clang-format fix.bunnei1-6/+4
2018-01-17SVC: Correct some return values in svcGetInfo and added TitleId and PrivilegedProcessId stubs.Subv1-6/+21
# Conflicts: # src/core/hle/kernel/svc.cpp
2018-01-16SetThreadCoreMask stub, time to implement fspDavid Marcec1-1/+6
2018-01-16Added more svcGetInfo pairsDavid Marcec1-0/+12
2018-01-16clang-formatMerryMage1-6/+4
2018-01-14svc: Implement svcMapSharedMemory.bunnei1-1/+33
2018-01-13yuzu: Update license text to be consistent across project.bunnei1-1/+1
2018-01-12core: Include <algorithm> where used.bunnei1-0/+2
2018-01-12svc: Implement GetSystemTick.bunnei1-2/+13
2018-01-11svc: Stub ResetSignal and CreateTransferMemorySubv1-3/+20
2018-01-11svc: Stub SetMemoryAttributeSubv1-0/+5
2018-01-10Threads: Added enum values for the Switch's 4 cpu cores and implemented svcGetInfo(AllowedCpuIdBitmask)Subv1-6/+11
2018-01-09SVC: Fixed WaitSynchronization with multiple handles when none is immediately ready.Subv1-7/+18
2018-01-09SVC: Implemented CancelSynchronization.Subv1-1/+17
2018-01-09SVC: Fixed WaitSynchronization with multiple handles when at least one of them is ready.Subv1-1/+24
2018-01-09kernel: Rename Semaphore to ConditionVariable.bunnei1-25/+33
2018-01-09Kernel: Actually wake up the requested number of threads in Semaphore::Release.Subv1-1/+1
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.
2018-01-09Kernel: Properly keep track of mutex lock data in the guest memory. This fixes userland locking/unlocking.Subv1-1/+4
2018-01-09Kernel: Allow chaining WaitSynchronization calls inside a wakeup callback.Subv1-15/+41
2018-01-07svc: Implement svcSignalProcessWideKey.bunnei1-2/+21
2018-01-06svc: Implement svcWaitProcessWideKeyAtomic.bunnei1-1/+49
2018-01-06svc: Implement WaitSynchronization for a single handle.bunnei1-4/+24
2018-01-06svc: Refactor LockMutex code to use WaitSynchronization1.bunnei1-13/+45
2018-01-05svc: Add missing string_util include.bunnei1-0/+1
2018-01-03arm: Remove SkyEye/Dyncom code that is ARMv6-only.bunnei1-19/+9
2018-01-03svc: Remove unnecessary "svc" prefix to naming scheme.bunnei1-106/+106
2018-01-03hle: Move SVC code to kernel namespace.bunnei1-100/+93
2018-01-01svc: Improve svcGetInfo.bunnei1-7/+29
2018-01-01svc: Fix string formatting for CreateThread.bunnei1-1/+1
2018-01-01svc: Stub out svcWaitSynchronization.bunnei1-1/+9
- This does not matter until we implement other kernel objects, mutexes use svcLockMutex for waiting.
2018-01-01svc: Implement svcExitProcess.bunnei1-4/+39
2018-01-01svc: Implement svcUnlockMutex.bunnei1-1/+11
2018-01-01svc: Implement svcLockMutex.bunnei1-1/+39
2017-12-31thread: Keep track of the initially created handle.bunnei1-1/+2
This is kinda crufty, but we need it for now to update guest state variables.
2017-12-31svc: Implement svcExitThread.bunnei1-1/+9
2017-12-31svc: Implement svcCreateThread.bunnei1-2/+57
2017-12-31svc: Cleanup svcGetThreadPriority.bunnei1-3/+5
2017-12-31svc: Stub out svcGetCurrentProcessorNumber.bunnei1-1/+7
2017-12-31svc: Implement svcSetThreadPriority.bunnei1-1/+30
2017-12-31svc: Change SignalProcessWideKey to a stub.bunnei1-2/+2
2017-12-31svc: Implement svcUnmapMemory.bunnei1-1/+8
2017-12-30svc: Minor cleanups.bunnei1-8/+9
2017-12-30svc: Implement svcStartThread.bunnei1-0/+16
2017-12-29kernel: Add SyncObject primitive, use it for ClientSession.bunnei1-2/+2
2017-12-29svc: Implement MapMemory.bunnei1-3/+11
2017-12-28svc: Implement SetHeapSize.bunnei1-1/+9
2017-10-23svc: Implement GetThreadId and GetProcessId.bunnei1-2/+29
2017-10-20hle: Fix QueryMemory response for MemoryInfo.bunnei1-17/+11
2017-10-15hle: Initial implementation of NX service framework and IPC.bunnei1-0/+1
2017-10-14svc: Some logging cleanup.bunnei1-7/+5
2017-10-14svc: Initial nx impl. for QueryMemory, ConnectToPort, SendSyncRequest, etc.bunnei1-1185/+185
2017-10-04SVC: Removed GetPointer usage in the GetResourceLimit functions.Subv1-10/+16
2017-10-04SVC: Remove GetPointer usage in CreatePort.Subv1-2/+2
2017-10-04SVC: Replace GetPointer usage with ReadCString in ConnectToPort.Subv1-5/+9
2017-10-04SVC: Replace GetPointer usage with ReadBlock in OutputDebugString.Subv1-2/+4
2017-10-04SVC: Replace GetPointer usage with Read32 in ReplyAndReceive.Subv1-4/+4
2017-10-04SVC: Replace GetPointer usage with Read32 in WaitSynchronizationN.Subv1-4/+4
2017-09-30Moved down_count to CoreTimingHuw Pascoe1-1/+1
2017-09-30Fixed type conversion ambiguityHuw Pascoe1-4/+4
2017-09-28Kernel/Threads: When putting a thread to wait, specify a function to execute when it is awoken.Subv1-4/+65
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.
2017-09-27Kernel/Thread: Allow specifying which process a thread belongs to when creating it.Subv1-2/+3
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.
2017-08-29Use recursive_mutex instead of mutex to fix #2902danzel1-1/+1
2017-08-22Kernel/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).Subv1-2/+6
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.
2017-06-29Kernel/SVC: Pass the current thread as a parameter to ClientSession::SendSyncRequest.Subv1-1/+1
2017-06-26Kernel/SVC: Partially implemented svcReplyAndReceive.Subv1-1/+108
It behaves mostly as WaitSynchronizationN with wait_all = false, except for IPC buffer translation. The target thread of an IPC response will now wake up when responding. IPC buffer translation is currently not implemented. Error passing back to svcSendSyncRequest is currently not implemented.
2017-06-23Kernel: Implement AcceptSession SVCYuri Kunde Schlesner1-1/+12
2017-06-23Kernel: Implement CreateSessionToPort SVCYuri Kunde Schlesner1-1/+12
2017-06-22Kernel: Implement CreateSession SVCYuri Kunde Schlesner1-3/+16
2017-05-30Kernel: Move HandleTable to a separate fileYuri Kunde Schlesner1-0/+2
2017-05-30Kernel: Move WaitObject to a separate fileYuri Kunde Schlesner1-0/+1
Now that HandleTable doesn't directly depend on WaitObject anymore, this can be separated from the main kernel.h header.
2017-05-30Kernel: Removed HandleTable::GetWaitObjectYuri Kunde Schlesner1-2/+2
This isn't necessary anymore since plain Get works correctly for WaitObjects.
2017-05-25Kernel: Centralize error definitions in errors.hYuri Kunde Schlesner1-65/+31
2017-05-08Remove ability to load symbol mapsYuri Kunde Schlesner1-8/+2
This was now mostly unused except by thread creation, which used a symbol of the entrypoint, if available, to name the thread.
2017-04-01Fix OutputDebugString syscallMichael Theall1-2/+2
2017-03-09Refined thread launch on syscore error messagesFernando Sahmkow1-5/+15
2017-02-22Timers: Return an error when calling SetTimer with negative timeouts.Subv1-0/+5
2017-01-11Threads: Check the process' resource limit for the max allowed priority when creating a thread and remove the priority clamping code.Subv1-5/+7
2017-01-11Thread: Added priority range checking to svcSetThreadPriority and removed priority clamping code from Thread::SetPriority.Subv1-0/+14
2017-01-06Kernel: Fix SharedMemory objects always returning error when addr = 0 (#2404)Hyper1-1/+5
Closes #2400
2017-01-06Kernel: Don't attempt to yield execution in SleepThread(0) if there are no available threads to run.Subv1-0/+5
With this we avoid an useless temporary deschedule of the current thread.
2017-01-05Kernel: Remove Thread::wait_objects_index and use wait_objects to hold all the objects that a thread is waiting on.Subv1-11/+3
2017-01-04Kernel: Use different thread statuses when a thread calls WaitSynchronization1 and WaitSynchronizationN with wait_all = true.Subv1-3/+3
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.
2017-01-04Kernel/Mutex: Propagate thread priority changes to other threads inheriting the priority via mutexesSubv1-0/+6
2017-01-04Kernel/Mutex: Update a mutex priority when a thread stops waiting on it.Subv1-2/+3
2017-01-04Kernel/Mutex: Implemented priority inheritance.Subv1-9/+0
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.
2017-01-04Kernel: Object ShouldWait and Acquire calls now take a thread as a parameter.Subv1-6/+6
This will be useful when implementing mutex priority inheritance.
2017-01-04Kernel/Synch: Do not attempt a reschedule on every syscall.Subv1-2/+17
Not all syscalls should cause reschedules, this commit attempts to remedy that, however, it still does not cover all cases.
2016-12-22core: Replace "AppCore" nomenclature with just "CPU".bunnei1-7/+6
2016-12-22Address clang-format issues.bunnei1-9/+10
2016-12-22core: Remove HLE module, consolidate code & various cleanups.bunnei1-35/+35
2016-12-22core: Consolidate core and system state, remove system module & cleanups.bunnei1-6/+6
2016-12-17Thread: remove the thread from the thread list when exitingwwylele1-1/+1
2016-12-14Fixed the codestyle to match our clang-format rules.Subv1-2/+4
2016-12-14Fixed the codestyle to match our clang-format rules.Subv1-19/+28
2016-12-10Properly remove a thread from its wait_objects' waitlist when it is awoken by a timeout.Subv1-1/+1
2016-12-09WaitSynch: Removed unused variables and reduced SharedPtr copies.Subv1-60/+45
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.
2016-12-08Use std::move where appropriate.Subv1-5/+1
2016-12-05Return an error code when connecting to a saturated port.Subv1-1/+2
The error code was taken from the 3DS kernel.
2016-12-05KServerPorts now have an HLE handler "template", which is inherited by all ServerSessions created from it.Subv1-13/+5
2016-12-04Threading: Added some utility functions and const correctness.Subv1-5/+13
2016-12-04Threading: Reworked the way our scheduler works.Subv1-78/+103
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.
2016-12-01Threads do not wait for the server endpoint to call AcceptSession before returning from a ConnectToPort or GetServiceHandle call.Subv1-2/+3
2016-12-01A bit of a redesign.Subv1-2/+9
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.
2016-12-01 Kernel/IPC: Use Ports and Sessions as the fundamental building block of Inter Process Communication.Subv1-3/+15
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.
2016-09-22name objectswwylele1-0/+4
2016-09-21Remove empty newlines in #include blocks.Emmanuel Gil Peyrot1-5/+1
This makes clang-format useful on those. Also add a bunch of forgotten transitive includes, which otherwise prevented compilation.
2016-09-18Sources: Run clang-format on everything.Emmanuel Gil Peyrot1-234/+278
2016-06-11Kernel/SVC: Implemented svcCreatePort.Subv1-1/+20
2016-05-21SVC::WaitSynchronizationN: Reschedule at the endwwylele1-2/+3
2016-05-17Set fpscr for new threadsJannik Vogel1-0/+3
2016-05-13Kernel: Implemented shared memory permissions.Subv1-0/+2
2016-05-13Kernel/SharedMemory: Properly implemented shared memory support.Subv1-12/+35
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.
2016-05-07Kernel/Threading: Warn when a thread can be scheduled in the Syscore (Core 1).Subv1-0/+5
We do not currently implement any cores other than the AppCore (Core 0).
2016-04-29Common: Remove section measurement from profiler (#1731)Yuri Kunde Schlesner1-4/+0
This has been entirely superseded by MicroProfile. The rest of the code can go when a simpler frametime/FPS meter is added to the GUI.
2016-04-21ac:u: stub CloseAsync; check memory size aling in svc:GetProcessInfo(type=2)mailwl1-0/+4
2016-03-13svc: Move ResetType enum to the kernel event headerLioncash1-2/+2
2016-03-01ThreadProcessorId_All on SVC::CreateThreadKloen1-0/+1
2016-01-14HLE/SVC: Implement UnmapMemoryBlock.Subv1-5/+27
This implementation will need to be (almost completely) changed when we implement multiprocess support.
2015-12-25svc: Remove superfluous printf argumentLioncash1-1/+1
2015-12-13svc: Fix compilation with LOG_TRACE enabledLioncash1-1/+1
2015-12-01Kernel: Implement svcGetSystemInfoYuri Kunde Schlesner1-1/+46
This makes smealum/ctrulib@b96dd51d3349961189d4ab1bc2a5c45deff21c09 work with Citra.
2015-08-30SVC: Advance time when calling GetSystemTick to escape busy-wait loopsYuri Kunde Schlesner1-1/+4
Cubic Ninja waited for the frame to end by spinning on a loop calling GetSystemTick while doing nothing else. Since GetSystemTick doesn't cause a reschedule (which advances time), this meant that very little emulated time would pass inside that loop, causing the game to spend most of the frame burning away CPU.
2015-08-25Integrate the MicroProfile profiling libraryYuri Kunde Schlesner1-0/+4
This brings goodies such as a configurable user interface and multi-threaded timeline view.
2015-08-16Kernel: Implement svcGetProcessInfo in a basic wayYuri Kunde Schlesner1-1/+47
This also adds some basic memory usage accounting. These two types are used by Super Smash Bros. during startup.
2015-08-16Kernel: Add more infrastructure to support different memory layoutsYuri Kunde Schlesner1-1/+1
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.
2015-08-16Move core/mem_map.{cpp,h} => core/hle/kernel/memory.{cpp,h}Yuri Kunde Schlesner1-1/+1
2015-08-16Kernel: Properly implement ControlMemory FREE and COMMITYuri Kunde Schlesner1-13/+95
2015-07-21dyncom: Pass SVC immediates directly.Lioncash1-4/+3
Previously it would just re-read the already decoded instruction and extract the immediate value.
2015-07-17Kernel/SVC: Implemented svcQueryProcessMemorySubv1-6/+16
2015-07-17Kernel/SVC: Implemented svcQueryMemory.Subv1-2/+14
2015-07-17Core\HLE : Fix Warningzawata1-2/+2
"signed/unsigned mismatch"
2015-06-17kernel: Fix svcWaitSynch to always acquire requested wait objects.bunnei1-9/+17
2015-05-29Remove every trailing whitespace from the project (but externals).Emmanuel Gil Peyrot1-2/+2
2015-05-25Core/SVC: Map the shared memory created in CreateMemoryBlock to the specified address.Subv1-0/+2
This SharedMemory can be passed to service functions (Which should map the memory into their own address space).
2015-05-21Kernel: Move reschedules from SVCs to actual mechanisms that reschedule.bunnei1-20/+2
2015-05-17Implement svcBreakarchshift1-1/+13
2015-05-15Core/ResourceLimits: Implemented the basic structure of ResourceLimits.Subv1-11/+38
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.
2015-05-15Memmap: Re-organize memory function in two filesYuri Kunde Schlesner1-1/+1
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.
2015-05-12fixup!Subv1-9/+9
2015-05-11Core/HLE: Implemented the SVCs GetProcessId and GetProcessIdOfThreadSubv1-2/+31
2015-05-11Kernel: Capture SharedMemory attributes at creation, not when mappingYuri Kunde Schlesner1-1/+3
2015-05-07Fix printf format warningYuri Kunde Schlesner1-1/+1
2015-05-07Common: Remove common.hYuri Kunde Schlesner1-0/+1
2015-05-06HLE: Clean up SVC dispatch mechanismYuri Kunde Schlesner1-3/+34
2015-04-10SVC: Assert on unsupported CreateThread processor ID.bunnei1-3/+9
2015-04-10SVC: Update various SVCs to cause a reschedule.bunnei1-2/+22
- CreateMutex/ReleaseMutex/ReleaseSemaphore/SetTimer/CancelTimer/ArbitrateAddress
2015-04-10Thread: Implement priority boost for starved threads.bunnei1-6/+16
SVC: Return correct error code on invalid CreateThread processor ID. SVC: Assert when creating a thread with an invalid userland priority.
2015-04-10SVC: Reschedule on svcCreateThread.bunnei1-0/+2
2015-03-16arm_interface: Get rid of GetTicks.Lioncash1-2/+3
Removes a TODO.
2015-02-11Asserts: break/crash program, fit to style guide; log.h->assert.harchshift1-1/+1
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.
2015-02-10Scheduler refactor Pt. 1Kevin Hartman1-5/+9
* 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.
2015-02-10WaitSynch: Always reschedule (verified behavior on hw).bunnei1-4/+4
2015-02-02Kernel: Stop creating useless Handles during object creationYuri Kunde Schlesner1-7/+11
They're finally unnecessary, and will stop cluttering the application's handle table.
2015-02-02SVC: Enable CloseHandle, clean up DuplicateHandleYuri Kunde Schlesner1-9/+5
2015-02-02Thread: Modernize two functions that slipped through previous rebasesYuri Kunde Schlesner1-3/+3
2015-02-02Make Port/Service registration and querying more HW-accurateYuri Kunde Schlesner1-4/+16
2015-01-30SVC: Use CASCADE_RESULT in SVC handlersYuri Kunde Schlesner1-73/+32
2015-01-30Remove result.h InvalidHandleYuri Kunde Schlesner1-15/+16
It was only being used in two places, where it was replaced by a local constant.
2015-01-30SVC: Change return type of handlers to ResultCodeYuri Kunde Schlesner1-90/+90
2015-01-30Kernel: Convert Event to not use HandlesYuri Kunde Schlesner1-11/+29
2015-01-30Kernel: Convert Timer to (mostly) not use HandlesYuri Kunde Schlesner1-7/+40
2015-01-30Kernel: Convert Mutex to not use HandlesYuri Kunde Schlesner1-5/+19
2015-01-30Kernel: Convert AddressArbiter to not use HandlesYuri Kunde Schlesner1-6/+24
2015-01-30Kernel: Convert Semaphore to not use HandlesYuri Kunde Schlesner1-6/+27
2015-01-30Kernel: Convert SharedMemory to not use HandlesYuri Kunde Schlesner1-15/+29
2015-01-27SVC: Update the SVC function tablepurpasmart961-7/+7
2015-01-22WaitSynchronization: Added a result code for invalid result, fixed bug.bunnei1-3/+9
2015-01-22Thread: Fix WaitSynchronization1 to not set register 1 on thread wakeup.bunnei1-3/+3
2015-01-22Kernel: Changed "ShouldWait" to return bool and "Acquire" to return void.bunnei1-7/+3
2015-01-22WaitObject: Renamed "Wait" to "ShouldWait", made "ShouldWait" and "Acquire" pure virtual.bunnei1-2/+2
2015-01-22Kernel: Reschedule on SignalEvent and SendSyncRequest, fix some bugs.bunnei1-0/+1
2015-01-22Kernel: Moved Wait and Acquire to WaitObject, added way to retrieve a WaitObject safely.bunnei1-2/+2
2015-01-22SVC: Removed a Sleep that made no sensebunnei1-6/+1
- Would deadlock the calling thread - Code would never get hit anyways
2015-01-22AddressArbiter: Changed to Kernel::Object, big cleanup, removed code that made no sense.bunnei1-3/+3
2015-01-22Kernel: Get rid of WaitTypes and simplify lots of code, removing hacks.bunnei1-10/+20
2015-01-22WaitSynchronizationN: Improved commentsbunnei1-7/+12
2015-01-22WaitSynchronizationN: Refactor to fix several bugsbunnei1-25/+27
- 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
2015-01-22Kernel: Separate WaitSynchronization into Wait and Acquire methods.bunnei1-4/+5
2015-01-22WaitSynchronizationN: Handle case where handles=nullptr.bunnei1-0/+4
2015-01-22WaitSynchronizationN: Handle case where handle_count is invalid.bunnei1-3/+7
2015-01-22WaitSynchronizationN: Handle case where handle_count=0.bunnei1-19/+29
2015-01-22WaitSynchronizationN: Implement return valuesbunnei1-27/+50
2015-01-13AddrArbiter: Implement arbitration types 3 and 4.Subv1-1/+1
2015-01-11SVC: Wake up the thread after the delay in WaitSync1Subv1-3/+2
2015-01-10Logging: Log all called service functions (under trace). Compile out all trace logs under release for performance.archshift1-1/+0
2015-01-09Kernel: Start using boost::intrusive_ptr for lifetime managementYuri Kunde Schlesner1-13/+18
2015-01-09Thread: Reduce use of Handles and move some funcs to inside the class.Yuri Kunde Schlesner1-20/+31
2015-01-09Move ThreadContext to core/core.h and deal with the falloutYuri Kunde Schlesner1-0/+1
2015-01-09SVC: Implemented the Timer service calls.Subv1-4/+32
2015-01-09SVC: Fixed SleepThread.Subv1-0/+4
It will now properly wait the specified number of nanoseconds and then wake up the thread.
2015-01-07Warn if a new thread is intended to be run on the system CPU core until we implement correct scheduling for such a thread.Kevin Hartman1-0/+5
2014-12-31SOC_U: Preliminary implementation of sockets.Subv1-1/+13
Stubbed CreateMemoryBlock Using Berkeley sockets, and Winsock2.2 on Windows. So far ftpony creates the socket and accepts incoming connections SOC_U: Renamed functions to maintain consistency Also prevents possible scope errors / conflicts with the actual Berkeley socket functions SOCU: Close all the opened sockets when cleaning up SOCU
2014-12-28Kernel: New handle managerYuri Kunde Schlesner1-19/+9
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.
2014-12-28Rename ObjectPool to HandleTableYuri Kunde Schlesner1-5/+5
2014-12-21License changepurpasmart961-1/+1
2014-12-21Thread: Wait current thread on svc_SleepThreadbunnei1-1/+2
- Removed unused VBLANK sleep mode - Added error log for bad context switch - Renamed VerifyWait to CheckWaitType to be more clear
2014-12-15Remove SyncRequest from K::Object and create a new K::Session typeYuri Kunde Schlesner1-7/+4
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.)
2014-12-13Kernel/Semaphores: Fixed buildSubv1-2/+2
2014-12-13SVC: Implemented ReleaseSemaphore.Subv1-3/+10
This behavior was tested on hardware, however i'm still not sure what use the "initial_count" parameter has
2014-12-13SVC: Implemented svcCreateSemaphoreSubv1-1/+10
ToDo: Implement svcReleaseSemaphore * Some testing against hardware needed
2014-12-13Convert old logging calls to new logging macrosYuri Kunde Schlesner1-27/+27
2014-12-12MemMap: Renamed "GSP" heap to "linear", as this is not specific to GSP.bunnei1-1/+1
- Linear simply indicates that the mapped physical address is always MappedVAddr+0x0C000000, thus this memory can be used for hardware devices' DMA (such as the GPU).
2014-12-04SVC: Implemented GetThreadId.Subv1-4/+5
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.
2014-11-26SVC: Add debug log to ArbitrateAddress.bunnei1-0/+2
2014-11-26SVC: SleepThread should yield to the next ready thread.bunnei1-0/+3
2014-11-24HLE: Revamp error handling throrough the HLE codeYuri Kunde Schlesner1-31/+37
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.
2014-11-19Remove trailing spaces in every file but the ones imported from SkyEye, AOSP or generatedEmmanuel Gil Peyrot1-14/+14
2014-11-19Kernel:Add missing permissions in shared memory & svcpurpasmart961-0/+4
2014-11-18core: Mark some hle functions as staticLioncash1-26/+26
These functions are not referred to by their linkage name outside of the translation unit, so they can be marked as static.
2014-10-30Fix some warningsSean1-3/+3
2014-09-09core: Prune redundant includesarchshift1-3/+0
2014-09-09Added string_util to common, small changes in loader.cpparchshift1-1/+1
2014-08-19SVC: Added support for svc_GetSystemTick.bunnei1-1/+6
Changed HLE function return methods to be static inline functions.
2014-08-18Core: Alter the kernel string functions to use std::string instead of const char*.Lioncash1-5/+5
Most functions already operate on std::strings. This also removes the need to manually null terminate thread names.
2014-08-17Core: Fix a formatting error in svc.cppLioncash1-3/+2
entry_point would not be added to the string. Also used StringFromFormat so that the buffer is unnecessary.
2014-08-08SVC: Fixed typo with MapMemoryBlock DEBUG_LOG call.bunnei1-1/+1
2014-08-06SVC: Removed ArbitrateAddress log message that spams to much.bunnei1-2/+0
2014-07-09Kernel: Added preliminary support for address arbiters.bunnei1-8/+10
AddressArbiter: Added documentation comment, fixed whitespace issue. AddressArbiter: Fixed incorrect comment, reordered if-statement to be more clear. SVC: Removed trailing whitespace.
2014-07-05SharedMemory: Updated MapSharedMemory to use an enum for permissions.bunnei1-10/+9
- Also added some safety checks to MapSharedMemory.
2014-07-05GSP: Fixed to use real shared memory object, various cleanups.bunnei1-5/+6
- Previously, used a hard-coded shared memory handle of 0x10002000 (as used by libctru homebrew) GSP: Added name for shared memory. GSP: Cleaned up assertion message.
2014-06-13SVC: Renamed all function wrapper templates to Wrap, moved to HLE namespace.bunnei1-126/+126
2014-06-13SVC: Cleaned up function wrappers to pass in correct argument types.bunnei1-148/+138
2014-06-13SVC: Moved declaration of "wait" variable in SendSyncRequest for improved readability.bunnei1-1/+1
2014-06-13HLE: Updated all uses of NULL to nullptr (to be C++11 compliant)bunnei1-107/+107
2014-06-13HLE: Updated various handle debug assertions to be more clear.bunnei1-6/+6
2014-06-13Kernel: Added real support for thread and event blockingbunnei1-28/+31
- 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.
2014-06-02svc: updated WaitSynchronizationN to properly use first pointer argumentbunnei1-3/+3
2014-06-02svc: changed DuplicateHandle log message from "error" to "debug"bunnei1-1/+1
2014-06-02svc: added GetThreadPriority and SetThreadPriority, added (incomplete) DuplicateHandle supportbunnei1-3/+26
2014-06-02kernel: changed main thread priority to default, updated Kernel::Reschedule to use PrepareReschedulebunnei1-2/+7
2014-06-02svc: cleaned up function_wrappers, updated various SVCs to make use of pointer argumentsbunnei1-16/+18
2014-06-01svc: updated waitSychronization to not overwrite handle on return, added stub for SleepThread (does nothing)bunnei1-2/+21
2014-05-30hle: cleaned up log messagesbunnei1-27/+28
2014-05-30svc: updated OutputDebugString to use OS_LOGbunnei1-1/+1
2014-05-30svc: changed unimplemented SVC log messages from "debug" messages to "error" messagesbunnei1-8/+8
2014-05-30svc: added svcClearEvent, stubbed function for svcArbitrateAddress, and various fixesbunnei1-22/+32
- force kernel reschedule after svcWaitSynchronization - fixed some bugs with passing in pointer arguments - cleaned up some comments and log messages
2014-05-28svc: implemented WaitSynchronization1, WaitSynchronizationN, and CreateEventbunnei1-14/+54
2014-05-27kernel: updated SyncRequest to take boolean thread wait result as a parameterbunnei1-2/+9
2014-05-27svc: added some assertionsbunnei1-6/+4
2014-05-27svc: changed SendSyncRequest to use Kernel::Object SyncRequest (instead of just service Interface class)bunnei1-2/+2
2014-05-27svc: added stub for DuplicateHandle SVC callbunnei1-1/+8
2014-05-23svc: added a check to ensure that a service was implemented before attempting to connect to its portbunnei1-1/+5
2014-05-23thread: renamed "WaitCurThread" to "WaitCurrentThread", removed unused "reason" argumentbunnei1-2/+2
2014-05-23thread: removed unused SwitchContext/Reschedule reason field, added missing arg parameter to SVC CreateThreadbunnei1-8/+5
2014-05-22svc: added Kernel::Reschedule to svc WaitSynchronization1, updated log messages to include newly created handlesbunnei1-4/+7
2014-05-21svc: enabled use of newly created kernel thread handlebunnei1-5/+5
2014-05-21mutex: refactored the interface to code to return a Mutex* handlebunnei1-1/+1
2014-05-21mutex: initial commit of HLE modulebunnei1-4/+5
2014-05-21svc: added some commentsbunnei1-0/+7
2014-05-21thread: moved threading calls to the Kernel namespacebunnei1-2/+2
2014-05-21renamed "syscall" module to "svc" (more accurate naming)bunnei1-5/+7
2014-05-19renamed "session" to "handle"bunnei1-3/+3
2014-05-19fix warningbunnei1-1/+1
2014-05-19renamed "UID" to "Handle" where appropriatebunnei1-2/+2
2014-05-18- added stub for CreateEventbunnei1-8/+22
- changed some stubbed SVCs to return unique handle names for debugging purposes
2014-05-18added stubbed function for WaitSynchronizationNbunnei1-3/+13
2014-05-17cleanups to SVC CreateThreadbunnei1-8/+15
2014-05-16- added SVC stubs for QueryMemory and GetThreadIdbunnei1-2/+14
- added SVC structs MemoryInfo and PageInfo
2014-05-16- added ThreadContext structbunnei1-8/+12
- cleaned up CreateThread svc
2014-05-14added CreateThread, CreateMutex, and ReleaseMutex SVC stubs (just parameter decoding for now)bunnei1-6/+37
2014-05-08removed unnecessary log messagebunnei1-1/+1
2014-05-07- added debug logging to syscall.cppbunnei1-134/+162
- added stubbed HLE syscall functions for svc_GetResourceLimit and svc_GetResourceLimitCurrentValues
2014-05-02- added some function wrappers for HLEbunnei1-2/+17
- added stub for SVC CreateAddressArbiter - added OutputDebugString SVC
2014-04-25fixed bug where svc_ControlMemory was not properly getting passed in parametersbunnei1-2/+2
2014-04-25- added preliminary support for svc_MapMemoryBlockbunnei1-4/+34
- added shared memory region - moarrrr cleanups to memory_map
2014-04-18renamed hw_lcd module to just lcdbunnei1-2/+0
2014-04-18added GSP heap memory allocationbunnei1-1/+25
2014-04-17- fixed tabs in function_wrappers.hbunnei1-126/+138
- fixed log message wording in hle.cpp - added syscall stubs for CloseHandle and WaitSynchronization1
2014-04-13- added HLE to connect to "srv:" servicebunnei1-128/+138
- added a manager for keeping track of services/ports - added a memory mapped region for memory accessed by HLE - added HLE for GetThreadCommandBuffer function
2014-04-12- renamed hle_syscall to just syscallbunnei1-62/+64
- added service.h as an initial service interface
2014-04-11added remaining known syscall functions to Syscall_Tablebunnei1-0/+80
2014-04-11base code to call a syscall from ARM11 appcorebunnei1-4/+51
2014-04-11changed some naming/misc cleanupsbunnei1-2/+2
2014-04-11- removed syscall classes (will just use HLEFunction)bunnei1-4/+6
- added hle.cpp and module registration - removed unused code
2014-04-11added initial modules for setting up SysCall HLEbunnei1-0/+22